]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.6-201310292050.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.6-201310292050.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 7f9d4f5..6d1afd6 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,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 @@ -1932,6 +1936,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 @@ -2199,6 +2207,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 e87ba83..ee3c7b7 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 # Store (new) KERNELRELEASE string in include/config/kernel.release
403 @@ -835,6 +897,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 @@ -942,6 +1005,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 @@ -957,7 +1022,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 @@ -1023,7 +1088,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 @@ -1063,6 +1128,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 @@ -1224,6 +1290,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 @@ -1363,17 +1431,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 @@ -1383,11 +1455,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 0c4132d..88f0d53 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 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
2095 index f1d96d4..73ddd72 100644
2096 --- a/arch/arm/include/asm/syscall.h
2097 +++ b/arch/arm/include/asm/syscall.h
2098 @@ -57,6 +57,9 @@ static inline void syscall_get_arguments(struct task_struct *task,
2099 unsigned int i, unsigned int n,
2100 unsigned long *args)
2101 {
2102 + if (n == 0)
2103 + return;
2104 +
2105 if (i + n > SYSCALL_MAX_ARGS) {
2106 unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
2107 unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
2108 @@ -81,6 +84,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
2109 unsigned int i, unsigned int n,
2110 const unsigned long *args)
2111 {
2112 + if (n == 0)
2113 + return;
2114 +
2115 if (i + n > SYSCALL_MAX_ARGS) {
2116 pr_warning("%s called with max args %d, handling only %d\n",
2117 __func__, i + n, SYSCALL_MAX_ARGS);
2118 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2119 index 2b8114f..8fe9bcf 100644
2120 --- a/arch/arm/include/asm/thread_info.h
2121 +++ b/arch/arm/include/asm/thread_info.h
2122 @@ -77,9 +77,9 @@ struct thread_info {
2123 .flags = 0, \
2124 .preempt_count = INIT_PREEMPT_COUNT, \
2125 .addr_limit = KERNEL_DS, \
2126 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2127 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2128 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2129 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2130 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2131 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2132 .restart_block = { \
2133 .fn = do_no_restart_syscall, \
2134 }, \
2135 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2136 #define TIF_SYSCALL_AUDIT 9
2137 #define TIF_SYSCALL_TRACEPOINT 10
2138 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2139 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2140 +/* within 8 bits of TIF_SYSCALL_TRACE
2141 + * to meet flexible second operand requirements
2142 + */
2143 +#define TIF_GRSEC_SETXID 12
2144 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2145 #define TIF_USING_IWMMXT 17
2146 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2147 #define TIF_RESTORE_SIGMASK 20
2148 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2149 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2150 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2151 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2152 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2153
2154 /* Checks for any syscall work in entry-common.S */
2155 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2156 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2157 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2158
2159 /*
2160 * Change these and you break ASM code in entry-common.S
2161 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2162 index 7e1f760..de33b13 100644
2163 --- a/arch/arm/include/asm/uaccess.h
2164 +++ b/arch/arm/include/asm/uaccess.h
2165 @@ -18,6 +18,7 @@
2166 #include <asm/domain.h>
2167 #include <asm/unified.h>
2168 #include <asm/compiler.h>
2169 +#include <asm/pgtable.h>
2170
2171 #define VERIFY_READ 0
2172 #define VERIFY_WRITE 1
2173 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2174 static inline void set_fs(mm_segment_t fs)
2175 {
2176 current_thread_info()->addr_limit = fs;
2177 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2178 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2179 }
2180
2181 #define segment_eq(a,b) ((a) == (b))
2182
2183 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2184 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2185 +
2186 +static inline void pax_open_userland(void)
2187 +{
2188 +
2189 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2190 + if (segment_eq(get_fs(), USER_DS)) {
2191 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2192 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2193 + }
2194 +#endif
2195 +
2196 +}
2197 +
2198 +static inline void pax_close_userland(void)
2199 +{
2200 +
2201 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2202 + if (segment_eq(get_fs(), USER_DS)) {
2203 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2204 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2205 + }
2206 +#endif
2207 +
2208 +}
2209 +
2210 #define __addr_ok(addr) ({ \
2211 unsigned long flag; \
2212 __asm__("cmp %2, %0; movlo %0, #0" \
2213 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2214
2215 #define get_user(x,p) \
2216 ({ \
2217 + int __e; \
2218 might_fault(); \
2219 - __get_user_check(x,p); \
2220 + pax_open_userland(); \
2221 + __e = __get_user_check(x,p); \
2222 + pax_close_userland(); \
2223 + __e; \
2224 })
2225
2226 extern int __put_user_1(void *, unsigned int);
2227 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2228
2229 #define put_user(x,p) \
2230 ({ \
2231 + int __e; \
2232 might_fault(); \
2233 - __put_user_check(x,p); \
2234 + pax_open_userland(); \
2235 + __e = __put_user_check(x,p); \
2236 + pax_close_userland(); \
2237 + __e; \
2238 })
2239
2240 #else /* CONFIG_MMU */
2241 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2242 #define __get_user(x,ptr) \
2243 ({ \
2244 long __gu_err = 0; \
2245 + pax_open_userland(); \
2246 __get_user_err((x),(ptr),__gu_err); \
2247 + pax_close_userland(); \
2248 __gu_err; \
2249 })
2250
2251 #define __get_user_error(x,ptr,err) \
2252 ({ \
2253 + pax_open_userland(); \
2254 __get_user_err((x),(ptr),err); \
2255 + pax_close_userland(); \
2256 (void) 0; \
2257 })
2258
2259 @@ -312,13 +352,17 @@ do { \
2260 #define __put_user(x,ptr) \
2261 ({ \
2262 long __pu_err = 0; \
2263 + pax_open_userland(); \
2264 __put_user_err((x),(ptr),__pu_err); \
2265 + pax_close_userland(); \
2266 __pu_err; \
2267 })
2268
2269 #define __put_user_error(x,ptr,err) \
2270 ({ \
2271 + pax_open_userland(); \
2272 __put_user_err((x),(ptr),err); \
2273 + pax_close_userland(); \
2274 (void) 0; \
2275 })
2276
2277 @@ -418,11 +462,44 @@ do { \
2278
2279
2280 #ifdef CONFIG_MMU
2281 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2282 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2283 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2284 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2285 +
2286 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2287 +{
2288 + unsigned long ret;
2289 +
2290 + check_object_size(to, n, false);
2291 + pax_open_userland();
2292 + ret = ___copy_from_user(to, from, n);
2293 + pax_close_userland();
2294 + return ret;
2295 +}
2296 +
2297 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2298 +{
2299 + unsigned long ret;
2300 +
2301 + check_object_size(from, n, true);
2302 + pax_open_userland();
2303 + ret = ___copy_to_user(to, from, n);
2304 + pax_close_userland();
2305 + return ret;
2306 +}
2307 +
2308 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2309 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2310 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2311 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2312 +
2313 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2314 +{
2315 + unsigned long ret;
2316 + pax_open_userland();
2317 + ret = ___clear_user(addr, n);
2318 + pax_close_userland();
2319 + return ret;
2320 +}
2321 +
2322 #else
2323 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2324 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2325 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2326
2327 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2328 {
2329 + if ((long)n < 0)
2330 + return n;
2331 +
2332 if (access_ok(VERIFY_READ, from, n))
2333 n = __copy_from_user(to, from, n);
2334 else /* security hole - plug it */
2335 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2336
2337 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2338 {
2339 + if ((long)n < 0)
2340 + return n;
2341 +
2342 if (access_ok(VERIFY_WRITE, to, n))
2343 n = __copy_to_user(to, from, n);
2344 return n;
2345 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2346 index 5af0ed1..cea83883 100644
2347 --- a/arch/arm/include/uapi/asm/ptrace.h
2348 +++ b/arch/arm/include/uapi/asm/ptrace.h
2349 @@ -92,7 +92,7 @@
2350 * ARMv7 groups of PSR bits
2351 */
2352 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2353 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2354 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2355 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2356 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2357
2358 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2359 index 60d3b73..e5a0f22 100644
2360 --- a/arch/arm/kernel/armksyms.c
2361 +++ b/arch/arm/kernel/armksyms.c
2362 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2363
2364 /* networking */
2365 EXPORT_SYMBOL(csum_partial);
2366 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2367 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2368 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2369 EXPORT_SYMBOL(__csum_ipv6_magic);
2370
2371 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2372 #ifdef CONFIG_MMU
2373 EXPORT_SYMBOL(copy_page);
2374
2375 -EXPORT_SYMBOL(__copy_from_user);
2376 -EXPORT_SYMBOL(__copy_to_user);
2377 -EXPORT_SYMBOL(__clear_user);
2378 +EXPORT_SYMBOL(___copy_from_user);
2379 +EXPORT_SYMBOL(___copy_to_user);
2380 +EXPORT_SYMBOL(___clear_user);
2381
2382 EXPORT_SYMBOL(__get_user_1);
2383 EXPORT_SYMBOL(__get_user_2);
2384 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2385 index 9cbe70c..a7b5e34 100644
2386 --- a/arch/arm/kernel/entry-armv.S
2387 +++ b/arch/arm/kernel/entry-armv.S
2388 @@ -47,6 +47,87 @@
2389 9997:
2390 .endm
2391
2392 + .macro pax_enter_kernel
2393 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2394 + @ make aligned space for saved DACR
2395 + sub sp, sp, #8
2396 + @ save regs
2397 + stmdb sp!, {r1, r2}
2398 + @ read DACR from cpu_domain into r1
2399 + mov r2, sp
2400 + @ assume 8K pages, since we have to split the immediate in two
2401 + bic r2, r2, #(0x1fc0)
2402 + bic r2, r2, #(0x3f)
2403 + ldr r1, [r2, #TI_CPU_DOMAIN]
2404 + @ store old DACR on stack
2405 + str r1, [sp, #8]
2406 +#ifdef CONFIG_PAX_KERNEXEC
2407 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2408 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2409 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2410 +#endif
2411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2412 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 +#endif
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r2, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r1, r2}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_open_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2439 + @ write r1 to current_thread_info()->cpu_domain
2440 + str r1, [r0, #TI_CPU_DOMAIN]
2441 + @ write r1 to DACR
2442 + mcr p15, 0, r1, c3, c0, 0
2443 + @ instruction sync
2444 + instr_sync
2445 + @ restore regs
2446 + ldmia sp!, {r0, r1}
2447 +#endif
2448 + .endm
2449 +
2450 + .macro pax_close_userland
2451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2452 + @ save regs
2453 + stmdb sp!, {r0, r1}
2454 + @ read DACR from cpu_domain into r1
2455 + mov r0, sp
2456 + @ assume 8K pages, since we have to split the immediate in two
2457 + bic r0, r0, #(0x1fc0)
2458 + bic r0, r0, #(0x3f)
2459 + ldr r1, [r0, #TI_CPU_DOMAIN]
2460 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2461 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2462 + @ write r1 to current_thread_info()->cpu_domain
2463 + str r1, [r0, #TI_CPU_DOMAIN]
2464 + @ write r1 to DACR
2465 + mcr p15, 0, r1, c3, c0, 0
2466 + @ instruction sync
2467 + instr_sync
2468 + @ restore regs
2469 + ldmia sp!, {r0, r1}
2470 +#endif
2471 + .endm
2472 +
2473 .macro pabt_helper
2474 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2475 #ifdef MULTI_PABORT
2476 @@ -89,11 +170,15 @@
2477 * Invalid mode handlers
2478 */
2479 .macro inv_entry, reason
2480 +
2481 + pax_enter_kernel
2482 +
2483 sub sp, sp, #S_FRAME_SIZE
2484 ARM( stmib sp, {r1 - lr} )
2485 THUMB( stmia sp, {r0 - r12} )
2486 THUMB( str sp, [sp, #S_SP] )
2487 THUMB( str lr, [sp, #S_LR] )
2488 +
2489 mov r1, #\reason
2490 .endm
2491
2492 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2493 .macro svc_entry, stack_hole=0
2494 UNWIND(.fnstart )
2495 UNWIND(.save {r0 - pc} )
2496 +
2497 + pax_enter_kernel
2498 +
2499 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2500 +
2501 #ifdef CONFIG_THUMB2_KERNEL
2502 SPFIX( str r0, [sp] ) @ temporarily saved
2503 SPFIX( mov r0, sp )
2504 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2505 ldmia r0, {r3 - r5}
2506 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2507 mov r6, #-1 @ "" "" "" ""
2508 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2509 + @ offset sp by 8 as done in pax_enter_kernel
2510 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2511 +#else
2512 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2513 +#endif
2514 SPFIX( addeq r2, r2, #4 )
2515 str r3, [sp, #-4]! @ save the "real" r0 copied
2516 @ from the exception stack
2517 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2518 .macro usr_entry
2519 UNWIND(.fnstart )
2520 UNWIND(.cantunwind ) @ don't unwind the user space
2521 +
2522 + pax_enter_kernel_user
2523 +
2524 sub sp, sp, #S_FRAME_SIZE
2525 ARM( stmib sp, {r1 - r12} )
2526 THUMB( stmia sp, {r0 - r12} )
2527 @@ -415,7 +512,9 @@ __und_usr:
2528 tst r3, #PSR_T_BIT @ Thumb mode?
2529 bne __und_usr_thumb
2530 sub r4, r2, #4 @ ARM instr at LR - 4
2531 + pax_open_userland
2532 1: ldrt r0, [r4]
2533 + pax_close_userland
2534 #ifdef CONFIG_CPU_ENDIAN_BE8
2535 rev r0, r0 @ little endian instruction
2536 #endif
2537 @@ -450,10 +549,14 @@ __und_usr_thumb:
2538 */
2539 .arch armv6t2
2540 #endif
2541 + pax_open_userland
2542 2: ldrht r5, [r4]
2543 + pax_close_userland
2544 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2545 blo __und_usr_fault_16 @ 16bit undefined instruction
2546 + pax_open_userland
2547 3: ldrht r0, [r2]
2548 + pax_close_userland
2549 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2550 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2551 orr r0, r0, r5, lsl #16
2552 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2553 */
2554 .pushsection .fixup, "ax"
2555 .align 2
2556 -4: mov pc, r9
2557 +4: pax_close_userland
2558 + mov pc, r9
2559 .popsection
2560 .pushsection __ex_table,"a"
2561 .long 1b, 4b
2562 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2563 THUMB( str lr, [ip], #4 )
2564 ldr r4, [r2, #TI_TP_VALUE]
2565 ldr r5, [r2, #TI_TP_VALUE + 4]
2566 -#ifdef CONFIG_CPU_USE_DOMAINS
2567 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2568 ldr r6, [r2, #TI_CPU_DOMAIN]
2569 #endif
2570 switch_tls r1, r4, r5, r3, r7
2571 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2572 ldr r8, =__stack_chk_guard
2573 ldr r7, [r7, #TSK_STACK_CANARY]
2574 #endif
2575 -#ifdef CONFIG_CPU_USE_DOMAINS
2576 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2577 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2578 #endif
2579 mov r5, r0
2580 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2581 index 94104bf..e425391 100644
2582 --- a/arch/arm/kernel/entry-common.S
2583 +++ b/arch/arm/kernel/entry-common.S
2584 @@ -10,18 +10,46 @@
2585
2586 #include <asm/unistd.h>
2587 #include <asm/ftrace.h>
2588 +#include <asm/domain.h>
2589 #include <asm/unwind.h>
2590
2591 +#include "entry-header.S"
2592 +
2593 #ifdef CONFIG_NEED_RET_TO_USER
2594 #include <mach/entry-macro.S>
2595 #else
2596 .macro arch_ret_to_user, tmp1, tmp2
2597 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2598 + @ save regs
2599 + stmdb sp!, {r1, r2}
2600 + @ read DACR from cpu_domain into r1
2601 + mov r2, sp
2602 + @ assume 8K pages, since we have to split the immediate in two
2603 + bic r2, r2, #(0x1fc0)
2604 + bic r2, r2, #(0x3f)
2605 + ldr r1, [r2, #TI_CPU_DOMAIN]
2606 +#ifdef CONFIG_PAX_KERNEXEC
2607 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2608 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2609 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2610 +#endif
2611 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2612 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2613 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2614 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2615 +#endif
2616 + @ write r1 to current_thread_info()->cpu_domain
2617 + str r1, [r2, #TI_CPU_DOMAIN]
2618 + @ write r1 to DACR
2619 + mcr p15, 0, r1, c3, c0, 0
2620 + @ instruction sync
2621 + instr_sync
2622 + @ restore regs
2623 + ldmia sp!, {r1, r2}
2624 +#endif
2625 .endm
2626 #endif
2627
2628 -#include "entry-header.S"
2629 -
2630 -
2631 .align 5
2632 /*
2633 * This is the fast syscall return path. We do as little as
2634 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2635 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2636 #endif
2637
2638 + /*
2639 + * do this here to avoid a performance hit of wrapping the code above
2640 + * that directly dereferences userland to parse the SWI instruction
2641 + */
2642 + pax_enter_kernel_user
2643 +
2644 adr tbl, sys_call_table @ load syscall table pointer
2645
2646 #if defined(CONFIG_OABI_COMPAT)
2647 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2648 index de23a9b..94c37c4 100644
2649 --- a/arch/arm/kernel/entry-header.S
2650 +++ b/arch/arm/kernel/entry-header.S
2651 @@ -184,6 +184,60 @@
2652 msr cpsr_c, \rtemp @ switch back to the SVC mode
2653 .endm
2654
2655 + .macro pax_enter_kernel_user
2656 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2657 + @ save regs
2658 + stmdb sp!, {r0, r1}
2659 + @ read DACR from cpu_domain into r1
2660 + mov r0, sp
2661 + @ assume 8K pages, since we have to split the immediate in two
2662 + bic r0, r0, #(0x1fc0)
2663 + bic r0, r0, #(0x3f)
2664 + ldr r1, [r0, #TI_CPU_DOMAIN]
2665 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2666 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2667 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2668 +#endif
2669 +#ifdef CONFIG_PAX_KERNEXEC
2670 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2671 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2672 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2673 +#endif
2674 + @ write r1 to current_thread_info()->cpu_domain
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 + .macro pax_exit_kernel
2686 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2687 + @ save regs
2688 + stmdb sp!, {r0, r1}
2689 + @ read old DACR from stack into r1
2690 + ldr r1, [sp, #(8 + S_SP)]
2691 + sub r1, r1, #8
2692 + ldr r1, [r1]
2693 +
2694 + @ write r1 to current_thread_info()->cpu_domain
2695 + mov r0, sp
2696 + @ assume 8K pages, since we have to split the immediate in two
2697 + bic r0, r0, #(0x1fc0)
2698 + bic r0, r0, #(0x3f)
2699 + str r1, [r0, #TI_CPU_DOMAIN]
2700 + @ write r1 to DACR
2701 + mcr p15, 0, r1, c3, c0, 0
2702 + @ instruction sync
2703 + instr_sync
2704 + @ restore regs
2705 + ldmia sp!, {r0, r1}
2706 +#endif
2707 + .endm
2708 +
2709 #ifndef CONFIG_THUMB2_KERNEL
2710 .macro svc_exit, rpsr, irq = 0
2711 .if \irq != 0
2712 @@ -203,6 +257,9 @@
2713 blne trace_hardirqs_off
2714 #endif
2715 .endif
2716 +
2717 + pax_exit_kernel
2718 +
2719 msr spsr_cxsf, \rpsr
2720 #if defined(CONFIG_CPU_V6)
2721 ldr r0, [sp]
2722 @@ -266,6 +323,9 @@
2723 blne trace_hardirqs_off
2724 #endif
2725 .endif
2726 +
2727 + pax_exit_kernel
2728 +
2729 ldr lr, [sp, #S_SP] @ top of the stack
2730 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2731 clrex @ clear the exclusive monitor
2732 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2733 index 918875d..cd5fa27 100644
2734 --- a/arch/arm/kernel/fiq.c
2735 +++ b/arch/arm/kernel/fiq.c
2736 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2737 void *base = vectors_page;
2738 unsigned offset = FIQ_OFFSET;
2739
2740 + pax_open_kernel();
2741 memcpy(base + offset, start, length);
2742 + pax_close_kernel();
2743 +
2744 if (!cache_is_vipt_nonaliasing())
2745 flush_icache_range((unsigned long)base + offset, offset +
2746 length);
2747 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2748 index 2c7cc1e..ab2e911 100644
2749 --- a/arch/arm/kernel/head.S
2750 +++ b/arch/arm/kernel/head.S
2751 @@ -52,7 +52,9 @@
2752 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2753
2754 .macro pgtbl, rd, phys
2755 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2756 + mov \rd, #TEXT_OFFSET
2757 + sub \rd, #PG_DIR_SIZE
2758 + add \rd, \rd, \phys
2759 .endm
2760
2761 /*
2762 @@ -432,7 +434,7 @@ __enable_mmu:
2763 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2764 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2765 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2766 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2767 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2768 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2769 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2770 #endif
2771 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2772 index 85c3fb6..054c2dc 100644
2773 --- a/arch/arm/kernel/module.c
2774 +++ b/arch/arm/kernel/module.c
2775 @@ -37,12 +37,39 @@
2776 #endif
2777
2778 #ifdef CONFIG_MMU
2779 -void *module_alloc(unsigned long size)
2780 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2781 {
2782 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2783 + return NULL;
2784 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2785 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2786 + GFP_KERNEL, prot, -1,
2787 __builtin_return_address(0));
2788 }
2789 +
2790 +void *module_alloc(unsigned long size)
2791 +{
2792 +
2793 +#ifdef CONFIG_PAX_KERNEXEC
2794 + return __module_alloc(size, PAGE_KERNEL);
2795 +#else
2796 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2797 +#endif
2798 +
2799 +}
2800 +
2801 +#ifdef CONFIG_PAX_KERNEXEC
2802 +void module_free_exec(struct module *mod, void *module_region)
2803 +{
2804 + module_free(mod, module_region);
2805 +}
2806 +EXPORT_SYMBOL(module_free_exec);
2807 +
2808 +void *module_alloc_exec(unsigned long size)
2809 +{
2810 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2811 +}
2812 +EXPORT_SYMBOL(module_alloc_exec);
2813 +#endif
2814 #endif
2815
2816 int
2817 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2818 index 07314af..c46655c 100644
2819 --- a/arch/arm/kernel/patch.c
2820 +++ b/arch/arm/kernel/patch.c
2821 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2822 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2823 int size;
2824
2825 + pax_open_kernel();
2826 if (thumb2 && __opcode_is_thumb16(insn)) {
2827 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2828 size = sizeof(u16);
2829 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2830 *(u32 *)addr = insn;
2831 size = sizeof(u32);
2832 }
2833 + pax_close_kernel();
2834
2835 flush_icache_range((uintptr_t)(addr),
2836 (uintptr_t)(addr) + size);
2837 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2838 index 94f6b05..efd7312 100644
2839 --- a/arch/arm/kernel/process.c
2840 +++ b/arch/arm/kernel/process.c
2841 @@ -217,6 +217,7 @@ void machine_power_off(void)
2842
2843 if (pm_power_off)
2844 pm_power_off();
2845 + BUG();
2846 }
2847
2848 /*
2849 @@ -230,7 +231,7 @@ void machine_power_off(void)
2850 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2851 * to use. Implementing such co-ordination would be essentially impossible.
2852 */
2853 -void machine_restart(char *cmd)
2854 +__noreturn void machine_restart(char *cmd)
2855 {
2856 local_irq_disable();
2857 smp_send_stop();
2858 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2859
2860 show_regs_print_info(KERN_DEFAULT);
2861
2862 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2863 - print_symbol("LR is at %s\n", regs->ARM_lr);
2864 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2865 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2866 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2867 "sp : %08lx ip : %08lx fp : %08lx\n",
2868 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2869 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2870 return 0;
2871 }
2872
2873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2874 -{
2875 - unsigned long range_end = mm->brk + 0x02000000;
2876 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2877 -}
2878 -
2879 #ifdef CONFIG_MMU
2880 #ifdef CONFIG_KUSER_HELPERS
2881 /*
2882 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2883
2884 static int __init gate_vma_init(void)
2885 {
2886 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2887 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2888 return 0;
2889 }
2890 arch_initcall(gate_vma_init);
2891 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2892
2893 const char *arch_vma_name(struct vm_area_struct *vma)
2894 {
2895 - return is_gate_vma(vma) ? "[vectors]" :
2896 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2897 - "[sigpage]" : NULL;
2898 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2899 }
2900
2901 -static struct page *signal_page;
2902 -extern struct page *get_signal_page(void);
2903 -
2904 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2905 {
2906 struct mm_struct *mm = current->mm;
2907 - unsigned long addr;
2908 - int ret;
2909 -
2910 - if (!signal_page)
2911 - signal_page = get_signal_page();
2912 - if (!signal_page)
2913 - return -ENOMEM;
2914
2915 down_write(&mm->mmap_sem);
2916 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2917 - if (IS_ERR_VALUE(addr)) {
2918 - ret = addr;
2919 - goto up_fail;
2920 - }
2921 -
2922 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2923 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2924 - &signal_page);
2925 -
2926 - if (ret == 0)
2927 - mm->context.sigpage = addr;
2928 -
2929 - up_fail:
2930 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2931 up_write(&mm->mmap_sem);
2932 - return ret;
2933 + return 0;
2934 }
2935 #endif
2936 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2937 index 4693188..4596c5e 100644
2938 --- a/arch/arm/kernel/psci.c
2939 +++ b/arch/arm/kernel/psci.c
2940 @@ -24,7 +24,7 @@
2941 #include <asm/opcodes-virt.h>
2942 #include <asm/psci.h>
2943
2944 -struct psci_operations psci_ops;
2945 +struct psci_operations psci_ops __read_only;
2946
2947 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2948
2949 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2950 index 0dd3b79..e018f64 100644
2951 --- a/arch/arm/kernel/ptrace.c
2952 +++ b/arch/arm/kernel/ptrace.c
2953 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2954 return current_thread_info()->syscall;
2955 }
2956
2957 +#ifdef CONFIG_GRKERNSEC_SETXID
2958 +extern void gr_delayed_cred_worker(void);
2959 +#endif
2960 +
2961 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2962 {
2963 current_thread_info()->syscall = scno;
2964
2965 +#ifdef CONFIG_GRKERNSEC_SETXID
2966 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2967 + gr_delayed_cred_worker();
2968 +#endif
2969 +
2970 /* Do the secure computing check first; failures should be fast. */
2971 if (secure_computing(scno) == -1)
2972 return -1;
2973 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2974 index afc2489..6372bc8 100644
2975 --- a/arch/arm/kernel/setup.c
2976 +++ b/arch/arm/kernel/setup.c
2977 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2978 unsigned int elf_hwcap __read_mostly;
2979 EXPORT_SYMBOL(elf_hwcap);
2980
2981 +pteval_t __supported_pte_mask __read_only;
2982 +pmdval_t __supported_pmd_mask __read_only;
2983
2984 #ifdef MULTI_CPU
2985 -struct processor processor __read_mostly;
2986 +struct processor processor;
2987 #endif
2988 #ifdef MULTI_TLB
2989 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2990 +struct cpu_tlb_fns cpu_tlb __read_only;
2991 #endif
2992 #ifdef MULTI_USER
2993 -struct cpu_user_fns cpu_user __read_mostly;
2994 +struct cpu_user_fns cpu_user __read_only;
2995 #endif
2996 #ifdef MULTI_CACHE
2997 -struct cpu_cache_fns cpu_cache __read_mostly;
2998 +struct cpu_cache_fns cpu_cache __read_only;
2999 #endif
3000 #ifdef CONFIG_OUTER_CACHE
3001 -struct outer_cache_fns outer_cache __read_mostly;
3002 +struct outer_cache_fns outer_cache __read_only;
3003 EXPORT_SYMBOL(outer_cache);
3004 #endif
3005
3006 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
3007 asm("mrc p15, 0, %0, c0, c1, 4"
3008 : "=r" (mmfr0));
3009 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3010 - (mmfr0 & 0x000000f0) >= 0x00000030)
3011 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3012 cpu_arch = CPU_ARCH_ARMv7;
3013 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3014 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3015 + __supported_pte_mask |= L_PTE_PXN;
3016 + __supported_pmd_mask |= PMD_PXNTABLE;
3017 + }
3018 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3019 (mmfr0 & 0x000000f0) == 0x00000020)
3020 cpu_arch = CPU_ARCH_ARMv6;
3021 else
3022 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3023 __cpu_architecture = __get_cpu_architecture();
3024
3025 #ifdef MULTI_CPU
3026 - processor = *list->proc;
3027 + memcpy((void *)&processor, list->proc, sizeof processor);
3028 #endif
3029 #ifdef MULTI_TLB
3030 cpu_tlb = *list->tlb;
3031 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3032 index ab33042..11248a8 100644
3033 --- a/arch/arm/kernel/signal.c
3034 +++ b/arch/arm/kernel/signal.c
3035 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3036 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3037 };
3038
3039 -static unsigned long signal_return_offset;
3040 -
3041 #ifdef CONFIG_CRUNCH
3042 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3043 {
3044 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3045 * except when the MPU has protected the vectors
3046 * page from PL0
3047 */
3048 - retcode = mm->context.sigpage + signal_return_offset +
3049 - (idx << 2) + thumb;
3050 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3051 } else
3052 #endif
3053 {
3054 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3055 } while (thread_flags & _TIF_WORK_MASK);
3056 return 0;
3057 }
3058 -
3059 -struct page *get_signal_page(void)
3060 -{
3061 - unsigned long ptr;
3062 - unsigned offset;
3063 - struct page *page;
3064 - void *addr;
3065 -
3066 - page = alloc_pages(GFP_KERNEL, 0);
3067 -
3068 - if (!page)
3069 - return NULL;
3070 -
3071 - addr = page_address(page);
3072 -
3073 - /* Give the signal return code some randomness */
3074 - offset = 0x200 + (get_random_int() & 0x7fc);
3075 - signal_return_offset = offset;
3076 -
3077 - /*
3078 - * Copy signal return handlers into the vector page, and
3079 - * set sigreturn to be a pointer to these.
3080 - */
3081 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3082 -
3083 - ptr = (unsigned long)addr + offset;
3084 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3085 -
3086 - return page;
3087 -}
3088 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3089 index 2dc1934..ecf0e21 100644
3090 --- a/arch/arm/kernel/smp.c
3091 +++ b/arch/arm/kernel/smp.c
3092 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3093
3094 static DECLARE_COMPLETION(cpu_running);
3095
3096 -static struct smp_operations smp_ops;
3097 +static struct smp_operations smp_ops __read_only;
3098
3099 void __init smp_set_ops(struct smp_operations *ops)
3100 {
3101 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3102 index ab517fc..9adf2fa 100644
3103 --- a/arch/arm/kernel/traps.c
3104 +++ b/arch/arm/kernel/traps.c
3105 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3106 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3107 {
3108 #ifdef CONFIG_KALLSYMS
3109 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3110 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3111 #else
3112 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3113 #endif
3114 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3115 static int die_owner = -1;
3116 static unsigned int die_nest_count;
3117
3118 +extern void gr_handle_kernel_exploit(void);
3119 +
3120 static unsigned long oops_begin(void)
3121 {
3122 int cpu;
3123 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3124 panic("Fatal exception in interrupt");
3125 if (panic_on_oops)
3126 panic("Fatal exception");
3127 +
3128 + gr_handle_kernel_exploit();
3129 +
3130 if (signr)
3131 do_exit(signr);
3132 }
3133 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3134 * The user helper at 0xffff0fe0 must be used instead.
3135 * (see entry-armv.S for details)
3136 */
3137 + pax_open_kernel();
3138 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3139 + pax_close_kernel();
3140 }
3141 return 0;
3142
3143 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3144 kuser_init(vectors_base);
3145
3146 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3147 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3148 +
3149 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3150 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3151 +#endif
3152 +
3153 #else /* ifndef CONFIG_CPU_V7M */
3154 /*
3155 * on V7-M there is no need to copy the vector table to a dedicated
3156 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3157 index 7bcee5c..e2f3249 100644
3158 --- a/arch/arm/kernel/vmlinux.lds.S
3159 +++ b/arch/arm/kernel/vmlinux.lds.S
3160 @@ -8,7 +8,11 @@
3161 #include <asm/thread_info.h>
3162 #include <asm/memory.h>
3163 #include <asm/page.h>
3164 -
3165 +
3166 +#ifdef CONFIG_PAX_KERNEXEC
3167 +#include <asm/pgtable.h>
3168 +#endif
3169 +
3170 #define PROC_INFO \
3171 . = ALIGN(4); \
3172 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3173 @@ -34,7 +38,7 @@
3174 #endif
3175
3176 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3177 - defined(CONFIG_GENERIC_BUG)
3178 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3179 #define ARM_EXIT_KEEP(x) x
3180 #define ARM_EXIT_DISCARD(x)
3181 #else
3182 @@ -90,6 +94,11 @@ SECTIONS
3183 _text = .;
3184 HEAD_TEXT
3185 }
3186 +
3187 +#ifdef CONFIG_PAX_KERNEXEC
3188 + . = ALIGN(1<<SECTION_SHIFT);
3189 +#endif
3190 +
3191 .text : { /* Real text segment */
3192 _stext = .; /* Text and read-only data */
3193 __exception_text_start = .;
3194 @@ -112,6 +121,8 @@ SECTIONS
3195 ARM_CPU_KEEP(PROC_INFO)
3196 }
3197
3198 + _etext = .; /* End of text section */
3199 +
3200 RO_DATA(PAGE_SIZE)
3201
3202 . = ALIGN(4);
3203 @@ -142,7 +153,9 @@ SECTIONS
3204
3205 NOTES
3206
3207 - _etext = .; /* End of text and rodata section */
3208 +#ifdef CONFIG_PAX_KERNEXEC
3209 + . = ALIGN(1<<SECTION_SHIFT);
3210 +#endif
3211
3212 #ifndef CONFIG_XIP_KERNEL
3213 . = ALIGN(PAGE_SIZE);
3214 @@ -220,6 +233,11 @@ SECTIONS
3215 . = PAGE_OFFSET + TEXT_OFFSET;
3216 #else
3217 __init_end = .;
3218 +
3219 +#ifdef CONFIG_PAX_KERNEXEC
3220 + . = ALIGN(1<<SECTION_SHIFT);
3221 +#endif
3222 +
3223 . = ALIGN(THREAD_SIZE);
3224 __data_loc = .;
3225 #endif
3226 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3227 index 741f66a..8a5615c 100644
3228 --- a/arch/arm/kvm/arm.c
3229 +++ b/arch/arm/kvm/arm.c
3230 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3231 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3232
3233 /* The VMID used in the VTTBR */
3234 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3235 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3236 static u8 kvm_next_vmid;
3237 static DEFINE_SPINLOCK(kvm_vmid_lock);
3238
3239 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3240 */
3241 static bool need_new_vmid_gen(struct kvm *kvm)
3242 {
3243 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3244 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3245 }
3246
3247 /**
3248 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3249
3250 /* First user of a new VMID generation? */
3251 if (unlikely(kvm_next_vmid == 0)) {
3252 - atomic64_inc(&kvm_vmid_gen);
3253 + atomic64_inc_unchecked(&kvm_vmid_gen);
3254 kvm_next_vmid = 1;
3255
3256 /*
3257 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3258 kvm_call_hyp(__kvm_flush_vm_context);
3259 }
3260
3261 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3262 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3263 kvm->arch.vmid = kvm_next_vmid;
3264 kvm_next_vmid++;
3265
3266 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3267 index 14a0d98..7771a7d 100644
3268 --- a/arch/arm/lib/clear_user.S
3269 +++ b/arch/arm/lib/clear_user.S
3270 @@ -12,14 +12,14 @@
3271
3272 .text
3273
3274 -/* Prototype: int __clear_user(void *addr, size_t sz)
3275 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3276 * Purpose : clear some user memory
3277 * Params : addr - user memory address to clear
3278 * : sz - number of bytes to clear
3279 * Returns : number of bytes NOT cleared
3280 */
3281 ENTRY(__clear_user_std)
3282 -WEAK(__clear_user)
3283 +WEAK(___clear_user)
3284 stmfd sp!, {r1, lr}
3285 mov r2, #0
3286 cmp r1, #4
3287 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3288 USER( strnebt r2, [r0])
3289 mov r0, #0
3290 ldmfd sp!, {r1, pc}
3291 -ENDPROC(__clear_user)
3292 +ENDPROC(___clear_user)
3293 ENDPROC(__clear_user_std)
3294
3295 .pushsection .fixup,"ax"
3296 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3297 index 66a477a..bee61d3 100644
3298 --- a/arch/arm/lib/copy_from_user.S
3299 +++ b/arch/arm/lib/copy_from_user.S
3300 @@ -16,7 +16,7 @@
3301 /*
3302 * Prototype:
3303 *
3304 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3305 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3306 *
3307 * Purpose:
3308 *
3309 @@ -84,11 +84,11 @@
3310
3311 .text
3312
3313 -ENTRY(__copy_from_user)
3314 +ENTRY(___copy_from_user)
3315
3316 #include "copy_template.S"
3317
3318 -ENDPROC(__copy_from_user)
3319 +ENDPROC(___copy_from_user)
3320
3321 .pushsection .fixup,"ax"
3322 .align 0
3323 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3324 index 6ee2f67..d1cce76 100644
3325 --- a/arch/arm/lib/copy_page.S
3326 +++ b/arch/arm/lib/copy_page.S
3327 @@ -10,6 +10,7 @@
3328 * ASM optimised string functions
3329 */
3330 #include <linux/linkage.h>
3331 +#include <linux/const.h>
3332 #include <asm/assembler.h>
3333 #include <asm/asm-offsets.h>
3334 #include <asm/cache.h>
3335 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3336 index d066df6..df28194 100644
3337 --- a/arch/arm/lib/copy_to_user.S
3338 +++ b/arch/arm/lib/copy_to_user.S
3339 @@ -16,7 +16,7 @@
3340 /*
3341 * Prototype:
3342 *
3343 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3344 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3345 *
3346 * Purpose:
3347 *
3348 @@ -88,11 +88,11 @@
3349 .text
3350
3351 ENTRY(__copy_to_user_std)
3352 -WEAK(__copy_to_user)
3353 +WEAK(___copy_to_user)
3354
3355 #include "copy_template.S"
3356
3357 -ENDPROC(__copy_to_user)
3358 +ENDPROC(___copy_to_user)
3359 ENDPROC(__copy_to_user_std)
3360
3361 .pushsection .fixup,"ax"
3362 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3363 index 7d08b43..f7ca7ea 100644
3364 --- a/arch/arm/lib/csumpartialcopyuser.S
3365 +++ b/arch/arm/lib/csumpartialcopyuser.S
3366 @@ -57,8 +57,8 @@
3367 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3368 */
3369
3370 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3371 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3372 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3373 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3374
3375 #include "csumpartialcopygeneric.S"
3376
3377 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3378 index 5306de3..aed6d03 100644
3379 --- a/arch/arm/lib/delay.c
3380 +++ b/arch/arm/lib/delay.c
3381 @@ -28,7 +28,7 @@
3382 /*
3383 * Default to the loop-based delay implementation.
3384 */
3385 -struct arm_delay_ops arm_delay_ops = {
3386 +struct arm_delay_ops arm_delay_ops __read_only = {
3387 .delay = __loop_delay,
3388 .const_udelay = __loop_const_udelay,
3389 .udelay = __loop_udelay,
3390 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3391 index 025f742..a9e5b3b 100644
3392 --- a/arch/arm/lib/uaccess_with_memcpy.c
3393 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3394 @@ -104,7 +104,7 @@ out:
3395 }
3396
3397 unsigned long
3398 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3399 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3400 {
3401 /*
3402 * This test is stubbed out of the main function above to keep
3403 @@ -155,7 +155,7 @@ out:
3404 return n;
3405 }
3406
3407 -unsigned long __clear_user(void __user *addr, unsigned long n)
3408 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3409 {
3410 /* See rational for this in __copy_to_user() above. */
3411 if (n < 64)
3412 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3413 index e9238b5..6ed904a 100644
3414 --- a/arch/arm/mach-kirkwood/common.c
3415 +++ b/arch/arm/mach-kirkwood/common.c
3416 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3417 clk_gate_ops.disable(hw);
3418 }
3419
3420 -static struct clk_ops clk_gate_fn_ops;
3421 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3422 +{
3423 + return clk_gate_ops.is_enabled(hw);
3424 +}
3425 +
3426 +static struct clk_ops clk_gate_fn_ops = {
3427 + .enable = clk_gate_fn_enable,
3428 + .disable = clk_gate_fn_disable,
3429 + .is_enabled = clk_gate_fn_is_enabled,
3430 +};
3431
3432 static struct clk __init *clk_register_gate_fn(struct device *dev,
3433 const char *name,
3434 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3435 gate_fn->fn_en = fn_en;
3436 gate_fn->fn_dis = fn_dis;
3437
3438 - /* ops is the gate ops, but with our enable/disable functions */
3439 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3440 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3441 - clk_gate_fn_ops = clk_gate_ops;
3442 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3443 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3444 - }
3445 -
3446 clk = clk_register(dev, &gate_fn->gate.hw);
3447
3448 if (IS_ERR(clk))
3449 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3450 index 827d1500..2885dc6 100644
3451 --- a/arch/arm/mach-omap2/board-n8x0.c
3452 +++ b/arch/arm/mach-omap2/board-n8x0.c
3453 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3454 }
3455 #endif
3456
3457 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3458 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3459 .late_init = n8x0_menelaus_late_init,
3460 };
3461
3462 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3463 index f3fdd6a..3564800 100644
3464 --- a/arch/arm/mach-omap2/gpmc.c
3465 +++ b/arch/arm/mach-omap2/gpmc.c
3466 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3467 };
3468
3469 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3470 -static struct irq_chip gpmc_irq_chip;
3471 static unsigned gpmc_irq_start;
3472
3473 static struct resource gpmc_mem_root;
3474 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3475
3476 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3477
3478 +static struct irq_chip gpmc_irq_chip = {
3479 + .name = "gpmc",
3480 + .irq_startup = gpmc_irq_noop_ret,
3481 + .irq_enable = gpmc_irq_enable,
3482 + .irq_disable = gpmc_irq_disable,
3483 + .irq_shutdown = gpmc_irq_noop,
3484 + .irq_ack = gpmc_irq_noop,
3485 + .irq_mask = gpmc_irq_noop,
3486 + .irq_unmask = gpmc_irq_noop,
3487 +
3488 +};
3489 +
3490 static int gpmc_setup_irq(void)
3491 {
3492 int i;
3493 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3494 return gpmc_irq_start;
3495 }
3496
3497 - gpmc_irq_chip.name = "gpmc";
3498 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3499 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3500 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3501 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3502 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3503 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3504 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3505 -
3506 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3507 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3508
3509 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3510 index f991016..145ebeb 100644
3511 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3512 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3513 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3514 int (*finish_suspend)(unsigned long cpu_state);
3515 void (*resume)(void);
3516 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3517 -};
3518 +} __no_const;
3519
3520 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3521 static struct powerdomain *mpuss_pd;
3522 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3523 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3524 {}
3525
3526 -struct cpu_pm_ops omap_pm_ops = {
3527 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3528 .finish_suspend = default_finish_suspend,
3529 .resume = dummy_cpu_resume,
3530 .scu_prepare = dummy_scu_prepare,
3531 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3532 index 813c615..ce467c6 100644
3533 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3534 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3535 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3536 return NOTIFY_OK;
3537 }
3538
3539 -static struct notifier_block __refdata irq_hotplug_notifier = {
3540 +static struct notifier_block irq_hotplug_notifier = {
3541 .notifier_call = irq_cpu_hotplug_notify,
3542 };
3543
3544 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3545 index f99f68e..e573e20 100644
3546 --- a/arch/arm/mach-omap2/omap_device.c
3547 +++ b/arch/arm/mach-omap2/omap_device.c
3548 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3549 struct platform_device __init *omap_device_build(const char *pdev_name,
3550 int pdev_id,
3551 struct omap_hwmod *oh,
3552 - void *pdata, int pdata_len)
3553 + const void *pdata, int pdata_len)
3554 {
3555 struct omap_hwmod *ohs[] = { oh };
3556
3557 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3558 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3559 int pdev_id,
3560 struct omap_hwmod **ohs,
3561 - int oh_cnt, void *pdata,
3562 + int oh_cnt, const void *pdata,
3563 int pdata_len)
3564 {
3565 int ret = -ENOMEM;
3566 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3567 index 17ca1ae..beba869 100644
3568 --- a/arch/arm/mach-omap2/omap_device.h
3569 +++ b/arch/arm/mach-omap2/omap_device.h
3570 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3571 /* Core code interface */
3572
3573 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3574 - struct omap_hwmod *oh, void *pdata,
3575 + struct omap_hwmod *oh, const void *pdata,
3576 int pdata_len);
3577
3578 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3579 struct omap_hwmod **oh, int oh_cnt,
3580 - void *pdata, int pdata_len);
3581 + const void *pdata, int pdata_len);
3582
3583 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3584 struct omap_hwmod **ohs, int oh_cnt);
3585 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3586 index 7f4db12..0243012 100644
3587 --- a/arch/arm/mach-omap2/omap_hwmod.c
3588 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3589 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3590 int (*init_clkdm)(struct omap_hwmod *oh);
3591 void (*update_context_lost)(struct omap_hwmod *oh);
3592 int (*get_context_lost)(struct omap_hwmod *oh);
3593 -};
3594 +} __no_const;
3595
3596 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3597 -static struct omap_hwmod_soc_ops soc_ops;
3598 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3599
3600 /* omap_hwmod_list contains all registered struct omap_hwmods */
3601 static LIST_HEAD(omap_hwmod_list);
3602 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3603 index d15c7bb..b2d1f0c 100644
3604 --- a/arch/arm/mach-omap2/wd_timer.c
3605 +++ b/arch/arm/mach-omap2/wd_timer.c
3606 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3607 struct omap_hwmod *oh;
3608 char *oh_name = "wd_timer2";
3609 char *dev_name = "omap_wdt";
3610 - struct omap_wd_timer_platform_data pdata;
3611 + static struct omap_wd_timer_platform_data pdata = {
3612 + .read_reset_sources = prm_read_reset_sources
3613 + };
3614
3615 if (!cpu_class_is_omap2() || of_have_populated_dt())
3616 return 0;
3617 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3618 return -EINVAL;
3619 }
3620
3621 - pdata.read_reset_sources = prm_read_reset_sources;
3622 -
3623 pdev = omap_device_build(dev_name, id, oh, &pdata,
3624 sizeof(struct omap_wd_timer_platform_data));
3625 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3626 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3627 index 706aa42..f85e9131 100644
3628 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3629 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3630 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3631 bool entered_lp2 = false;
3632
3633 if (tegra_pending_sgi())
3634 - ACCESS_ONCE(abort_flag) = true;
3635 + ACCESS_ONCE_RW(abort_flag) = true;
3636
3637 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3638
3639 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3640 index cad3ca86..1d79e0f 100644
3641 --- a/arch/arm/mach-ux500/setup.h
3642 +++ b/arch/arm/mach-ux500/setup.h
3643 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3644 .type = MT_DEVICE, \
3645 }
3646
3647 -#define __MEM_DEV_DESC(x, sz) { \
3648 - .virtual = IO_ADDRESS(x), \
3649 - .pfn = __phys_to_pfn(x), \
3650 - .length = sz, \
3651 - .type = MT_MEMORY, \
3652 -}
3653 -
3654 extern struct smp_operations ux500_smp_ops;
3655 extern void ux500_cpu_die(unsigned int cpu);
3656
3657 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3658 index cd2c88e..7430282 100644
3659 --- a/arch/arm/mm/Kconfig
3660 +++ b/arch/arm/mm/Kconfig
3661 @@ -446,7 +446,7 @@ config CPU_32v5
3662
3663 config CPU_32v6
3664 bool
3665 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3666 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3667 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3668
3669 config CPU_32v6K
3670 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3671
3672 config CPU_USE_DOMAINS
3673 bool
3674 + depends on !ARM_LPAE && !PAX_KERNEXEC
3675 help
3676 This option enables or disables the use of domain switching
3677 via the set_fs() function.
3678 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3679 config KUSER_HELPERS
3680 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3681 default y
3682 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3683 help
3684 Warning: disabling this option may break user programs.
3685
3686 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3687 See Documentation/arm/kernel_user_helpers.txt for details.
3688
3689 However, the fixed address nature of these helpers can be used
3690 - by ROP (return orientated programming) authors when creating
3691 + by ROP (Return Oriented Programming) authors when creating
3692 exploits.
3693
3694 If all of the binaries and libraries which run on your platform
3695 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3696 index 6f4585b..7b6f52b 100644
3697 --- a/arch/arm/mm/alignment.c
3698 +++ b/arch/arm/mm/alignment.c
3699 @@ -211,10 +211,12 @@ union offset_union {
3700 #define __get16_unaligned_check(ins,val,addr) \
3701 do { \
3702 unsigned int err = 0, v, a = addr; \
3703 + pax_open_userland(); \
3704 __get8_unaligned_check(ins,v,a,err); \
3705 val = v << ((BE) ? 8 : 0); \
3706 __get8_unaligned_check(ins,v,a,err); \
3707 val |= v << ((BE) ? 0 : 8); \
3708 + pax_close_userland(); \
3709 if (err) \
3710 goto fault; \
3711 } while (0)
3712 @@ -228,6 +230,7 @@ union offset_union {
3713 #define __get32_unaligned_check(ins,val,addr) \
3714 do { \
3715 unsigned int err = 0, v, a = addr; \
3716 + pax_open_userland(); \
3717 __get8_unaligned_check(ins,v,a,err); \
3718 val = v << ((BE) ? 24 : 0); \
3719 __get8_unaligned_check(ins,v,a,err); \
3720 @@ -236,6 +239,7 @@ union offset_union {
3721 val |= v << ((BE) ? 8 : 16); \
3722 __get8_unaligned_check(ins,v,a,err); \
3723 val |= v << ((BE) ? 0 : 24); \
3724 + pax_close_userland(); \
3725 if (err) \
3726 goto fault; \
3727 } while (0)
3728 @@ -249,6 +253,7 @@ union offset_union {
3729 #define __put16_unaligned_check(ins,val,addr) \
3730 do { \
3731 unsigned int err = 0, v = val, a = addr; \
3732 + pax_open_userland(); \
3733 __asm__( FIRST_BYTE_16 \
3734 ARM( "1: "ins" %1, [%2], #1\n" ) \
3735 THUMB( "1: "ins" %1, [%2]\n" ) \
3736 @@ -268,6 +273,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 @@ -281,6 +287,7 @@ union offset_union {
3745 #define __put32_unaligned_check(ins,val,addr) \
3746 do { \
3747 unsigned int err = 0, v = val, a = addr; \
3748 + pax_open_userland(); \
3749 __asm__( FIRST_BYTE_32 \
3750 ARM( "1: "ins" %1, [%2], #1\n" ) \
3751 THUMB( "1: "ins" %1, [%2]\n" ) \
3752 @@ -310,6 +317,7 @@ union offset_union {
3753 " .popsection\n" \
3754 : "=r" (err), "=&r" (v), "=&r" (a) \
3755 : "0" (err), "1" (v), "2" (a)); \
3756 + pax_close_userland(); \
3757 if (err) \
3758 goto fault; \
3759 } while (0)
3760 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3761 index 4a05444..d21968c 100644
3762 --- a/arch/arm/mm/context.c
3763 +++ b/arch/arm/mm/context.c
3764 @@ -43,7 +43,7 @@
3765 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3766
3767 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3768 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3769 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3770 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3771
3772 static DEFINE_PER_CPU(atomic64_t, active_asids);
3773 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3774 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3775 {
3776 u64 asid = atomic64_read(&mm->context.id);
3777 - u64 generation = atomic64_read(&asid_generation);
3778 + u64 generation = atomic64_read_unchecked(&asid_generation);
3779
3780 if (asid != 0 && is_reserved_asid(asid)) {
3781 /*
3782 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3783 */
3784 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3785 if (asid == NUM_USER_ASIDS) {
3786 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3787 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3788 &asid_generation);
3789 flush_context(cpu);
3790 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3791 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3792 cpu_set_reserved_ttbr0();
3793
3794 asid = atomic64_read(&mm->context.id);
3795 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3796 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3797 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3798 goto switch_mm_fastpath;
3799
3800 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3801 /* Check that our ASID belongs to the current generation. */
3802 asid = atomic64_read(&mm->context.id);
3803 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3804 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3805 asid = new_context(mm, cpu);
3806 atomic64_set(&mm->context.id, asid);
3807 }
3808 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3809 index c97f794..6461880 100644
3810 --- a/arch/arm/mm/fault.c
3811 +++ b/arch/arm/mm/fault.c
3812 @@ -25,6 +25,7 @@
3813 #include <asm/system_misc.h>
3814 #include <asm/system_info.h>
3815 #include <asm/tlbflush.h>
3816 +#include <asm/sections.h>
3817
3818 #include "fault.h"
3819
3820 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3821 if (fixup_exception(regs))
3822 return;
3823
3824 +#ifdef CONFIG_PAX_KERNEXEC
3825 + if ((fsr & FSR_WRITE) &&
3826 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3827 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3828 + {
3829 + if (current->signal->curr_ip)
3830 + 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),
3831 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3832 + else
3833 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3834 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3835 + }
3836 +#endif
3837 +
3838 /*
3839 * No handler, we'll have to terminate things with extreme prejudice.
3840 */
3841 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3842 }
3843 #endif
3844
3845 +#ifdef CONFIG_PAX_PAGEEXEC
3846 + if (fsr & FSR_LNX_PF) {
3847 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3848 + do_group_exit(SIGKILL);
3849 + }
3850 +#endif
3851 +
3852 tsk->thread.address = addr;
3853 tsk->thread.error_code = fsr;
3854 tsk->thread.trap_no = 14;
3855 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3856 }
3857 #endif /* CONFIG_MMU */
3858
3859 +#ifdef CONFIG_PAX_PAGEEXEC
3860 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3861 +{
3862 + long i;
3863 +
3864 + printk(KERN_ERR "PAX: bytes at PC: ");
3865 + for (i = 0; i < 20; i++) {
3866 + unsigned char c;
3867 + if (get_user(c, (__force unsigned char __user *)pc+i))
3868 + printk(KERN_CONT "?? ");
3869 + else
3870 + printk(KERN_CONT "%02x ", c);
3871 + }
3872 + printk("\n");
3873 +
3874 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3875 + for (i = -1; i < 20; i++) {
3876 + unsigned long c;
3877 + if (get_user(c, (__force unsigned long __user *)sp+i))
3878 + printk(KERN_CONT "???????? ");
3879 + else
3880 + printk(KERN_CONT "%08lx ", c);
3881 + }
3882 + printk("\n");
3883 +}
3884 +#endif
3885 +
3886 /*
3887 * First Level Translation Fault Handler
3888 *
3889 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3890 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3891 struct siginfo info;
3892
3893 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3894 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3895 + if (current->signal->curr_ip)
3896 + 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),
3897 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3898 + else
3899 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3900 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3901 + goto die;
3902 + }
3903 +#endif
3904 +
3905 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3906 return;
3907
3908 +die:
3909 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3910 inf->name, fsr, addr);
3911
3912 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3913 ifsr_info[nr].name = name;
3914 }
3915
3916 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3917 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3918 +
3919 asmlinkage void __exception
3920 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3921 {
3922 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3923 struct siginfo info;
3924 + unsigned long pc = instruction_pointer(regs);
3925 +
3926 + if (user_mode(regs)) {
3927 + unsigned long sigpage = current->mm->context.sigpage;
3928 +
3929 + if (sigpage <= pc && pc < sigpage + 7*4) {
3930 + if (pc < sigpage + 3*4)
3931 + sys_sigreturn(regs);
3932 + else
3933 + sys_rt_sigreturn(regs);
3934 + return;
3935 + }
3936 + if (pc == 0xffff0f60UL) {
3937 + /*
3938 + * PaX: __kuser_cmpxchg64 emulation
3939 + */
3940 + // TODO
3941 + //regs->ARM_pc = regs->ARM_lr;
3942 + //return;
3943 + }
3944 + if (pc == 0xffff0fa0UL) {
3945 + /*
3946 + * PaX: __kuser_memory_barrier emulation
3947 + */
3948 + // dmb(); implied by the exception
3949 + regs->ARM_pc = regs->ARM_lr;
3950 + return;
3951 + }
3952 + if (pc == 0xffff0fc0UL) {
3953 + /*
3954 + * PaX: __kuser_cmpxchg emulation
3955 + */
3956 + // TODO
3957 + //regs->ARM_pc = regs->ARM_lr;
3958 + //return;
3959 + }
3960 + if (pc == 0xffff0fe0UL) {
3961 + /*
3962 + * PaX: __kuser_get_tls emulation
3963 + */
3964 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3965 + regs->ARM_pc = regs->ARM_lr;
3966 + return;
3967 + }
3968 + }
3969 +
3970 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3971 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3972 + if (current->signal->curr_ip)
3973 + 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),
3974 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3975 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3976 + else
3977 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3978 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3979 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3980 + goto die;
3981 + }
3982 +#endif
3983 +
3984 +#ifdef CONFIG_PAX_REFCOUNT
3985 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3986 + unsigned int bkpt;
3987 +
3988 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3989 + current->thread.error_code = ifsr;
3990 + current->thread.trap_no = 0;
3991 + pax_report_refcount_overflow(regs);
3992 + fixup_exception(regs);
3993 + return;
3994 + }
3995 + }
3996 +#endif
3997
3998 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3999 return;
4000
4001 +die:
4002 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4003 inf->name, ifsr, addr);
4004
4005 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4006 index cf08bdf..772656c 100644
4007 --- a/arch/arm/mm/fault.h
4008 +++ b/arch/arm/mm/fault.h
4009 @@ -3,6 +3,7 @@
4010
4011 /*
4012 * Fault status register encodings. We steal bit 31 for our own purposes.
4013 + * Set when the FSR value is from an instruction fault.
4014 */
4015 #define FSR_LNX_PF (1 << 31)
4016 #define FSR_WRITE (1 << 11)
4017 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4018 }
4019 #endif
4020
4021 +/* valid for LPAE and !LPAE */
4022 +static inline int is_xn_fault(unsigned int fsr)
4023 +{
4024 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4025 +}
4026 +
4027 +static inline int is_domain_fault(unsigned int fsr)
4028 +{
4029 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4030 +}
4031 +
4032 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4033 unsigned long search_exception_table(unsigned long addr);
4034
4035 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4036 index 15225d8..25e2e3c 100644
4037 --- a/arch/arm/mm/init.c
4038 +++ b/arch/arm/mm/init.c
4039 @@ -30,6 +30,8 @@
4040 #include <asm/setup.h>
4041 #include <asm/tlb.h>
4042 #include <asm/fixmap.h>
4043 +#include <asm/system_info.h>
4044 +#include <asm/cp15.h>
4045
4046 #include <asm/mach/arch.h>
4047 #include <asm/mach/map.h>
4048 @@ -683,7 +685,46 @@ void free_initmem(void)
4049 {
4050 #ifdef CONFIG_HAVE_TCM
4051 extern char __tcm_start, __tcm_end;
4052 +#endif
4053
4054 +#ifdef CONFIG_PAX_KERNEXEC
4055 + unsigned long addr;
4056 + pgd_t *pgd;
4057 + pud_t *pud;
4058 + pmd_t *pmd;
4059 + int cpu_arch = cpu_architecture();
4060 + unsigned int cr = get_cr();
4061 +
4062 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4063 + /* make pages tables, etc before .text NX */
4064 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make init NX */
4071 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 + __section_update(pmd, addr, PMD_SECT_XN);
4076 + }
4077 + /* make kernel code/rodata RX */
4078 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4079 + pgd = pgd_offset_k(addr);
4080 + pud = pud_offset(pgd, addr);
4081 + pmd = pmd_offset(pud, addr);
4082 +#ifdef CONFIG_ARM_LPAE
4083 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4084 +#else
4085 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4086 +#endif
4087 + }
4088 + }
4089 +#endif
4090 +
4091 +#ifdef CONFIG_HAVE_TCM
4092 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4093 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4094 #endif
4095 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4096 index f123d6e..04bf569 100644
4097 --- a/arch/arm/mm/ioremap.c
4098 +++ b/arch/arm/mm/ioremap.c
4099 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4100 unsigned int mtype;
4101
4102 if (cached)
4103 - mtype = MT_MEMORY;
4104 + mtype = MT_MEMORY_RX;
4105 else
4106 - mtype = MT_MEMORY_NONCACHED;
4107 + mtype = MT_MEMORY_NONCACHED_RX;
4108
4109 return __arm_ioremap_caller(phys_addr, size, mtype,
4110 __builtin_return_address(0));
4111 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4112 index 0c63562..7128a90 100644
4113 --- a/arch/arm/mm/mmap.c
4114 +++ b/arch/arm/mm/mmap.c
4115 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4116 struct vm_area_struct *vma;
4117 int do_align = 0;
4118 int aliasing = cache_is_vipt_aliasing();
4119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4120 struct vm_unmapped_area_info info;
4121
4122 /*
4123 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4124 if (len > TASK_SIZE)
4125 return -ENOMEM;
4126
4127 +#ifdef CONFIG_PAX_RANDMMAP
4128 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4129 +#endif
4130 +
4131 if (addr) {
4132 if (do_align)
4133 addr = COLOUR_ALIGN(addr, pgoff);
4134 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4135 addr = PAGE_ALIGN(addr);
4136
4137 vma = find_vma(mm, addr);
4138 - if (TASK_SIZE - len >= addr &&
4139 - (!vma || addr + len <= vma->vm_start))
4140 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4141 return addr;
4142 }
4143
4144 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4145 info.high_limit = TASK_SIZE;
4146 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4147 info.align_offset = pgoff << PAGE_SHIFT;
4148 + info.threadstack_offset = offset;
4149 return vm_unmapped_area(&info);
4150 }
4151
4152 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4153 unsigned long addr = addr0;
4154 int do_align = 0;
4155 int aliasing = cache_is_vipt_aliasing();
4156 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4157 struct vm_unmapped_area_info info;
4158
4159 /*
4160 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4161 return addr;
4162 }
4163
4164 +#ifdef CONFIG_PAX_RANDMMAP
4165 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4166 +#endif
4167 +
4168 /* requesting a specific address */
4169 if (addr) {
4170 if (do_align)
4171 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4172 else
4173 addr = PAGE_ALIGN(addr);
4174 vma = find_vma(mm, addr);
4175 - if (TASK_SIZE - len >= addr &&
4176 - (!vma || addr + len <= vma->vm_start))
4177 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4178 return addr;
4179 }
4180
4181 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4182 info.high_limit = mm->mmap_base;
4183 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4184 info.align_offset = pgoff << PAGE_SHIFT;
4185 + info.threadstack_offset = offset;
4186 addr = vm_unmapped_area(&info);
4187
4188 /*
4189 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 } else {
4212 mm->mmap_base = mmap_base(random_factor);
4213 +
4214 +#ifdef CONFIG_PAX_RANDMMAP
4215 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4216 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4217 +#endif
4218 +
4219 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4220 }
4221 }
4222 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4223 index 53cdbd3..670f177 100644
4224 --- a/arch/arm/mm/mmu.c
4225 +++ b/arch/arm/mm/mmu.c
4226 @@ -36,6 +36,22 @@
4227 #include "mm.h"
4228 #include "tcm.h"
4229
4230 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4231 +void modify_domain(unsigned int dom, unsigned int type)
4232 +{
4233 + struct thread_info *thread = current_thread_info();
4234 + unsigned int domain = thread->cpu_domain;
4235 + /*
4236 + * DOMAIN_MANAGER might be defined to some other value,
4237 + * use the arch-defined constant
4238 + */
4239 + domain &= ~domain_val(dom, 3);
4240 + thread->cpu_domain = domain | domain_val(dom, type);
4241 + set_domain(thread->cpu_domain);
4242 +}
4243 +EXPORT_SYMBOL(modify_domain);
4244 +#endif
4245 +
4246 /*
4247 * empty_zero_page is a special page that is used for
4248 * zero-initialized data and COW.
4249 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4250
4251 #endif /* ifdef CONFIG_CPU_CP15 / else */
4252
4253 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4254 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4255 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4256
4257 -static struct mem_type mem_types[] = {
4258 +#ifdef CONFIG_PAX_KERNEXEC
4259 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4260 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4261 +#else
4262 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4263 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4264 +#endif
4265 +
4266 +static struct mem_type mem_types[] __read_only = {
4267 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4268 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4269 L_PTE_SHARED,
4270 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4271 [MT_UNCACHED] = {
4272 .prot_pte = PROT_PTE_DEVICE,
4273 .prot_l1 = PMD_TYPE_TABLE,
4274 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4275 + .prot_sect = PROT_SECT_DEVICE,
4276 .domain = DOMAIN_IO,
4277 },
4278 [MT_CACHECLEAN] = {
4279 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4280 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4281 .domain = DOMAIN_KERNEL,
4282 },
4283 #ifndef CONFIG_ARM_LPAE
4284 [MT_MINICLEAN] = {
4285 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4286 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4287 .domain = DOMAIN_KERNEL,
4288 },
4289 #endif
4290 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_RDONLY,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 - .domain = DOMAIN_USER,
4295 + .domain = DOMAIN_VECTORS,
4296 },
4297 [MT_HIGH_VECTORS] = {
4298 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4299 L_PTE_USER | L_PTE_RDONLY,
4300 .prot_l1 = PMD_TYPE_TABLE,
4301 - .domain = DOMAIN_USER,
4302 + .domain = DOMAIN_VECTORS,
4303 },
4304 - [MT_MEMORY] = {
4305 + [MT_MEMORY_RWX] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4307 .prot_l1 = PMD_TYPE_TABLE,
4308 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4309 .domain = DOMAIN_KERNEL,
4310 },
4311 + [MT_MEMORY_RW] = {
4312 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4313 + .prot_l1 = PMD_TYPE_TABLE,
4314 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4315 + .domain = DOMAIN_KERNEL,
4316 + },
4317 + [MT_MEMORY_RX] = {
4318 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4319 + .prot_l1 = PMD_TYPE_TABLE,
4320 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4321 + .domain = DOMAIN_KERNEL,
4322 + },
4323 [MT_ROM] = {
4324 - .prot_sect = PMD_TYPE_SECT,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 - [MT_MEMORY_NONCACHED] = {
4329 + [MT_MEMORY_NONCACHED_RW] = {
4330 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4331 L_PTE_MT_BUFFERABLE,
4332 .prot_l1 = PMD_TYPE_TABLE,
4333 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4334 .domain = DOMAIN_KERNEL,
4335 },
4336 + [MT_MEMORY_NONCACHED_RX] = {
4337 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4338 + L_PTE_MT_BUFFERABLE,
4339 + .prot_l1 = PMD_TYPE_TABLE,
4340 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4341 + .domain = DOMAIN_KERNEL,
4342 + },
4343 [MT_MEMORY_DTCM] = {
4344 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4345 - L_PTE_XN,
4346 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4347 .prot_l1 = PMD_TYPE_TABLE,
4348 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4349 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4350 .domain = DOMAIN_KERNEL,
4351 },
4352 [MT_MEMORY_ITCM] = {
4353 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4354 },
4355 [MT_MEMORY_SO] = {
4356 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4357 - L_PTE_MT_UNCACHED | L_PTE_XN,
4358 + L_PTE_MT_UNCACHED,
4359 .prot_l1 = PMD_TYPE_TABLE,
4360 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4361 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4362 + PMD_SECT_UNCACHED,
4363 .domain = DOMAIN_KERNEL,
4364 },
4365 [MT_MEMORY_DMA_READY] = {
4366 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4367 * to prevent speculative instruction fetches.
4368 */
4369 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4371 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4372 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4373 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4375 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4376 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4377 +
4378 + /* Mark other regions on ARMv6+ as execute-never */
4379 +
4380 +#ifdef CONFIG_PAX_KERNEXEC
4381 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4382 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4383 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4385 +#ifndef CONFIG_ARM_LPAE
4386 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4388 +#endif
4389 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4391 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4392 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4394 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4395 +#endif
4396 +
4397 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4399 }
4400 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4401 /*
4402 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4403 * from SVC mode and no access from userspace.
4404 */
4405 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4406 +#ifdef CONFIG_PAX_KERNEXEC
4407 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4408 +#endif
4409 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4410 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 #endif
4412 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4413 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4414 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4415 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4416 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4417 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4418 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4419 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4420 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4421 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4422 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4423 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4424 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4425 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4426 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4427 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4428 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4429 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4431 }
4432 }
4433
4434 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4435 if (cpu_arch >= CPU_ARCH_ARMv6) {
4436 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4437 /* Non-cacheable Normal is XCB = 001 */
4438 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4440 + PMD_SECT_BUFFERED;
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4442 PMD_SECT_BUFFERED;
4443 } else {
4444 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4445 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4446 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4447 + PMD_SECT_TEX(1);
4448 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4449 PMD_SECT_TEX(1);
4450 }
4451 } else {
4452 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4453 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4454 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4455 }
4456
4457 #ifdef CONFIG_ARM_LPAE
4458 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4459 vecs_pgprot |= PTE_EXT_AF;
4460 #endif
4461
4462 + user_pgprot |= __supported_pte_mask;
4463 +
4464 for (i = 0; i < 16; i++) {
4465 pteval_t v = pgprot_val(protection_map[i]);
4466 protection_map[i] = __pgprot(v | user_pgprot);
4467 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4468
4469 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4470 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4471 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4472 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4473 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4474 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4475 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4476 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4477 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4478 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4479 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4480 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4481 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4482 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4483 mem_types[MT_ROM].prot_sect |= cp->pmd;
4484
4485 switch (cp->pmd) {
4486 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4487 * called function. This means you can't use any function or debugging
4488 * method which may touch any device, otherwise the kernel _will_ crash.
4489 */
4490 +
4491 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4492 +
4493 static void __init devicemaps_init(struct machine_desc *mdesc)
4494 {
4495 struct map_desc map;
4496 unsigned long addr;
4497 - void *vectors;
4498
4499 - /*
4500 - * Allocate the vector page early.
4501 - */
4502 - vectors = early_alloc(PAGE_SIZE * 2);
4503 -
4504 - early_trap_init(vectors);
4505 + early_trap_init(&vectors);
4506
4507 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4508 pmd_clear(pmd_off_k(addr));
4509 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4510 * location (0xffff0000). If we aren't using high-vectors, also
4511 * create a mapping at the low-vectors virtual address.
4512 */
4513 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4514 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4515 map.virtual = 0xffff0000;
4516 map.length = PAGE_SIZE;
4517 #ifdef CONFIG_KUSER_HELPERS
4518 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4519 map.pfn = __phys_to_pfn(start);
4520 map.virtual = __phys_to_virt(start);
4521 map.length = end - start;
4522 - map.type = MT_MEMORY;
4523
4524 +#ifdef CONFIG_PAX_KERNEXEC
4525 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4526 + struct map_desc kernel;
4527 + struct map_desc initmap;
4528 +
4529 + /* when freeing initmem we will make this RW */
4530 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4531 + initmap.virtual = (unsigned long)__init_begin;
4532 + initmap.length = _sdata - __init_begin;
4533 + initmap.type = MT_MEMORY_RWX;
4534 + create_mapping(&initmap);
4535 +
4536 + /* when freeing initmem we will make this RX */
4537 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4538 + kernel.virtual = (unsigned long)_stext;
4539 + kernel.length = __init_begin - _stext;
4540 + kernel.type = MT_MEMORY_RWX;
4541 + create_mapping(&kernel);
4542 +
4543 + if (map.virtual < (unsigned long)_stext) {
4544 + map.length = (unsigned long)_stext - map.virtual;
4545 + map.type = MT_MEMORY_RWX;
4546 + create_mapping(&map);
4547 + }
4548 +
4549 + map.pfn = __phys_to_pfn(__pa(_sdata));
4550 + map.virtual = (unsigned long)_sdata;
4551 + map.length = end - __pa(_sdata);
4552 + }
4553 +#endif
4554 +
4555 + map.type = MT_MEMORY_RW;
4556 create_mapping(&map);
4557 }
4558 }
4559 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4560 index a5bc92d..0bb4730 100644
4561 --- a/arch/arm/plat-omap/sram.c
4562 +++ b/arch/arm/plat-omap/sram.c
4563 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4564 * Looks like we need to preserve some bootloader code at the
4565 * beginning of SRAM for jumping to flash for reboot to work...
4566 */
4567 + pax_open_kernel();
4568 memset_io(omap_sram_base + omap_sram_skip, 0,
4569 omap_sram_size - omap_sram_skip);
4570 + pax_close_kernel();
4571 }
4572 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4573 index ce6d763..cfea917 100644
4574 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4575 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4576 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4577 int (*started)(unsigned ch);
4578 int (*flush)(unsigned ch);
4579 int (*stop)(unsigned ch);
4580 -};
4581 +} __no_const;
4582
4583 extern void *samsung_dmadev_get_ops(void);
4584 extern void *s3c_dma_get_ops(void);
4585 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4586 index c3a58a1..78fbf54 100644
4587 --- a/arch/avr32/include/asm/cache.h
4588 +++ b/arch/avr32/include/asm/cache.h
4589 @@ -1,8 +1,10 @@
4590 #ifndef __ASM_AVR32_CACHE_H
4591 #define __ASM_AVR32_CACHE_H
4592
4593 +#include <linux/const.h>
4594 +
4595 #define L1_CACHE_SHIFT 5
4596 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4597 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4598
4599 /*
4600 * Memory returned by kmalloc() may be used for DMA, so we must make
4601 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4602 index d232888..87c8df1 100644
4603 --- a/arch/avr32/include/asm/elf.h
4604 +++ b/arch/avr32/include/asm/elf.h
4605 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4606 the loader. We need to make sure that it is out of the way of the program
4607 that it will "exec", and that there is sufficient room for the brk. */
4608
4609 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4610 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4611
4612 +#ifdef CONFIG_PAX_ASLR
4613 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4614 +
4615 +#define PAX_DELTA_MMAP_LEN 15
4616 +#define PAX_DELTA_STACK_LEN 15
4617 +#endif
4618
4619 /* This yields a mask that user programs can use to figure out what
4620 instruction set this CPU supports. This could be done in user space,
4621 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4622 index 479330b..53717a8 100644
4623 --- a/arch/avr32/include/asm/kmap_types.h
4624 +++ b/arch/avr32/include/asm/kmap_types.h
4625 @@ -2,9 +2,9 @@
4626 #define __ASM_AVR32_KMAP_TYPES_H
4627
4628 #ifdef CONFIG_DEBUG_HIGHMEM
4629 -# define KM_TYPE_NR 29
4630 +# define KM_TYPE_NR 30
4631 #else
4632 -# define KM_TYPE_NR 14
4633 +# define KM_TYPE_NR 15
4634 #endif
4635
4636 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4637 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4638 index b2f2d2d..d1c85cb 100644
4639 --- a/arch/avr32/mm/fault.c
4640 +++ b/arch/avr32/mm/fault.c
4641 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4642
4643 int exception_trace = 1;
4644
4645 +#ifdef CONFIG_PAX_PAGEEXEC
4646 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4647 +{
4648 + unsigned long i;
4649 +
4650 + printk(KERN_ERR "PAX: bytes at PC: ");
4651 + for (i = 0; i < 20; i++) {
4652 + unsigned char c;
4653 + if (get_user(c, (unsigned char *)pc+i))
4654 + printk(KERN_CONT "???????? ");
4655 + else
4656 + printk(KERN_CONT "%02x ", c);
4657 + }
4658 + printk("\n");
4659 +}
4660 +#endif
4661 +
4662 /*
4663 * This routine handles page faults. It determines the address and the
4664 * problem, and then passes it off to one of the appropriate routines.
4665 @@ -174,6 +191,16 @@ bad_area:
4666 up_read(&mm->mmap_sem);
4667
4668 if (user_mode(regs)) {
4669 +
4670 +#ifdef CONFIG_PAX_PAGEEXEC
4671 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4672 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4673 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4674 + do_group_exit(SIGKILL);
4675 + }
4676 + }
4677 +#endif
4678 +
4679 if (exception_trace && printk_ratelimit())
4680 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4681 "sp %08lx ecr %lu\n",
4682 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4683 index 568885a..f8008df 100644
4684 --- a/arch/blackfin/include/asm/cache.h
4685 +++ b/arch/blackfin/include/asm/cache.h
4686 @@ -7,6 +7,7 @@
4687 #ifndef __ARCH_BLACKFIN_CACHE_H
4688 #define __ARCH_BLACKFIN_CACHE_H
4689
4690 +#include <linux/const.h>
4691 #include <linux/linkage.h> /* for asmlinkage */
4692
4693 /*
4694 @@ -14,7 +15,7 @@
4695 * Blackfin loads 32 bytes for cache
4696 */
4697 #define L1_CACHE_SHIFT 5
4698 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4699 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4700 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4701
4702 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4703 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4704 index aea2718..3639a60 100644
4705 --- a/arch/cris/include/arch-v10/arch/cache.h
4706 +++ b/arch/cris/include/arch-v10/arch/cache.h
4707 @@ -1,8 +1,9 @@
4708 #ifndef _ASM_ARCH_CACHE_H
4709 #define _ASM_ARCH_CACHE_H
4710
4711 +#include <linux/const.h>
4712 /* Etrax 100LX have 32-byte cache-lines. */
4713 -#define L1_CACHE_BYTES 32
4714 #define L1_CACHE_SHIFT 5
4715 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4716
4717 #endif /* _ASM_ARCH_CACHE_H */
4718 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4719 index 7caf25d..ee65ac5 100644
4720 --- a/arch/cris/include/arch-v32/arch/cache.h
4721 +++ b/arch/cris/include/arch-v32/arch/cache.h
4722 @@ -1,11 +1,12 @@
4723 #ifndef _ASM_CRIS_ARCH_CACHE_H
4724 #define _ASM_CRIS_ARCH_CACHE_H
4725
4726 +#include <linux/const.h>
4727 #include <arch/hwregs/dma.h>
4728
4729 /* A cache-line is 32 bytes. */
4730 -#define L1_CACHE_BYTES 32
4731 #define L1_CACHE_SHIFT 5
4732 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4733
4734 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4735
4736 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4737 index b86329d..6709906 100644
4738 --- a/arch/frv/include/asm/atomic.h
4739 +++ b/arch/frv/include/asm/atomic.h
4740 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4741 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4742 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4743
4744 +#define atomic64_read_unchecked(v) atomic64_read(v)
4745 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4746 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4747 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4748 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4749 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4750 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4751 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4752 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4753 +
4754 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4755 {
4756 int c, old;
4757 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4758 index 2797163..c2a401d 100644
4759 --- a/arch/frv/include/asm/cache.h
4760 +++ b/arch/frv/include/asm/cache.h
4761 @@ -12,10 +12,11 @@
4762 #ifndef __ASM_CACHE_H
4763 #define __ASM_CACHE_H
4764
4765 +#include <linux/const.h>
4766
4767 /* bytes per L1 cache line */
4768 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4769 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4770 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4771
4772 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4773 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4774 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4775 index 43901f2..0d8b865 100644
4776 --- a/arch/frv/include/asm/kmap_types.h
4777 +++ b/arch/frv/include/asm/kmap_types.h
4778 @@ -2,6 +2,6 @@
4779 #ifndef _ASM_KMAP_TYPES_H
4780 #define _ASM_KMAP_TYPES_H
4781
4782 -#define KM_TYPE_NR 17
4783 +#define KM_TYPE_NR 18
4784
4785 #endif
4786 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4787 index 836f147..4cf23f5 100644
4788 --- a/arch/frv/mm/elf-fdpic.c
4789 +++ b/arch/frv/mm/elf-fdpic.c
4790 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4791 {
4792 struct vm_area_struct *vma;
4793 struct vm_unmapped_area_info info;
4794 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4795
4796 if (len > TASK_SIZE)
4797 return -ENOMEM;
4798 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4799 if (addr) {
4800 addr = PAGE_ALIGN(addr);
4801 vma = find_vma(current->mm, addr);
4802 - if (TASK_SIZE - len >= addr &&
4803 - (!vma || addr + len <= vma->vm_start))
4804 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4805 goto success;
4806 }
4807
4808 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4809 info.high_limit = (current->mm->start_stack - 0x00200000);
4810 info.align_mask = 0;
4811 info.align_offset = 0;
4812 + info.threadstack_offset = offset;
4813 addr = vm_unmapped_area(&info);
4814 if (!(addr & ~PAGE_MASK))
4815 goto success;
4816 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4817 index f4ca594..adc72fd6 100644
4818 --- a/arch/hexagon/include/asm/cache.h
4819 +++ b/arch/hexagon/include/asm/cache.h
4820 @@ -21,9 +21,11 @@
4821 #ifndef __ASM_CACHE_H
4822 #define __ASM_CACHE_H
4823
4824 +#include <linux/const.h>
4825 +
4826 /* Bytes per L1 cache line */
4827 -#define L1_CACHE_SHIFT (5)
4828 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4829 +#define L1_CACHE_SHIFT 5
4830 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4831
4832 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4833 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4834 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4835 index 6e6fe18..a6ae668 100644
4836 --- a/arch/ia64/include/asm/atomic.h
4837 +++ b/arch/ia64/include/asm/atomic.h
4838 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4839 #define atomic64_inc(v) atomic64_add(1, (v))
4840 #define atomic64_dec(v) atomic64_sub(1, (v))
4841
4842 +#define atomic64_read_unchecked(v) atomic64_read(v)
4843 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4844 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4845 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4846 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4847 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4848 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4849 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4850 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4851 +
4852 /* Atomic operations are already serializing */
4853 #define smp_mb__before_atomic_dec() barrier()
4854 #define smp_mb__after_atomic_dec() barrier()
4855 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4856 index 988254a..e1ee885 100644
4857 --- a/arch/ia64/include/asm/cache.h
4858 +++ b/arch/ia64/include/asm/cache.h
4859 @@ -1,6 +1,7 @@
4860 #ifndef _ASM_IA64_CACHE_H
4861 #define _ASM_IA64_CACHE_H
4862
4863 +#include <linux/const.h>
4864
4865 /*
4866 * Copyright (C) 1998-2000 Hewlett-Packard Co
4867 @@ -9,7 +10,7 @@
4868
4869 /* Bytes per L1 (data) cache line. */
4870 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4871 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4872 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4873
4874 #ifdef CONFIG_SMP
4875 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4876 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4877 index 5a83c5c..4d7f553 100644
4878 --- a/arch/ia64/include/asm/elf.h
4879 +++ b/arch/ia64/include/asm/elf.h
4880 @@ -42,6 +42,13 @@
4881 */
4882 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4883
4884 +#ifdef CONFIG_PAX_ASLR
4885 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4886 +
4887 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4888 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4889 +#endif
4890 +
4891 #define PT_IA_64_UNWIND 0x70000001
4892
4893 /* IA-64 relocations: */
4894 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4895 index 96a8d92..617a1cf 100644
4896 --- a/arch/ia64/include/asm/pgalloc.h
4897 +++ b/arch/ia64/include/asm/pgalloc.h
4898 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4899 pgd_val(*pgd_entry) = __pa(pud);
4900 }
4901
4902 +static inline void
4903 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4904 +{
4905 + pgd_populate(mm, pgd_entry, pud);
4906 +}
4907 +
4908 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4909 {
4910 return quicklist_alloc(0, GFP_KERNEL, NULL);
4911 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4912 pud_val(*pud_entry) = __pa(pmd);
4913 }
4914
4915 +static inline void
4916 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4917 +{
4918 + pud_populate(mm, pud_entry, pmd);
4919 +}
4920 +
4921 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4922 {
4923 return quicklist_alloc(0, GFP_KERNEL, NULL);
4924 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4925 index 7935115..c0eca6a 100644
4926 --- a/arch/ia64/include/asm/pgtable.h
4927 +++ b/arch/ia64/include/asm/pgtable.h
4928 @@ -12,7 +12,7 @@
4929 * David Mosberger-Tang <davidm@hpl.hp.com>
4930 */
4931
4932 -
4933 +#include <linux/const.h>
4934 #include <asm/mman.h>
4935 #include <asm/page.h>
4936 #include <asm/processor.h>
4937 @@ -142,6 +142,17 @@
4938 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4939 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4940 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4941 +
4942 +#ifdef CONFIG_PAX_PAGEEXEC
4943 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4944 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4945 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4946 +#else
4947 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4948 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4949 +# define PAGE_COPY_NOEXEC PAGE_COPY
4950 +#endif
4951 +
4952 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4953 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4954 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4955 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4956 index 54ff557..70c88b7 100644
4957 --- a/arch/ia64/include/asm/spinlock.h
4958 +++ b/arch/ia64/include/asm/spinlock.h
4959 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4960 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4961
4962 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4963 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4964 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4965 }
4966
4967 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4968 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4969 index 449c8c0..18965fb 100644
4970 --- a/arch/ia64/include/asm/uaccess.h
4971 +++ b/arch/ia64/include/asm/uaccess.h
4972 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4973 static inline unsigned long
4974 __copy_to_user (void __user *to, const void *from, unsigned long count)
4975 {
4976 + if (count > INT_MAX)
4977 + return count;
4978 +
4979 + if (!__builtin_constant_p(count))
4980 + check_object_size(from, count, true);
4981 +
4982 return __copy_user(to, (__force void __user *) from, count);
4983 }
4984
4985 static inline unsigned long
4986 __copy_from_user (void *to, const void __user *from, unsigned long count)
4987 {
4988 + if (count > INT_MAX)
4989 + return count;
4990 +
4991 + if (!__builtin_constant_p(count))
4992 + check_object_size(to, count, false);
4993 +
4994 return __copy_user((__force void __user *) to, from, count);
4995 }
4996
4997 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4998 ({ \
4999 void __user *__cu_to = (to); \
5000 const void *__cu_from = (from); \
5001 - long __cu_len = (n); \
5002 + unsigned long __cu_len = (n); \
5003 \
5004 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5005 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5006 + if (!__builtin_constant_p(n)) \
5007 + check_object_size(__cu_from, __cu_len, true); \
5008 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5009 + } \
5010 __cu_len; \
5011 })
5012
5013 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5014 ({ \
5015 void *__cu_to = (to); \
5016 const void __user *__cu_from = (from); \
5017 - long __cu_len = (n); \
5018 + unsigned long __cu_len = (n); \
5019 \
5020 __chk_user_ptr(__cu_from); \
5021 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5022 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5023 + if (!__builtin_constant_p(n)) \
5024 + check_object_size(__cu_to, __cu_len, false); \
5025 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5026 + } \
5027 __cu_len; \
5028 })
5029
5030 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5031 index 24603be..948052d 100644
5032 --- a/arch/ia64/kernel/module.c
5033 +++ b/arch/ia64/kernel/module.c
5034 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5035 void
5036 module_free (struct module *mod, void *module_region)
5037 {
5038 - if (mod && mod->arch.init_unw_table &&
5039 - module_region == mod->module_init) {
5040 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5041 unw_remove_unwind_table(mod->arch.init_unw_table);
5042 mod->arch.init_unw_table = NULL;
5043 }
5044 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5045 }
5046
5047 static inline int
5048 +in_init_rx (const struct module *mod, uint64_t addr)
5049 +{
5050 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5051 +}
5052 +
5053 +static inline int
5054 +in_init_rw (const struct module *mod, uint64_t addr)
5055 +{
5056 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5057 +}
5058 +
5059 +static inline int
5060 in_init (const struct module *mod, uint64_t addr)
5061 {
5062 - return addr - (uint64_t) mod->module_init < mod->init_size;
5063 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5064 +}
5065 +
5066 +static inline int
5067 +in_core_rx (const struct module *mod, uint64_t addr)
5068 +{
5069 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5070 +}
5071 +
5072 +static inline int
5073 +in_core_rw (const struct module *mod, uint64_t addr)
5074 +{
5075 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5076 }
5077
5078 static inline int
5079 in_core (const struct module *mod, uint64_t addr)
5080 {
5081 - return addr - (uint64_t) mod->module_core < mod->core_size;
5082 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5083 }
5084
5085 static inline int
5086 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5087 break;
5088
5089 case RV_BDREL:
5090 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5091 + if (in_init_rx(mod, val))
5092 + val -= (uint64_t) mod->module_init_rx;
5093 + else if (in_init_rw(mod, val))
5094 + val -= (uint64_t) mod->module_init_rw;
5095 + else if (in_core_rx(mod, val))
5096 + val -= (uint64_t) mod->module_core_rx;
5097 + else if (in_core_rw(mod, val))
5098 + val -= (uint64_t) mod->module_core_rw;
5099 break;
5100
5101 case RV_LTV:
5102 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5103 * addresses have been selected...
5104 */
5105 uint64_t gp;
5106 - if (mod->core_size > MAX_LTOFF)
5107 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5108 /*
5109 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5110 * at the end of the module.
5111 */
5112 - gp = mod->core_size - MAX_LTOFF / 2;
5113 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5114 else
5115 - gp = mod->core_size / 2;
5116 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5117 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5118 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5119 mod->arch.gp = gp;
5120 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5121 }
5122 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5123 index ab33328..f39506c 100644
5124 --- a/arch/ia64/kernel/palinfo.c
5125 +++ b/arch/ia64/kernel/palinfo.c
5126 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5127 return NOTIFY_OK;
5128 }
5129
5130 -static struct notifier_block __refdata palinfo_cpu_notifier =
5131 +static struct notifier_block palinfo_cpu_notifier =
5132 {
5133 .notifier_call = palinfo_cpu_callback,
5134 .priority = 0,
5135 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5136 index 41e33f8..65180b2 100644
5137 --- a/arch/ia64/kernel/sys_ia64.c
5138 +++ b/arch/ia64/kernel/sys_ia64.c
5139 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5140 unsigned long align_mask = 0;
5141 struct mm_struct *mm = current->mm;
5142 struct vm_unmapped_area_info info;
5143 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5144
5145 if (len > RGN_MAP_LIMIT)
5146 return -ENOMEM;
5147 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5148 if (REGION_NUMBER(addr) == RGN_HPAGE)
5149 addr = 0;
5150 #endif
5151 +
5152 +#ifdef CONFIG_PAX_RANDMMAP
5153 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5154 + addr = mm->free_area_cache;
5155 + else
5156 +#endif
5157 +
5158 if (!addr)
5159 addr = TASK_UNMAPPED_BASE;
5160
5161 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5162 info.high_limit = TASK_SIZE;
5163 info.align_mask = align_mask;
5164 info.align_offset = 0;
5165 + info.threadstack_offset = offset;
5166 return vm_unmapped_area(&info);
5167 }
5168
5169 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5170 index 0ccb28f..8992469 100644
5171 --- a/arch/ia64/kernel/vmlinux.lds.S
5172 +++ b/arch/ia64/kernel/vmlinux.lds.S
5173 @@ -198,7 +198,7 @@ SECTIONS {
5174 /* Per-cpu data: */
5175 . = ALIGN(PERCPU_PAGE_SIZE);
5176 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5177 - __phys_per_cpu_start = __per_cpu_load;
5178 + __phys_per_cpu_start = per_cpu_load;
5179 /*
5180 * ensure percpu data fits
5181 * into percpu page size
5182 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5183 index 6cf0341..d352594 100644
5184 --- a/arch/ia64/mm/fault.c
5185 +++ b/arch/ia64/mm/fault.c
5186 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5187 return pte_present(pte);
5188 }
5189
5190 +#ifdef CONFIG_PAX_PAGEEXEC
5191 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5192 +{
5193 + unsigned long i;
5194 +
5195 + printk(KERN_ERR "PAX: bytes at PC: ");
5196 + for (i = 0; i < 8; i++) {
5197 + unsigned int c;
5198 + if (get_user(c, (unsigned int *)pc+i))
5199 + printk(KERN_CONT "???????? ");
5200 + else
5201 + printk(KERN_CONT "%08x ", c);
5202 + }
5203 + printk("\n");
5204 +}
5205 +#endif
5206 +
5207 # define VM_READ_BIT 0
5208 # define VM_WRITE_BIT 1
5209 # define VM_EXEC_BIT 2
5210 @@ -149,8 +166,21 @@ retry:
5211 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5212 goto bad_area;
5213
5214 - if ((vma->vm_flags & mask) != mask)
5215 + if ((vma->vm_flags & mask) != mask) {
5216 +
5217 +#ifdef CONFIG_PAX_PAGEEXEC
5218 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5219 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5220 + goto bad_area;
5221 +
5222 + up_read(&mm->mmap_sem);
5223 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5224 + do_group_exit(SIGKILL);
5225 + }
5226 +#endif
5227 +
5228 goto bad_area;
5229 + }
5230
5231 /*
5232 * If for any reason at all we couldn't handle the fault, make
5233 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5234 index 76069c1..c2aa816 100644
5235 --- a/arch/ia64/mm/hugetlbpage.c
5236 +++ b/arch/ia64/mm/hugetlbpage.c
5237 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5238 unsigned long pgoff, unsigned long flags)
5239 {
5240 struct vm_unmapped_area_info info;
5241 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5242
5243 if (len > RGN_MAP_LIMIT)
5244 return -ENOMEM;
5245 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5246 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5247 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5248 info.align_offset = 0;
5249 + info.threadstack_offset = offset;
5250 return vm_unmapped_area(&info);
5251 }
5252
5253 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5254 index b6f7f43..c04320d 100644
5255 --- a/arch/ia64/mm/init.c
5256 +++ b/arch/ia64/mm/init.c
5257 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5258 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5259 vma->vm_end = vma->vm_start + PAGE_SIZE;
5260 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5261 +
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5264 + vma->vm_flags &= ~VM_EXEC;
5265 +
5266 +#ifdef CONFIG_PAX_MPROTECT
5267 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5268 + vma->vm_flags &= ~VM_MAYEXEC;
5269 +#endif
5270 +
5271 + }
5272 +#endif
5273 +
5274 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5275 down_write(&current->mm->mmap_sem);
5276 if (insert_vm_struct(current->mm, vma)) {
5277 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5278 index 40b3ee9..8c2c112 100644
5279 --- a/arch/m32r/include/asm/cache.h
5280 +++ b/arch/m32r/include/asm/cache.h
5281 @@ -1,8 +1,10 @@
5282 #ifndef _ASM_M32R_CACHE_H
5283 #define _ASM_M32R_CACHE_H
5284
5285 +#include <linux/const.h>
5286 +
5287 /* L1 cache line size */
5288 #define L1_CACHE_SHIFT 4
5289 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5290 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5291
5292 #endif /* _ASM_M32R_CACHE_H */
5293 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5294 index 82abd15..d95ae5d 100644
5295 --- a/arch/m32r/lib/usercopy.c
5296 +++ b/arch/m32r/lib/usercopy.c
5297 @@ -14,6 +14,9 @@
5298 unsigned long
5299 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5300 {
5301 + if ((long)n < 0)
5302 + return n;
5303 +
5304 prefetch(from);
5305 if (access_ok(VERIFY_WRITE, to, n))
5306 __copy_user(to,from,n);
5307 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5308 unsigned long
5309 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5310 {
5311 + if ((long)n < 0)
5312 + return n;
5313 +
5314 prefetchw(to);
5315 if (access_ok(VERIFY_READ, from, n))
5316 __copy_user_zeroing(to,from,n);
5317 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5318 index 0395c51..5f26031 100644
5319 --- a/arch/m68k/include/asm/cache.h
5320 +++ b/arch/m68k/include/asm/cache.h
5321 @@ -4,9 +4,11 @@
5322 #ifndef __ARCH_M68K_CACHE_H
5323 #define __ARCH_M68K_CACHE_H
5324
5325 +#include <linux/const.h>
5326 +
5327 /* bytes per L1 cache line */
5328 #define L1_CACHE_SHIFT 4
5329 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5330 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5331
5332 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5333
5334 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5335 index 3c52fa6..11b2ad8 100644
5336 --- a/arch/metag/mm/hugetlbpage.c
5337 +++ b/arch/metag/mm/hugetlbpage.c
5338 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5339 info.high_limit = TASK_SIZE;
5340 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5341 info.align_offset = 0;
5342 + info.threadstack_offset = 0;
5343 return vm_unmapped_area(&info);
5344 }
5345
5346 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5347 index 4efe96a..60e8699 100644
5348 --- a/arch/microblaze/include/asm/cache.h
5349 +++ b/arch/microblaze/include/asm/cache.h
5350 @@ -13,11 +13,12 @@
5351 #ifndef _ASM_MICROBLAZE_CACHE_H
5352 #define _ASM_MICROBLAZE_CACHE_H
5353
5354 +#include <linux/const.h>
5355 #include <asm/registers.h>
5356
5357 #define L1_CACHE_SHIFT 5
5358 /* word-granular cache in microblaze */
5359 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5360 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5361
5362 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5363
5364 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5365 index 08b6079..8b554d2 100644
5366 --- a/arch/mips/include/asm/atomic.h
5367 +++ b/arch/mips/include/asm/atomic.h
5368 @@ -21,15 +21,39 @@
5369 #include <asm/cmpxchg.h>
5370 #include <asm/war.h>
5371
5372 +#ifdef CONFIG_GENERIC_ATOMIC64
5373 +#include <asm-generic/atomic64.h>
5374 +#endif
5375 +
5376 #define ATOMIC_INIT(i) { (i) }
5377
5378 +#ifdef CONFIG_64BIT
5379 +#define _ASM_EXTABLE(from, to) \
5380 +" .section __ex_table,\"a\"\n" \
5381 +" .dword " #from ", " #to"\n" \
5382 +" .previous\n"
5383 +#else
5384 +#define _ASM_EXTABLE(from, to) \
5385 +" .section __ex_table,\"a\"\n" \
5386 +" .word " #from ", " #to"\n" \
5387 +" .previous\n"
5388 +#endif
5389 +
5390 /*
5391 * atomic_read - read atomic variable
5392 * @v: pointer of type atomic_t
5393 *
5394 * Atomically reads the value of @v.
5395 */
5396 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5397 +static inline int atomic_read(const atomic_t *v)
5398 +{
5399 + return (*(volatile const int *) &v->counter);
5400 +}
5401 +
5402 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5403 +{
5404 + return (*(volatile const int *) &v->counter);
5405 +}
5406
5407 /*
5408 * atomic_set - set atomic variable
5409 @@ -38,7 +62,15 @@
5410 *
5411 * Atomically sets the value of @v to @i.
5412 */
5413 -#define atomic_set(v, i) ((v)->counter = (i))
5414 +static inline void atomic_set(atomic_t *v, int i)
5415 +{
5416 + v->counter = i;
5417 +}
5418 +
5419 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5420 +{
5421 + v->counter = i;
5422 +}
5423
5424 /*
5425 * atomic_add - add integer to atomic variable
5426 @@ -47,7 +79,67 @@
5427 *
5428 * Atomically adds @i to @v.
5429 */
5430 -static __inline__ void atomic_add(int i, atomic_t * v)
5431 +static __inline__ void atomic_add(int i, atomic_t *v)
5432 +{
5433 + int temp;
5434 +
5435 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5436 + __asm__ __volatile__(
5437 + " .set mips3 \n"
5438 + "1: ll %0, %1 # atomic_add \n"
5439 +#ifdef CONFIG_PAX_REFCOUNT
5440 + /* Exception on overflow. */
5441 + "2: add %0, %2 \n"
5442 +#else
5443 + " addu %0, %2 \n"
5444 +#endif
5445 + " sc %0, %1 \n"
5446 + " beqzl %0, 1b \n"
5447 +#ifdef CONFIG_PAX_REFCOUNT
5448 + "3: \n"
5449 + _ASM_EXTABLE(2b, 3b)
5450 +#endif
5451 + " .set mips0 \n"
5452 + : "=&r" (temp), "+m" (v->counter)
5453 + : "Ir" (i));
5454 + } else if (kernel_uses_llsc) {
5455 + __asm__ __volatile__(
5456 + " .set mips3 \n"
5457 + "1: ll %0, %1 # atomic_add \n"
5458 +#ifdef CONFIG_PAX_REFCOUNT
5459 + /* Exception on overflow. */
5460 + "2: add %0, %2 \n"
5461 +#else
5462 + " addu %0, %2 \n"
5463 +#endif
5464 + " sc %0, %1 \n"
5465 + " beqz %0, 1b \n"
5466 +#ifdef CONFIG_PAX_REFCOUNT
5467 + "3: \n"
5468 + _ASM_EXTABLE(2b, 3b)
5469 +#endif
5470 + " .set mips0 \n"
5471 + : "=&r" (temp), "+m" (v->counter)
5472 + : "Ir" (i));
5473 + } else {
5474 + unsigned long flags;
5475 +
5476 + raw_local_irq_save(flags);
5477 + __asm__ __volatile__(
5478 +#ifdef CONFIG_PAX_REFCOUNT
5479 + /* Exception on overflow. */
5480 + "1: add %0, %1 \n"
5481 + "2: \n"
5482 + _ASM_EXTABLE(1b, 2b)
5483 +#else
5484 + " addu %0, %1 \n"
5485 +#endif
5486 + : "+r" (v->counter) : "Ir" (i));
5487 + raw_local_irq_restore(flags);
5488 + }
5489 +}
5490 +
5491 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5492 {
5493 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5494 int temp;
5495 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5496 *
5497 * Atomically subtracts @i from @v.
5498 */
5499 -static __inline__ void atomic_sub(int i, atomic_t * v)
5500 +static __inline__ void atomic_sub(int i, atomic_t *v)
5501 +{
5502 + int temp;
5503 +
5504 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5505 + __asm__ __volatile__(
5506 + " .set mips3 \n"
5507 + "1: ll %0, %1 # atomic64_sub \n"
5508 +#ifdef CONFIG_PAX_REFCOUNT
5509 + /* Exception on overflow. */
5510 + "2: sub %0, %2 \n"
5511 +#else
5512 + " subu %0, %2 \n"
5513 +#endif
5514 + " sc %0, %1 \n"
5515 + " beqzl %0, 1b \n"
5516 +#ifdef CONFIG_PAX_REFCOUNT
5517 + "3: \n"
5518 + _ASM_EXTABLE(2b, 3b)
5519 +#endif
5520 + " .set mips0 \n"
5521 + : "=&r" (temp), "+m" (v->counter)
5522 + : "Ir" (i));
5523 + } else if (kernel_uses_llsc) {
5524 + __asm__ __volatile__(
5525 + " .set mips3 \n"
5526 + "1: ll %0, %1 # atomic64_sub \n"
5527 +#ifdef CONFIG_PAX_REFCOUNT
5528 + /* Exception on overflow. */
5529 + "2: sub %0, %2 \n"
5530 +#else
5531 + " subu %0, %2 \n"
5532 +#endif
5533 + " sc %0, %1 \n"
5534 + " beqz %0, 1b \n"
5535 +#ifdef CONFIG_PAX_REFCOUNT
5536 + "3: \n"
5537 + _ASM_EXTABLE(2b, 3b)
5538 +#endif
5539 + " .set mips0 \n"
5540 + : "=&r" (temp), "+m" (v->counter)
5541 + : "Ir" (i));
5542 + } else {
5543 + unsigned long flags;
5544 +
5545 + raw_local_irq_save(flags);
5546 + __asm__ __volatile__(
5547 +#ifdef CONFIG_PAX_REFCOUNT
5548 + /* Exception on overflow. */
5549 + "1: sub %0, %1 \n"
5550 + "2: \n"
5551 + _ASM_EXTABLE(1b, 2b)
5552 +#else
5553 + " subu %0, %1 \n"
5554 +#endif
5555 + : "+r" (v->counter) : "Ir" (i));
5556 + raw_local_irq_restore(flags);
5557 + }
5558 +}
5559 +
5560 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5561 {
5562 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5563 int temp;
5564 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5565 /*
5566 * Same as above, but return the result value
5567 */
5568 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5569 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5570 +{
5571 + int result;
5572 + int temp;
5573 +
5574 + smp_mb__before_llsc();
5575 +
5576 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5577 + __asm__ __volatile__(
5578 + " .set mips3 \n"
5579 + "1: ll %1, %2 # atomic_add_return \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + "2: add %0, %1, %3 \n"
5582 +#else
5583 + " addu %0, %1, %3 \n"
5584 +#endif
5585 + " sc %0, %2 \n"
5586 + " beqzl %0, 1b \n"
5587 +#ifdef CONFIG_PAX_REFCOUNT
5588 + " b 4f \n"
5589 + " .set noreorder \n"
5590 + "3: b 5f \n"
5591 + " move %0, %1 \n"
5592 + " .set reorder \n"
5593 + _ASM_EXTABLE(2b, 3b)
5594 +#endif
5595 + "4: addu %0, %1, %3 \n"
5596 +#ifdef CONFIG_PAX_REFCOUNT
5597 + "5: \n"
5598 +#endif
5599 + " .set mips0 \n"
5600 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5601 + : "Ir" (i));
5602 + } else if (kernel_uses_llsc) {
5603 + __asm__ __volatile__(
5604 + " .set mips3 \n"
5605 + "1: ll %1, %2 # atomic_add_return \n"
5606 +#ifdef CONFIG_PAX_REFCOUNT
5607 + "2: add %0, %1, %3 \n"
5608 +#else
5609 + " addu %0, %1, %3 \n"
5610 +#endif
5611 + " sc %0, %2 \n"
5612 + " bnez %0, 4f \n"
5613 + " b 1b \n"
5614 +#ifdef CONFIG_PAX_REFCOUNT
5615 + " .set noreorder \n"
5616 + "3: b 5f \n"
5617 + " move %0, %1 \n"
5618 + " .set reorder \n"
5619 + _ASM_EXTABLE(2b, 3b)
5620 +#endif
5621 + "4: addu %0, %1, %3 \n"
5622 +#ifdef CONFIG_PAX_REFCOUNT
5623 + "5: \n"
5624 +#endif
5625 + " .set mips0 \n"
5626 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5627 + : "Ir" (i));
5628 + } else {
5629 + unsigned long flags;
5630 +
5631 + raw_local_irq_save(flags);
5632 + __asm__ __volatile__(
5633 + " lw %0, %1 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + /* Exception on overflow. */
5636 + "1: add %0, %2 \n"
5637 +#else
5638 + " addu %0, %2 \n"
5639 +#endif
5640 + " sw %0, %1 \n"
5641 +#ifdef CONFIG_PAX_REFCOUNT
5642 + /* Note: Dest reg is not modified on overflow */
5643 + "2: \n"
5644 + _ASM_EXTABLE(1b, 2b)
5645 +#endif
5646 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5647 + raw_local_irq_restore(flags);
5648 + }
5649 +
5650 + smp_llsc_mb();
5651 +
5652 + return result;
5653 +}
5654 +
5655 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5656 {
5657 int result;
5658
5659 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5660 return result;
5661 }
5662
5663 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5664 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5665 +{
5666 + int result;
5667 + int temp;
5668 +
5669 + smp_mb__before_llsc();
5670 +
5671 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5672 + __asm__ __volatile__(
5673 + " .set mips3 \n"
5674 + "1: ll %1, %2 # atomic_sub_return \n"
5675 +#ifdef CONFIG_PAX_REFCOUNT
5676 + "2: sub %0, %1, %3 \n"
5677 +#else
5678 + " subu %0, %1, %3 \n"
5679 +#endif
5680 + " sc %0, %2 \n"
5681 + " beqzl %0, 1b \n"
5682 +#ifdef CONFIG_PAX_REFCOUNT
5683 + " b 4f \n"
5684 + " .set noreorder \n"
5685 + "3: b 5f \n"
5686 + " move %0, %1 \n"
5687 + " .set reorder \n"
5688 + _ASM_EXTABLE(2b, 3b)
5689 +#endif
5690 + "4: subu %0, %1, %3 \n"
5691 +#ifdef CONFIG_PAX_REFCOUNT
5692 + "5: \n"
5693 +#endif
5694 + " .set mips0 \n"
5695 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5696 + : "Ir" (i), "m" (v->counter)
5697 + : "memory");
5698 + } else if (kernel_uses_llsc) {
5699 + __asm__ __volatile__(
5700 + " .set mips3 \n"
5701 + "1: ll %1, %2 # atomic_sub_return \n"
5702 +#ifdef CONFIG_PAX_REFCOUNT
5703 + "2: sub %0, %1, %3 \n"
5704 +#else
5705 + " subu %0, %1, %3 \n"
5706 +#endif
5707 + " sc %0, %2 \n"
5708 + " bnez %0, 4f \n"
5709 + " b 1b \n"
5710 +#ifdef CONFIG_PAX_REFCOUNT
5711 + " .set noreorder \n"
5712 + "3: b 5f \n"
5713 + " move %0, %1 \n"
5714 + " .set reorder \n"
5715 + _ASM_EXTABLE(2b, 3b)
5716 +#endif
5717 + "4: subu %0, %1, %3 \n"
5718 +#ifdef CONFIG_PAX_REFCOUNT
5719 + "5: \n"
5720 +#endif
5721 + " .set mips0 \n"
5722 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5723 + : "Ir" (i));
5724 + } else {
5725 + unsigned long flags;
5726 +
5727 + raw_local_irq_save(flags);
5728 + __asm__ __volatile__(
5729 + " lw %0, %1 \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Exception on overflow. */
5732 + "1: sub %0, %2 \n"
5733 +#else
5734 + " subu %0, %2 \n"
5735 +#endif
5736 + " sw %0, %1 \n"
5737 +#ifdef CONFIG_PAX_REFCOUNT
5738 + /* Note: Dest reg is not modified on overflow */
5739 + "2: \n"
5740 + _ASM_EXTABLE(1b, 2b)
5741 +#endif
5742 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5743 + raw_local_irq_restore(flags);
5744 + }
5745 +
5746 + smp_llsc_mb();
5747 +
5748 + return result;
5749 +}
5750 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5751 {
5752 int result;
5753
5754 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5755 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5756 * The function returns the old value of @v minus @i.
5757 */
5758 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5759 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5760 {
5761 int result;
5762
5763 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5764 return result;
5765 }
5766
5767 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5768 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5769 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5770 +{
5771 + return cmpxchg(&v->counter, old, new);
5772 +}
5773 +
5774 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5775 + int new)
5776 +{
5777 + return cmpxchg(&(v->counter), old, new);
5778 +}
5779 +
5780 +static inline int atomic_xchg(atomic_t *v, int new)
5781 +{
5782 + return xchg(&v->counter, new);
5783 +}
5784 +
5785 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5786 +{
5787 + return xchg(&(v->counter), new);
5788 +}
5789
5790 /**
5791 * __atomic_add_unless - add unless the number is a given value
5792 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5793
5794 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5795 #define atomic_inc_return(v) atomic_add_return(1, (v))
5796 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5797 +{
5798 + return atomic_add_return_unchecked(1, v);
5799 +}
5800
5801 /*
5802 * atomic_sub_and_test - subtract value from variable and test result
5803 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5804 * other cases.
5805 */
5806 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5807 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5808 +{
5809 + return atomic_add_return_unchecked(1, v) == 0;
5810 +}
5811
5812 /*
5813 * atomic_dec_and_test - decrement by 1 and test
5814 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5815 * Atomically increments @v by 1.
5816 */
5817 #define atomic_inc(v) atomic_add(1, (v))
5818 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5819 +{
5820 + atomic_add_unchecked(1, v);
5821 +}
5822
5823 /*
5824 * atomic_dec - decrement and test
5825 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5826 * Atomically decrements @v by 1.
5827 */
5828 #define atomic_dec(v) atomic_sub(1, (v))
5829 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5830 +{
5831 + atomic_sub_unchecked(1, v);
5832 +}
5833
5834 /*
5835 * atomic_add_negative - add and test if negative
5836 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5837 * @v: pointer of type atomic64_t
5838 *
5839 */
5840 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5841 +static inline long atomic64_read(const atomic64_t *v)
5842 +{
5843 + return (*(volatile const long *) &v->counter);
5844 +}
5845 +
5846 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5847 +{
5848 + return (*(volatile const long *) &v->counter);
5849 +}
5850
5851 /*
5852 * atomic64_set - set atomic variable
5853 * @v: pointer of type atomic64_t
5854 * @i: required value
5855 */
5856 -#define atomic64_set(v, i) ((v)->counter = (i))
5857 +static inline void atomic64_set(atomic64_t *v, long i)
5858 +{
5859 + v->counter = i;
5860 +}
5861 +
5862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5863 +{
5864 + v->counter = i;
5865 +}
5866
5867 /*
5868 * atomic64_add - add integer to atomic variable
5869 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5870 *
5871 * Atomically adds @i to @v.
5872 */
5873 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5874 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5875 +{
5876 + long temp;
5877 +
5878 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5879 + __asm__ __volatile__(
5880 + " .set mips3 \n"
5881 + "1: lld %0, %1 # atomic64_add \n"
5882 +#ifdef CONFIG_PAX_REFCOUNT
5883 + /* Exception on overflow. */
5884 + "2: dadd %0, %2 \n"
5885 +#else
5886 + " daddu %0, %2 \n"
5887 +#endif
5888 + " scd %0, %1 \n"
5889 + " beqzl %0, 1b \n"
5890 +#ifdef CONFIG_PAX_REFCOUNT
5891 + "3: \n"
5892 + _ASM_EXTABLE(2b, 3b)
5893 +#endif
5894 + " .set mips0 \n"
5895 + : "=&r" (temp), "+m" (v->counter)
5896 + : "Ir" (i));
5897 + } else if (kernel_uses_llsc) {
5898 + __asm__ __volatile__(
5899 + " .set mips3 \n"
5900 + "1: lld %0, %1 # atomic64_add \n"
5901 +#ifdef CONFIG_PAX_REFCOUNT
5902 + /* Exception on overflow. */
5903 + "2: dadd %0, %2 \n"
5904 +#else
5905 + " daddu %0, %2 \n"
5906 +#endif
5907 + " scd %0, %1 \n"
5908 + " beqz %0, 1b \n"
5909 +#ifdef CONFIG_PAX_REFCOUNT
5910 + "3: \n"
5911 + _ASM_EXTABLE(2b, 3b)
5912 +#endif
5913 + " .set mips0 \n"
5914 + : "=&r" (temp), "+m" (v->counter)
5915 + : "Ir" (i));
5916 + } else {
5917 + unsigned long flags;
5918 +
5919 + raw_local_irq_save(flags);
5920 + __asm__ __volatile__(
5921 +#ifdef CONFIG_PAX_REFCOUNT
5922 + /* Exception on overflow. */
5923 + "1: dadd %0, %1 \n"
5924 + "2: \n"
5925 + _ASM_EXTABLE(1b, 2b)
5926 +#else
5927 + " daddu %0, %1 \n"
5928 +#endif
5929 + : "+r" (v->counter) : "Ir" (i));
5930 + raw_local_irq_restore(flags);
5931 + }
5932 +}
5933 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5934 {
5935 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5936 long temp;
5937 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5938 *
5939 * Atomically subtracts @i from @v.
5940 */
5941 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5942 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5943 +{
5944 + long temp;
5945 +
5946 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5947 + __asm__ __volatile__(
5948 + " .set mips3 \n"
5949 + "1: lld %0, %1 # atomic64_sub \n"
5950 +#ifdef CONFIG_PAX_REFCOUNT
5951 + /* Exception on overflow. */
5952 + "2: dsub %0, %2 \n"
5953 +#else
5954 + " dsubu %0, %2 \n"
5955 +#endif
5956 + " scd %0, %1 \n"
5957 + " beqzl %0, 1b \n"
5958 +#ifdef CONFIG_PAX_REFCOUNT
5959 + "3: \n"
5960 + _ASM_EXTABLE(2b, 3b)
5961 +#endif
5962 + " .set mips0 \n"
5963 + : "=&r" (temp), "+m" (v->counter)
5964 + : "Ir" (i));
5965 + } else if (kernel_uses_llsc) {
5966 + __asm__ __volatile__(
5967 + " .set mips3 \n"
5968 + "1: lld %0, %1 # atomic64_sub \n"
5969 +#ifdef CONFIG_PAX_REFCOUNT
5970 + /* Exception on overflow. */
5971 + "2: dsub %0, %2 \n"
5972 +#else
5973 + " dsubu %0, %2 \n"
5974 +#endif
5975 + " scd %0, %1 \n"
5976 + " beqz %0, 1b \n"
5977 +#ifdef CONFIG_PAX_REFCOUNT
5978 + "3: \n"
5979 + _ASM_EXTABLE(2b, 3b)
5980 +#endif
5981 + " .set mips0 \n"
5982 + : "=&r" (temp), "+m" (v->counter)
5983 + : "Ir" (i));
5984 + } else {
5985 + unsigned long flags;
5986 +
5987 + raw_local_irq_save(flags);
5988 + __asm__ __volatile__(
5989 +#ifdef CONFIG_PAX_REFCOUNT
5990 + /* Exception on overflow. */
5991 + "1: dsub %0, %1 \n"
5992 + "2: \n"
5993 + _ASM_EXTABLE(1b, 2b)
5994 +#else
5995 + " dsubu %0, %1 \n"
5996 +#endif
5997 + : "+r" (v->counter) : "Ir" (i));
5998 + raw_local_irq_restore(flags);
5999 + }
6000 +}
6001 +
6002 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6003 {
6004 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6005 long temp;
6006 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6007 /*
6008 * Same as above, but return the result value
6009 */
6010 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6011 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6012 +{
6013 + long result;
6014 + long temp;
6015 +
6016 + smp_mb__before_llsc();
6017 +
6018 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6019 + __asm__ __volatile__(
6020 + " .set mips3 \n"
6021 + "1: lld %1, %2 # atomic64_add_return \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + "2: dadd %0, %1, %3 \n"
6024 +#else
6025 + " daddu %0, %1, %3 \n"
6026 +#endif
6027 + " scd %0, %2 \n"
6028 + " beqzl %0, 1b \n"
6029 +#ifdef CONFIG_PAX_REFCOUNT
6030 + " b 4f \n"
6031 + " .set noreorder \n"
6032 + "3: b 5f \n"
6033 + " move %0, %1 \n"
6034 + " .set reorder \n"
6035 + _ASM_EXTABLE(2b, 3b)
6036 +#endif
6037 + "4: daddu %0, %1, %3 \n"
6038 +#ifdef CONFIG_PAX_REFCOUNT
6039 + "5: \n"
6040 +#endif
6041 + " .set mips0 \n"
6042 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6043 + : "Ir" (i));
6044 + } else if (kernel_uses_llsc) {
6045 + __asm__ __volatile__(
6046 + " .set mips3 \n"
6047 + "1: lld %1, %2 # atomic64_add_return \n"
6048 +#ifdef CONFIG_PAX_REFCOUNT
6049 + "2: dadd %0, %1, %3 \n"
6050 +#else
6051 + " daddu %0, %1, %3 \n"
6052 +#endif
6053 + " scd %0, %2 \n"
6054 + " bnez %0, 4f \n"
6055 + " b 1b \n"
6056 +#ifdef CONFIG_PAX_REFCOUNT
6057 + " .set noreorder \n"
6058 + "3: b 5f \n"
6059 + " move %0, %1 \n"
6060 + " .set reorder \n"
6061 + _ASM_EXTABLE(2b, 3b)
6062 +#endif
6063 + "4: daddu %0, %1, %3 \n"
6064 +#ifdef CONFIG_PAX_REFCOUNT
6065 + "5: \n"
6066 +#endif
6067 + " .set mips0 \n"
6068 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6069 + : "Ir" (i), "m" (v->counter)
6070 + : "memory");
6071 + } else {
6072 + unsigned long flags;
6073 +
6074 + raw_local_irq_save(flags);
6075 + __asm__ __volatile__(
6076 + " ld %0, %1 \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + /* Exception on overflow. */
6079 + "1: dadd %0, %2 \n"
6080 +#else
6081 + " daddu %0, %2 \n"
6082 +#endif
6083 + " sd %0, %1 \n"
6084 +#ifdef CONFIG_PAX_REFCOUNT
6085 + /* Note: Dest reg is not modified on overflow */
6086 + "2: \n"
6087 + _ASM_EXTABLE(1b, 2b)
6088 +#endif
6089 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6090 + raw_local_irq_restore(flags);
6091 + }
6092 +
6093 + smp_llsc_mb();
6094 +
6095 + return result;
6096 +}
6097 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6098 {
6099 long result;
6100
6101 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6102 return result;
6103 }
6104
6105 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6106 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6107 +{
6108 + long result;
6109 + long temp;
6110 +
6111 + smp_mb__before_llsc();
6112 +
6113 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6114 + long temp;
6115 +
6116 + __asm__ __volatile__(
6117 + " .set mips3 \n"
6118 + "1: lld %1, %2 # atomic64_sub_return \n"
6119 +#ifdef CONFIG_PAX_REFCOUNT
6120 + "2: dsub %0, %1, %3 \n"
6121 +#else
6122 + " dsubu %0, %1, %3 \n"
6123 +#endif
6124 + " scd %0, %2 \n"
6125 + " beqzl %0, 1b \n"
6126 +#ifdef CONFIG_PAX_REFCOUNT
6127 + " b 4f \n"
6128 + " .set noreorder \n"
6129 + "3: b 5f \n"
6130 + " move %0, %1 \n"
6131 + " .set reorder \n"
6132 + _ASM_EXTABLE(2b, 3b)
6133 +#endif
6134 + "4: dsubu %0, %1, %3 \n"
6135 +#ifdef CONFIG_PAX_REFCOUNT
6136 + "5: \n"
6137 +#endif
6138 + " .set mips0 \n"
6139 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6140 + : "Ir" (i), "m" (v->counter)
6141 + : "memory");
6142 + } else if (kernel_uses_llsc) {
6143 + __asm__ __volatile__(
6144 + " .set mips3 \n"
6145 + "1: lld %1, %2 # atomic64_sub_return \n"
6146 +#ifdef CONFIG_PAX_REFCOUNT
6147 + "2: dsub %0, %1, %3 \n"
6148 +#else
6149 + " dsubu %0, %1, %3 \n"
6150 +#endif
6151 + " scd %0, %2 \n"
6152 + " bnez %0, 4f \n"
6153 + " b 1b \n"
6154 +#ifdef CONFIG_PAX_REFCOUNT
6155 + " .set noreorder \n"
6156 + "3: b 5f \n"
6157 + " move %0, %1 \n"
6158 + " .set reorder \n"
6159 + _ASM_EXTABLE(2b, 3b)
6160 +#endif
6161 + "4: dsubu %0, %1, %3 \n"
6162 +#ifdef CONFIG_PAX_REFCOUNT
6163 + "5: \n"
6164 +#endif
6165 + " .set mips0 \n"
6166 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6167 + : "Ir" (i), "m" (v->counter)
6168 + : "memory");
6169 + } else {
6170 + unsigned long flags;
6171 +
6172 + raw_local_irq_save(flags);
6173 + __asm__ __volatile__(
6174 + " ld %0, %1 \n"
6175 +#ifdef CONFIG_PAX_REFCOUNT
6176 + /* Exception on overflow. */
6177 + "1: dsub %0, %2 \n"
6178 +#else
6179 + " dsubu %0, %2 \n"
6180 +#endif
6181 + " sd %0, %1 \n"
6182 +#ifdef CONFIG_PAX_REFCOUNT
6183 + /* Note: Dest reg is not modified on overflow */
6184 + "2: \n"
6185 + _ASM_EXTABLE(1b, 2b)
6186 +#endif
6187 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6188 + raw_local_irq_restore(flags);
6189 + }
6190 +
6191 + smp_llsc_mb();
6192 +
6193 + return result;
6194 +}
6195 +
6196 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6197 {
6198 long result;
6199
6200 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6201 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6202 * The function returns the old value of @v minus @i.
6203 */
6204 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6205 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6206 {
6207 long result;
6208
6209 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6210 return result;
6211 }
6212
6213 -#define atomic64_cmpxchg(v, o, n) \
6214 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6215 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6216 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6217 +{
6218 + return cmpxchg(&v->counter, old, new);
6219 +}
6220 +
6221 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6222 + long new)
6223 +{
6224 + return cmpxchg(&(v->counter), old, new);
6225 +}
6226 +
6227 +static inline long atomic64_xchg(atomic64_t *v, long new)
6228 +{
6229 + return xchg(&v->counter, new);
6230 +}
6231 +
6232 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6233 +{
6234 + return xchg(&(v->counter), new);
6235 +}
6236
6237 /**
6238 * atomic64_add_unless - add unless the number is a given value
6239 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240
6241 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6242 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6243 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_sub_and_test - subtract value from variable and test result
6247 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6248 * other cases.
6249 */
6250 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6251 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6252
6253 /*
6254 * atomic64_dec_and_test - decrement by 1 and test
6255 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6256 * Atomically increments @v by 1.
6257 */
6258 #define atomic64_inc(v) atomic64_add(1, (v))
6259 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6260
6261 /*
6262 * atomic64_dec - decrement and test
6263 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6264 * Atomically decrements @v by 1.
6265 */
6266 #define atomic64_dec(v) atomic64_sub(1, (v))
6267 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6268
6269 /*
6270 * atomic64_add_negative - add and test if negative
6271 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6272 index b4db69f..8f3b093 100644
6273 --- a/arch/mips/include/asm/cache.h
6274 +++ b/arch/mips/include/asm/cache.h
6275 @@ -9,10 +9,11 @@
6276 #ifndef _ASM_CACHE_H
6277 #define _ASM_CACHE_H
6278
6279 +#include <linux/const.h>
6280 #include <kmalloc.h>
6281
6282 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6283 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6284 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6285
6286 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6287 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6288 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6289 index cf3ae24..238d22f 100644
6290 --- a/arch/mips/include/asm/elf.h
6291 +++ b/arch/mips/include/asm/elf.h
6292 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6293 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6294 #endif
6295
6296 +#ifdef CONFIG_PAX_ASLR
6297 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6298 +
6299 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6300 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6301 +#endif
6302 +
6303 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6304 struct linux_binprm;
6305 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6306 int uses_interp);
6307
6308 -struct mm_struct;
6309 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6310 -#define arch_randomize_brk arch_randomize_brk
6311 -
6312 #endif /* _ASM_ELF_H */
6313 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6314 index c1f6afa..38cc6e9 100644
6315 --- a/arch/mips/include/asm/exec.h
6316 +++ b/arch/mips/include/asm/exec.h
6317 @@ -12,6 +12,6 @@
6318 #ifndef _ASM_EXEC_H
6319 #define _ASM_EXEC_H
6320
6321 -extern unsigned long arch_align_stack(unsigned long sp);
6322 +#define arch_align_stack(x) ((x) & ~0xfUL)
6323
6324 #endif /* _ASM_EXEC_H */
6325 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6326 index d44622c..64990d2 100644
6327 --- a/arch/mips/include/asm/local.h
6328 +++ b/arch/mips/include/asm/local.h
6329 @@ -12,15 +12,25 @@ typedef struct
6330 atomic_long_t a;
6331 } local_t;
6332
6333 +typedef struct {
6334 + atomic_long_unchecked_t a;
6335 +} local_unchecked_t;
6336 +
6337 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6338
6339 #define local_read(l) atomic_long_read(&(l)->a)
6340 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6341 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6342 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6343
6344 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6345 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6346 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6347 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6348 #define local_inc(l) atomic_long_inc(&(l)->a)
6349 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6350 #define local_dec(l) atomic_long_dec(&(l)->a)
6351 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6352
6353 /*
6354 * Same as above, but return the result value
6355 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6356 return result;
6357 }
6358
6359 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6360 +{
6361 + unsigned long result;
6362 +
6363 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6364 + unsigned long temp;
6365 +
6366 + __asm__ __volatile__(
6367 + " .set mips3 \n"
6368 + "1:" __LL "%1, %2 # local_add_return \n"
6369 + " addu %0, %1, %3 \n"
6370 + __SC "%0, %2 \n"
6371 + " beqzl %0, 1b \n"
6372 + " addu %0, %1, %3 \n"
6373 + " .set mips0 \n"
6374 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6375 + : "Ir" (i), "m" (l->a.counter)
6376 + : "memory");
6377 + } else if (kernel_uses_llsc) {
6378 + unsigned long temp;
6379 +
6380 + __asm__ __volatile__(
6381 + " .set mips3 \n"
6382 + "1:" __LL "%1, %2 # local_add_return \n"
6383 + " addu %0, %1, %3 \n"
6384 + __SC "%0, %2 \n"
6385 + " beqz %0, 1b \n"
6386 + " addu %0, %1, %3 \n"
6387 + " .set mips0 \n"
6388 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6389 + : "Ir" (i), "m" (l->a.counter)
6390 + : "memory");
6391 + } else {
6392 + unsigned long flags;
6393 +
6394 + local_irq_save(flags);
6395 + result = l->a.counter;
6396 + result += i;
6397 + l->a.counter = result;
6398 + local_irq_restore(flags);
6399 + }
6400 +
6401 + return result;
6402 +}
6403 +
6404 static __inline__ long local_sub_return(long i, local_t * l)
6405 {
6406 unsigned long result;
6407 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6408
6409 #define local_cmpxchg(l, o, n) \
6410 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6411 +#define local_cmpxchg_unchecked(l, o, n) \
6412 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6413 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6414
6415 /**
6416 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6417 index f6be474..12ad554 100644
6418 --- a/arch/mips/include/asm/page.h
6419 +++ b/arch/mips/include/asm/page.h
6420 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6421 #ifdef CONFIG_CPU_MIPS32
6422 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6423 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6424 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6425 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6426 #else
6427 typedef struct { unsigned long long pte; } pte_t;
6428 #define pte_val(x) ((x).pte)
6429 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6430 index 881d18b..cea38bc 100644
6431 --- a/arch/mips/include/asm/pgalloc.h
6432 +++ b/arch/mips/include/asm/pgalloc.h
6433 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6434 {
6435 set_pud(pud, __pud((unsigned long)pmd));
6436 }
6437 +
6438 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6439 +{
6440 + pud_populate(mm, pud, pmd);
6441 +}
6442 #endif
6443
6444 /*
6445 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6446 index 25da651..ae2a259 100644
6447 --- a/arch/mips/include/asm/smtc_proc.h
6448 +++ b/arch/mips/include/asm/smtc_proc.h
6449 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6450
6451 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6452
6453 -extern atomic_t smtc_fpu_recoveries;
6454 +extern atomic_unchecked_t smtc_fpu_recoveries;
6455
6456 #endif /* __ASM_SMTC_PROC_H */
6457 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6458 index 61215a3..213ee0e 100644
6459 --- a/arch/mips/include/asm/thread_info.h
6460 +++ b/arch/mips/include/asm/thread_info.h
6461 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6462 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6463 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6464 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6465 +/* li takes a 32bit immediate */
6466 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6467 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6468
6469 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6470 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6471 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6472 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6473 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6474 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6475
6476 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6477 - _TIF_SYSCALL_AUDIT)
6478 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6479
6480 /* work to do in syscall_trace_leave() */
6481 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6482 - _TIF_SYSCALL_AUDIT)
6483 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6484
6485 /* work to do on interrupt/exception return */
6486 #define _TIF_WORK_MASK \
6487 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6488 /* work to do on any return to u-space */
6489 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6490 - _TIF_WORK_SYSCALL_EXIT)
6491 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6492
6493 #endif /* __KERNEL__ */
6494
6495 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6496 index 1188e00..41cf144 100644
6497 --- a/arch/mips/kernel/binfmt_elfn32.c
6498 +++ b/arch/mips/kernel/binfmt_elfn32.c
6499 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6500 #undef ELF_ET_DYN_BASE
6501 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6502
6503 +#ifdef CONFIG_PAX_ASLR
6504 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6505 +
6506 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6507 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6508 +#endif
6509 +
6510 #include <asm/processor.h>
6511 #include <linux/module.h>
6512 #include <linux/elfcore.h>
6513 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6514 index 202e581..689ca79 100644
6515 --- a/arch/mips/kernel/binfmt_elfo32.c
6516 +++ b/arch/mips/kernel/binfmt_elfo32.c
6517 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6518 #undef ELF_ET_DYN_BASE
6519 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6520
6521 +#ifdef CONFIG_PAX_ASLR
6522 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6523 +
6524 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6525 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6526 +#endif
6527 +
6528 #include <asm/processor.h>
6529
6530 /*
6531 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6532 index d1fea7a..45602ea 100644
6533 --- a/arch/mips/kernel/irq.c
6534 +++ b/arch/mips/kernel/irq.c
6535 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6536 printk("unexpected IRQ # %d\n", irq);
6537 }
6538
6539 -atomic_t irq_err_count;
6540 +atomic_unchecked_t irq_err_count;
6541
6542 int arch_show_interrupts(struct seq_file *p, int prec)
6543 {
6544 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6545 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6546 return 0;
6547 }
6548
6549 asmlinkage void spurious_interrupt(void)
6550 {
6551 - atomic_inc(&irq_err_count);
6552 + atomic_inc_unchecked(&irq_err_count);
6553 }
6554
6555 void __init init_IRQ(void)
6556 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6557 index ddc7610..8c58f17 100644
6558 --- a/arch/mips/kernel/process.c
6559 +++ b/arch/mips/kernel/process.c
6560 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6561 out:
6562 return pc;
6563 }
6564 -
6565 -/*
6566 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6567 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6568 - */
6569 -unsigned long arch_align_stack(unsigned long sp)
6570 -{
6571 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6572 - sp -= get_random_int() & ~PAGE_MASK;
6573 -
6574 - return sp & ALMASK;
6575 -}
6576 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6577 index 8ae1ebe..1bcbf47 100644
6578 --- a/arch/mips/kernel/ptrace.c
6579 +++ b/arch/mips/kernel/ptrace.c
6580 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6581 return arch;
6582 }
6583
6584 +#ifdef CONFIG_GRKERNSEC_SETXID
6585 +extern void gr_delayed_cred_worker(void);
6586 +#endif
6587 +
6588 /*
6589 * Notification of system call entry/exit
6590 * - triggered by current->work.syscall_trace
6591 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6592 /* do the secure computing check first */
6593 secure_computing_strict(regs->regs[2]);
6594
6595 +#ifdef CONFIG_GRKERNSEC_SETXID
6596 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6597 + gr_delayed_cred_worker();
6598 +#endif
6599 +
6600 if (!(current->ptrace & PT_PTRACED))
6601 goto out;
6602
6603 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6604 index c10aa84..9ec2e60 100644
6605 --- a/arch/mips/kernel/smtc-proc.c
6606 +++ b/arch/mips/kernel/smtc-proc.c
6607 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6608
6609 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6610
6611 -atomic_t smtc_fpu_recoveries;
6612 +atomic_unchecked_t smtc_fpu_recoveries;
6613
6614 static int smtc_proc_show(struct seq_file *m, void *v)
6615 {
6616 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6617 for(i = 0; i < NR_CPUS; i++)
6618 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6619 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6620 - atomic_read(&smtc_fpu_recoveries));
6621 + atomic_read_unchecked(&smtc_fpu_recoveries));
6622 return 0;
6623 }
6624
6625 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6626 smtc_cpu_stats[i].selfipis = 0;
6627 }
6628
6629 - atomic_set(&smtc_fpu_recoveries, 0);
6630 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6631
6632 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6633 }
6634 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6635 index dfc1b91..11a2c07 100644
6636 --- a/arch/mips/kernel/smtc.c
6637 +++ b/arch/mips/kernel/smtc.c
6638 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6639 }
6640 smtc_ipi_qdump();
6641 printk("%d Recoveries of \"stolen\" FPU\n",
6642 - atomic_read(&smtc_fpu_recoveries));
6643 + atomic_read_unchecked(&smtc_fpu_recoveries));
6644 }
6645
6646
6647 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6648 index 84536bf..79caa4d 100644
6649 --- a/arch/mips/kernel/sync-r4k.c
6650 +++ b/arch/mips/kernel/sync-r4k.c
6651 @@ -21,8 +21,8 @@
6652 #include <asm/mipsregs.h>
6653
6654 static atomic_t count_start_flag = ATOMIC_INIT(0);
6655 -static atomic_t count_count_start = ATOMIC_INIT(0);
6656 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6657 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6658 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6659 static atomic_t count_reference = ATOMIC_INIT(0);
6660
6661 #define COUNTON 100
6662 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6663
6664 for (i = 0; i < NR_LOOPS; i++) {
6665 /* slaves loop on '!= 2' */
6666 - while (atomic_read(&count_count_start) != 1)
6667 + while (atomic_read_unchecked(&count_count_start) != 1)
6668 mb();
6669 - atomic_set(&count_count_stop, 0);
6670 + atomic_set_unchecked(&count_count_stop, 0);
6671 smp_wmb();
6672
6673 /* this lets the slaves write their count register */
6674 - atomic_inc(&count_count_start);
6675 + atomic_inc_unchecked(&count_count_start);
6676
6677 /*
6678 * Everyone initialises count in the last loop:
6679 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6680 /*
6681 * Wait for all slaves to leave the synchronization point:
6682 */
6683 - while (atomic_read(&count_count_stop) != 1)
6684 + while (atomic_read_unchecked(&count_count_stop) != 1)
6685 mb();
6686 - atomic_set(&count_count_start, 0);
6687 + atomic_set_unchecked(&count_count_start, 0);
6688 smp_wmb();
6689 - atomic_inc(&count_count_stop);
6690 + atomic_inc_unchecked(&count_count_stop);
6691 }
6692 /* Arrange for an interrupt in a short while */
6693 write_c0_compare(read_c0_count() + COUNTON);
6694 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6695 initcount = atomic_read(&count_reference);
6696
6697 for (i = 0; i < NR_LOOPS; i++) {
6698 - atomic_inc(&count_count_start);
6699 - while (atomic_read(&count_count_start) != 2)
6700 + atomic_inc_unchecked(&count_count_start);
6701 + while (atomic_read_unchecked(&count_count_start) != 2)
6702 mb();
6703
6704 /*
6705 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6706 if (i == NR_LOOPS-1)
6707 write_c0_count(initcount);
6708
6709 - atomic_inc(&count_count_stop);
6710 - while (atomic_read(&count_count_stop) != 2)
6711 + atomic_inc_unchecked(&count_count_stop);
6712 + while (atomic_read_unchecked(&count_count_stop) != 2)
6713 mb();
6714 }
6715 /* Arrange for an interrupt in a short while */
6716 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6717 index aec3408..74d79d3 100644
6718 --- a/arch/mips/kernel/traps.c
6719 +++ b/arch/mips/kernel/traps.c
6720 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6721 siginfo_t info;
6722
6723 prev_state = exception_enter();
6724 - die_if_kernel("Integer overflow", regs);
6725 + if (unlikely(!user_mode(regs))) {
6726 +
6727 +#ifdef CONFIG_PAX_REFCOUNT
6728 + if (fixup_exception(regs)) {
6729 + pax_report_refcount_overflow(regs);
6730 + exception_exit(prev_state);
6731 + return;
6732 + }
6733 +#endif
6734 +
6735 + die("Integer overflow", regs);
6736 + }
6737
6738 info.si_code = FPE_INTOVF;
6739 info.si_signo = SIGFPE;
6740 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6741 index 85df1cd..4f0a4de 100644
6742 --- a/arch/mips/mm/fault.c
6743 +++ b/arch/mips/mm/fault.c
6744 @@ -28,6 +28,23 @@
6745 #include <asm/highmem.h> /* For VMALLOC_END */
6746 #include <linux/kdebug.h>
6747
6748 +#ifdef CONFIG_PAX_PAGEEXEC
6749 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6750 +{
6751 + unsigned long i;
6752 +
6753 + printk(KERN_ERR "PAX: bytes at PC: ");
6754 + for (i = 0; i < 5; i++) {
6755 + unsigned int c;
6756 + if (get_user(c, (unsigned int *)pc+i))
6757 + printk(KERN_CONT "???????? ");
6758 + else
6759 + printk(KERN_CONT "%08x ", c);
6760 + }
6761 + printk("\n");
6762 +}
6763 +#endif
6764 +
6765 /*
6766 * This routine handles page faults. It determines the address,
6767 * and the problem, and then passes it off to one of the appropriate
6768 @@ -197,6 +214,14 @@ bad_area:
6769 bad_area_nosemaphore:
6770 /* User mode accesses just cause a SIGSEGV */
6771 if (user_mode(regs)) {
6772 +
6773 +#ifdef CONFIG_PAX_PAGEEXEC
6774 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6775 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6776 + do_group_exit(SIGKILL);
6777 + }
6778 +#endif
6779 +
6780 tsk->thread.cp0_badvaddr = address;
6781 tsk->thread.error_code = write;
6782 #if 0
6783 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6784 index f1baadd..8537544 100644
6785 --- a/arch/mips/mm/mmap.c
6786 +++ b/arch/mips/mm/mmap.c
6787 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6788 struct vm_area_struct *vma;
6789 unsigned long addr = addr0;
6790 int do_color_align;
6791 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6792 struct vm_unmapped_area_info info;
6793
6794 if (unlikely(len > TASK_SIZE))
6795 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6796 do_color_align = 1;
6797
6798 /* requesting a specific address */
6799 +
6800 +#ifdef CONFIG_PAX_RANDMMAP
6801 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6802 +#endif
6803 +
6804 if (addr) {
6805 if (do_color_align)
6806 addr = COLOUR_ALIGN(addr, pgoff);
6807 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6808 addr = PAGE_ALIGN(addr);
6809
6810 vma = find_vma(mm, addr);
6811 - if (TASK_SIZE - len >= addr &&
6812 - (!vma || addr + len <= vma->vm_start))
6813 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6814 return addr;
6815 }
6816
6817 info.length = len;
6818 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6819 info.align_offset = pgoff << PAGE_SHIFT;
6820 + info.threadstack_offset = offset;
6821
6822 if (dir == DOWN) {
6823 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6824 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6825 {
6826 unsigned long random_factor = 0UL;
6827
6828 +#ifdef CONFIG_PAX_RANDMMAP
6829 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6830 +#endif
6831 +
6832 if (current->flags & PF_RANDOMIZE) {
6833 random_factor = get_random_int();
6834 random_factor = random_factor << PAGE_SHIFT;
6835 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6836
6837 if (mmap_is_legacy()) {
6838 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6839 +
6840 +#ifdef CONFIG_PAX_RANDMMAP
6841 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6842 + mm->mmap_base += mm->delta_mmap;
6843 +#endif
6844 +
6845 mm->get_unmapped_area = arch_get_unmapped_area;
6846 } else {
6847 mm->mmap_base = mmap_base(random_factor);
6848 +
6849 +#ifdef CONFIG_PAX_RANDMMAP
6850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6851 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6852 +#endif
6853 +
6854 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6855 }
6856 }
6857
6858 -static inline unsigned long brk_rnd(void)
6859 -{
6860 - unsigned long rnd = get_random_int();
6861 -
6862 - rnd = rnd << PAGE_SHIFT;
6863 - /* 8MB for 32bit, 256MB for 64bit */
6864 - if (TASK_IS_32BIT_ADDR)
6865 - rnd = rnd & 0x7ffffful;
6866 - else
6867 - rnd = rnd & 0xffffffful;
6868 -
6869 - return rnd;
6870 -}
6871 -
6872 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6873 -{
6874 - unsigned long base = mm->brk;
6875 - unsigned long ret;
6876 -
6877 - ret = PAGE_ALIGN(base + brk_rnd());
6878 -
6879 - if (ret < mm->brk)
6880 - return mm->brk;
6881 -
6882 - return ret;
6883 -}
6884 -
6885 int __virt_addr_valid(const volatile void *kaddr)
6886 {
6887 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6888 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6889 index a2358b4..7cead4f 100644
6890 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6891 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6892 @@ -187,9 +187,9 @@ void
6893 cont_nmi_dump(void)
6894 {
6895 #ifndef REAL_NMI_SIGNAL
6896 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6897 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6898
6899 - atomic_inc(&nmied_cpus);
6900 + atomic_inc_unchecked(&nmied_cpus);
6901 #endif
6902 /*
6903 * Only allow 1 cpu to proceed
6904 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6905 udelay(10000);
6906 }
6907 #else
6908 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6909 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6910 #endif
6911
6912 /*
6913 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6914 index 967d144..db12197 100644
6915 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6916 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6917 @@ -11,12 +11,14 @@
6918 #ifndef _ASM_PROC_CACHE_H
6919 #define _ASM_PROC_CACHE_H
6920
6921 +#include <linux/const.h>
6922 +
6923 /* L1 cache */
6924
6925 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6926 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6927 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6928 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6929 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6930 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6931
6932 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6933 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6934 index bcb5df2..84fabd2 100644
6935 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6936 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6937 @@ -16,13 +16,15 @@
6938 #ifndef _ASM_PROC_CACHE_H
6939 #define _ASM_PROC_CACHE_H
6940
6941 +#include <linux/const.h>
6942 +
6943 /*
6944 * L1 cache
6945 */
6946 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6947 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6948 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6949 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6950 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6951 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6952
6953 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6954 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6955 index 4ce7a01..449202a 100644
6956 --- a/arch/openrisc/include/asm/cache.h
6957 +++ b/arch/openrisc/include/asm/cache.h
6958 @@ -19,11 +19,13 @@
6959 #ifndef __ASM_OPENRISC_CACHE_H
6960 #define __ASM_OPENRISC_CACHE_H
6961
6962 +#include <linux/const.h>
6963 +
6964 /* FIXME: How can we replace these with values from the CPU...
6965 * they shouldn't be hard-coded!
6966 */
6967
6968 -#define L1_CACHE_BYTES 16
6969 #define L1_CACHE_SHIFT 4
6970 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6971
6972 #endif /* __ASM_OPENRISC_CACHE_H */
6973 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6974 index 472886c..00e7df9 100644
6975 --- a/arch/parisc/include/asm/atomic.h
6976 +++ b/arch/parisc/include/asm/atomic.h
6977 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6978 return dec;
6979 }
6980
6981 +#define atomic64_read_unchecked(v) atomic64_read(v)
6982 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6983 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6984 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6985 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6986 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6987 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6988 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6989 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6990 +
6991 #endif /* !CONFIG_64BIT */
6992
6993
6994 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6995 index 47f11c7..3420df2 100644
6996 --- a/arch/parisc/include/asm/cache.h
6997 +++ b/arch/parisc/include/asm/cache.h
6998 @@ -5,6 +5,7 @@
6999 #ifndef __ARCH_PARISC_CACHE_H
7000 #define __ARCH_PARISC_CACHE_H
7001
7002 +#include <linux/const.h>
7003
7004 /*
7005 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7006 @@ -15,13 +16,13 @@
7007 * just ruin performance.
7008 */
7009 #ifdef CONFIG_PA20
7010 -#define L1_CACHE_BYTES 64
7011 #define L1_CACHE_SHIFT 6
7012 #else
7013 -#define L1_CACHE_BYTES 32
7014 #define L1_CACHE_SHIFT 5
7015 #endif
7016
7017 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7018 +
7019 #ifndef __ASSEMBLY__
7020
7021 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7022 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7023 index ad2b503..bdf1651 100644
7024 --- a/arch/parisc/include/asm/elf.h
7025 +++ b/arch/parisc/include/asm/elf.h
7026 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7027
7028 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7029
7030 +#ifdef CONFIG_PAX_ASLR
7031 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7032 +
7033 +#define PAX_DELTA_MMAP_LEN 16
7034 +#define PAX_DELTA_STACK_LEN 16
7035 +#endif
7036 +
7037 /* This yields a mask that user programs can use to figure out what
7038 instruction set this CPU supports. This could be done in user space,
7039 but it's not easy, and we've already done it here. */
7040 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7041 index fc987a1..6e068ef 100644
7042 --- a/arch/parisc/include/asm/pgalloc.h
7043 +++ b/arch/parisc/include/asm/pgalloc.h
7044 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7045 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7046 }
7047
7048 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7049 +{
7050 + pgd_populate(mm, pgd, pmd);
7051 +}
7052 +
7053 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7054 {
7055 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7056 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7057 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7058 #define pmd_free(mm, x) do { } while (0)
7059 #define pgd_populate(mm, pmd, pte) BUG()
7060 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7061
7062 #endif
7063
7064 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7065 index 34899b5..02dd060 100644
7066 --- a/arch/parisc/include/asm/pgtable.h
7067 +++ b/arch/parisc/include/asm/pgtable.h
7068 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7069 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7070 #define PAGE_COPY PAGE_EXECREAD
7071 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7072 +
7073 +#ifdef CONFIG_PAX_PAGEEXEC
7074 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7075 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7076 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7077 +#else
7078 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7079 +# define PAGE_COPY_NOEXEC PAGE_COPY
7080 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7081 +#endif
7082 +
7083 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7084 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7085 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7086 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7087 index e0a8235..ce2f1e1 100644
7088 --- a/arch/parisc/include/asm/uaccess.h
7089 +++ b/arch/parisc/include/asm/uaccess.h
7090 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7091 const void __user *from,
7092 unsigned long n)
7093 {
7094 - int sz = __compiletime_object_size(to);
7095 + size_t sz = __compiletime_object_size(to);
7096 int ret = -EFAULT;
7097
7098 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7099 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7100 ret = __copy_from_user(to, from, n);
7101 else
7102 copy_from_user_overflow();
7103 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7104 index 2a625fb..9908930 100644
7105 --- a/arch/parisc/kernel/module.c
7106 +++ b/arch/parisc/kernel/module.c
7107 @@ -98,16 +98,38 @@
7108
7109 /* three functions to determine where in the module core
7110 * or init pieces the location is */
7111 +static inline int in_init_rx(struct module *me, void *loc)
7112 +{
7113 + return (loc >= me->module_init_rx &&
7114 + loc < (me->module_init_rx + me->init_size_rx));
7115 +}
7116 +
7117 +static inline int in_init_rw(struct module *me, void *loc)
7118 +{
7119 + return (loc >= me->module_init_rw &&
7120 + loc < (me->module_init_rw + me->init_size_rw));
7121 +}
7122 +
7123 static inline int in_init(struct module *me, void *loc)
7124 {
7125 - return (loc >= me->module_init &&
7126 - loc <= (me->module_init + me->init_size));
7127 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7128 +}
7129 +
7130 +static inline int in_core_rx(struct module *me, void *loc)
7131 +{
7132 + return (loc >= me->module_core_rx &&
7133 + loc < (me->module_core_rx + me->core_size_rx));
7134 +}
7135 +
7136 +static inline int in_core_rw(struct module *me, void *loc)
7137 +{
7138 + return (loc >= me->module_core_rw &&
7139 + loc < (me->module_core_rw + me->core_size_rw));
7140 }
7141
7142 static inline int in_core(struct module *me, void *loc)
7143 {
7144 - return (loc >= me->module_core &&
7145 - loc <= (me->module_core + me->core_size));
7146 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7147 }
7148
7149 static inline int in_local(struct module *me, void *loc)
7150 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7151 }
7152
7153 /* align things a bit */
7154 - me->core_size = ALIGN(me->core_size, 16);
7155 - me->arch.got_offset = me->core_size;
7156 - me->core_size += gots * sizeof(struct got_entry);
7157 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7158 + me->arch.got_offset = me->core_size_rw;
7159 + me->core_size_rw += gots * sizeof(struct got_entry);
7160
7161 - me->core_size = ALIGN(me->core_size, 16);
7162 - me->arch.fdesc_offset = me->core_size;
7163 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7164 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7165 + me->arch.fdesc_offset = me->core_size_rw;
7166 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7167
7168 me->arch.got_max = gots;
7169 me->arch.fdesc_max = fdescs;
7170 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7171
7172 BUG_ON(value == 0);
7173
7174 - got = me->module_core + me->arch.got_offset;
7175 + got = me->module_core_rw + me->arch.got_offset;
7176 for (i = 0; got[i].addr; i++)
7177 if (got[i].addr == value)
7178 goto out;
7179 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7180 #ifdef CONFIG_64BIT
7181 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7182 {
7183 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7184 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7185
7186 if (!value) {
7187 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7188 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7189
7190 /* Create new one */
7191 fdesc->addr = value;
7192 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7193 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7194 return (Elf_Addr)fdesc;
7195 }
7196 #endif /* CONFIG_64BIT */
7197 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7198
7199 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7200 end = table + sechdrs[me->arch.unwind_section].sh_size;
7201 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7202 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7203
7204 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7205 me->arch.unwind_section, table, end, gp);
7206 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7207 index 5dfd248..64914ac 100644
7208 --- a/arch/parisc/kernel/sys_parisc.c
7209 +++ b/arch/parisc/kernel/sys_parisc.c
7210 @@ -33,9 +33,11 @@
7211 #include <linux/utsname.h>
7212 #include <linux/personality.h>
7213
7214 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7215 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7216 + unsigned long flags)
7217 {
7218 struct vm_unmapped_area_info info;
7219 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7220
7221 info.flags = 0;
7222 info.length = len;
7223 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7224 info.high_limit = TASK_SIZE;
7225 info.align_mask = 0;
7226 info.align_offset = 0;
7227 + info.threadstack_offset = offset;
7228 return vm_unmapped_area(&info);
7229 }
7230
7231 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7232 return (unsigned long) mapping >> 8;
7233 }
7234
7235 -static unsigned long get_shared_area(struct address_space *mapping,
7236 - unsigned long addr, unsigned long len, unsigned long pgoff)
7237 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7238 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7239 {
7240 struct vm_unmapped_area_info info;
7241 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7242
7243 info.flags = 0;
7244 info.length = len;
7245 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7246 info.high_limit = TASK_SIZE;
7247 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7248 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7249 + info.threadstack_offset = offset;
7250 return vm_unmapped_area(&info);
7251 }
7252
7253 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7254 return -EINVAL;
7255 return addr;
7256 }
7257 - if (!addr)
7258 + if (!addr) {
7259 addr = TASK_UNMAPPED_BASE;
7260
7261 +#ifdef CONFIG_PAX_RANDMMAP
7262 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7263 + addr += current->mm->delta_mmap;
7264 +#endif
7265 +
7266 + }
7267 +
7268 if (filp) {
7269 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7270 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7271 } else if(flags & MAP_SHARED) {
7272 - addr = get_shared_area(NULL, addr, len, pgoff);
7273 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7274 } else {
7275 - addr = get_unshared_area(addr, len);
7276 + addr = get_unshared_area(filp, addr, len, flags);
7277 }
7278 return addr;
7279 }
7280 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7281 index b3f87a3..5d5d03d 100644
7282 --- a/arch/parisc/kernel/traps.c
7283 +++ b/arch/parisc/kernel/traps.c
7284 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7285
7286 down_read(&current->mm->mmap_sem);
7287 vma = find_vma(current->mm,regs->iaoq[0]);
7288 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7289 - && (vma->vm_flags & VM_EXEC)) {
7290 -
7291 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7292 fault_address = regs->iaoq[0];
7293 fault_space = regs->iasq[0];
7294
7295 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7296 index f247a34..dc0f219 100644
7297 --- a/arch/parisc/mm/fault.c
7298 +++ b/arch/parisc/mm/fault.c
7299 @@ -15,6 +15,7 @@
7300 #include <linux/sched.h>
7301 #include <linux/interrupt.h>
7302 #include <linux/module.h>
7303 +#include <linux/unistd.h>
7304
7305 #include <asm/uaccess.h>
7306 #include <asm/traps.h>
7307 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7308 static unsigned long
7309 parisc_acctyp(unsigned long code, unsigned int inst)
7310 {
7311 - if (code == 6 || code == 16)
7312 + if (code == 6 || code == 7 || code == 16)
7313 return VM_EXEC;
7314
7315 switch (inst & 0xf0000000) {
7316 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7317 }
7318 #endif
7319
7320 +#ifdef CONFIG_PAX_PAGEEXEC
7321 +/*
7322 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7323 + *
7324 + * returns 1 when task should be killed
7325 + * 2 when rt_sigreturn trampoline was detected
7326 + * 3 when unpatched PLT trampoline was detected
7327 + */
7328 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7329 +{
7330 +
7331 +#ifdef CONFIG_PAX_EMUPLT
7332 + int err;
7333 +
7334 + do { /* PaX: unpatched PLT emulation */
7335 + unsigned int bl, depwi;
7336 +
7337 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7338 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7339 +
7340 + if (err)
7341 + break;
7342 +
7343 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7344 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7345 +
7346 + err = get_user(ldw, (unsigned int *)addr);
7347 + err |= get_user(bv, (unsigned int *)(addr+4));
7348 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7349 +
7350 + if (err)
7351 + break;
7352 +
7353 + if (ldw == 0x0E801096U &&
7354 + bv == 0xEAC0C000U &&
7355 + ldw2 == 0x0E881095U)
7356 + {
7357 + unsigned int resolver, map;
7358 +
7359 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7360 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7361 + if (err)
7362 + break;
7363 +
7364 + regs->gr[20] = instruction_pointer(regs)+8;
7365 + regs->gr[21] = map;
7366 + regs->gr[22] = resolver;
7367 + regs->iaoq[0] = resolver | 3UL;
7368 + regs->iaoq[1] = regs->iaoq[0] + 4;
7369 + return 3;
7370 + }
7371 + }
7372 + } while (0);
7373 +#endif
7374 +
7375 +#ifdef CONFIG_PAX_EMUTRAMP
7376 +
7377 +#ifndef CONFIG_PAX_EMUSIGRT
7378 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7379 + return 1;
7380 +#endif
7381 +
7382 + do { /* PaX: rt_sigreturn emulation */
7383 + unsigned int ldi1, ldi2, bel, nop;
7384 +
7385 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7386 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7387 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7388 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7389 +
7390 + if (err)
7391 + break;
7392 +
7393 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7394 + ldi2 == 0x3414015AU &&
7395 + bel == 0xE4008200U &&
7396 + nop == 0x08000240U)
7397 + {
7398 + regs->gr[25] = (ldi1 & 2) >> 1;
7399 + regs->gr[20] = __NR_rt_sigreturn;
7400 + regs->gr[31] = regs->iaoq[1] + 16;
7401 + regs->sr[0] = regs->iasq[1];
7402 + regs->iaoq[0] = 0x100UL;
7403 + regs->iaoq[1] = regs->iaoq[0] + 4;
7404 + regs->iasq[0] = regs->sr[2];
7405 + regs->iasq[1] = regs->sr[2];
7406 + return 2;
7407 + }
7408 + } while (0);
7409 +#endif
7410 +
7411 + return 1;
7412 +}
7413 +
7414 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7415 +{
7416 + unsigned long i;
7417 +
7418 + printk(KERN_ERR "PAX: bytes at PC: ");
7419 + for (i = 0; i < 5; i++) {
7420 + unsigned int c;
7421 + if (get_user(c, (unsigned int *)pc+i))
7422 + printk(KERN_CONT "???????? ");
7423 + else
7424 + printk(KERN_CONT "%08x ", c);
7425 + }
7426 + printk("\n");
7427 +}
7428 +#endif
7429 +
7430 int fixup_exception(struct pt_regs *regs)
7431 {
7432 const struct exception_table_entry *fix;
7433 @@ -194,8 +305,33 @@ good_area:
7434
7435 acc_type = parisc_acctyp(code,regs->iir);
7436
7437 - if ((vma->vm_flags & acc_type) != acc_type)
7438 + if ((vma->vm_flags & acc_type) != acc_type) {
7439 +
7440 +#ifdef CONFIG_PAX_PAGEEXEC
7441 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7442 + (address & ~3UL) == instruction_pointer(regs))
7443 + {
7444 + up_read(&mm->mmap_sem);
7445 + switch (pax_handle_fetch_fault(regs)) {
7446 +
7447 +#ifdef CONFIG_PAX_EMUPLT
7448 + case 3:
7449 + return;
7450 +#endif
7451 +
7452 +#ifdef CONFIG_PAX_EMUTRAMP
7453 + case 2:
7454 + return;
7455 +#endif
7456 +
7457 + }
7458 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7459 + do_group_exit(SIGKILL);
7460 + }
7461 +#endif
7462 +
7463 goto bad_area;
7464 + }
7465
7466 /*
7467 * If for any reason at all we couldn't handle the fault, make
7468 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7469 index e3b1d41..8e81edf 100644
7470 --- a/arch/powerpc/include/asm/atomic.h
7471 +++ b/arch/powerpc/include/asm/atomic.h
7472 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7473 return t1;
7474 }
7475
7476 +#define atomic64_read_unchecked(v) atomic64_read(v)
7477 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7478 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7479 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7480 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7481 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7482 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7483 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7484 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7485 +
7486 #endif /* __powerpc64__ */
7487
7488 #endif /* __KERNEL__ */
7489 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7490 index 9e495c9..b6878e5 100644
7491 --- a/arch/powerpc/include/asm/cache.h
7492 +++ b/arch/powerpc/include/asm/cache.h
7493 @@ -3,6 +3,7 @@
7494
7495 #ifdef __KERNEL__
7496
7497 +#include <linux/const.h>
7498
7499 /* bytes per L1 cache line */
7500 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7501 @@ -22,7 +23,7 @@
7502 #define L1_CACHE_SHIFT 7
7503 #endif
7504
7505 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7506 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7507
7508 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7509
7510 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7511 index cc0655a..13eac2e 100644
7512 --- a/arch/powerpc/include/asm/elf.h
7513 +++ b/arch/powerpc/include/asm/elf.h
7514 @@ -28,8 +28,19 @@
7515 the loader. We need to make sure that it is out of the way of the program
7516 that it will "exec", and that there is sufficient room for the brk. */
7517
7518 -extern unsigned long randomize_et_dyn(unsigned long base);
7519 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7520 +#define ELF_ET_DYN_BASE (0x20000000)
7521 +
7522 +#ifdef CONFIG_PAX_ASLR
7523 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7524 +
7525 +#ifdef __powerpc64__
7526 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7527 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7528 +#else
7529 +#define PAX_DELTA_MMAP_LEN 15
7530 +#define PAX_DELTA_STACK_LEN 15
7531 +#endif
7532 +#endif
7533
7534 /*
7535 * Our registers are always unsigned longs, whether we're a 32 bit
7536 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7537 (0x7ff >> (PAGE_SHIFT - 12)) : \
7538 (0x3ffff >> (PAGE_SHIFT - 12)))
7539
7540 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7541 -#define arch_randomize_brk arch_randomize_brk
7542 -
7543 -
7544 #ifdef CONFIG_SPU_BASE
7545 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7546 #define NT_SPU 1
7547 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7548 index 8196e9c..d83a9f3 100644
7549 --- a/arch/powerpc/include/asm/exec.h
7550 +++ b/arch/powerpc/include/asm/exec.h
7551 @@ -4,6 +4,6 @@
7552 #ifndef _ASM_POWERPC_EXEC_H
7553 #define _ASM_POWERPC_EXEC_H
7554
7555 -extern unsigned long arch_align_stack(unsigned long sp);
7556 +#define arch_align_stack(x) ((x) & ~0xfUL)
7557
7558 #endif /* _ASM_POWERPC_EXEC_H */
7559 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7560 index 5acabbd..7ea14fa 100644
7561 --- a/arch/powerpc/include/asm/kmap_types.h
7562 +++ b/arch/powerpc/include/asm/kmap_types.h
7563 @@ -10,7 +10,7 @@
7564 * 2 of the License, or (at your option) any later version.
7565 */
7566
7567 -#define KM_TYPE_NR 16
7568 +#define KM_TYPE_NR 17
7569
7570 #endif /* __KERNEL__ */
7571 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7572 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7573 index 8565c25..2865190 100644
7574 --- a/arch/powerpc/include/asm/mman.h
7575 +++ b/arch/powerpc/include/asm/mman.h
7576 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7577 }
7578 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7579
7580 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7581 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7582 {
7583 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7584 }
7585 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7586 index b9f4262..dcf04f7 100644
7587 --- a/arch/powerpc/include/asm/page.h
7588 +++ b/arch/powerpc/include/asm/page.h
7589 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7590 * and needs to be executable. This means the whole heap ends
7591 * up being executable.
7592 */
7593 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7594 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7595 +#define VM_DATA_DEFAULT_FLAGS32 \
7596 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7597 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7598
7599 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7600 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7601 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7602 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7603 #endif
7604
7605 +#define ktla_ktva(addr) (addr)
7606 +#define ktva_ktla(addr) (addr)
7607 +
7608 #ifndef CONFIG_PPC_BOOK3S_64
7609 /*
7610 * Use the top bit of the higher-level page table entries to indicate whether
7611 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7612 index 88693ce..ac6f9ab 100644
7613 --- a/arch/powerpc/include/asm/page_64.h
7614 +++ b/arch/powerpc/include/asm/page_64.h
7615 @@ -153,15 +153,18 @@ do { \
7616 * stack by default, so in the absence of a PT_GNU_STACK program header
7617 * we turn execute permission off.
7618 */
7619 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7620 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7621 +#define VM_STACK_DEFAULT_FLAGS32 \
7622 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7623 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7624
7625 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7626 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7627
7628 +#ifndef CONFIG_PAX_PAGEEXEC
7629 #define VM_STACK_DEFAULT_FLAGS \
7630 (is_32bit_task() ? \
7631 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7632 +#endif
7633
7634 #include <asm-generic/getorder.h>
7635
7636 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7637 index f65e27b..23ffb5b 100644
7638 --- a/arch/powerpc/include/asm/pgalloc-64.h
7639 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7640 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7641 #ifndef CONFIG_PPC_64K_PAGES
7642
7643 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7644 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7645
7646 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7647 {
7648 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7649 pud_set(pud, (unsigned long)pmd);
7650 }
7651
7652 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7653 +{
7654 + pud_populate(mm, pud, pmd);
7655 +}
7656 +
7657 #define pmd_populate(mm, pmd, pte_page) \
7658 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7659 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7660 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7661 #endif
7662
7663 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7664 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7665
7666 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7667 pte_t *pte)
7668 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7669 index 7d6eacf..14c0240 100644
7670 --- a/arch/powerpc/include/asm/pgtable.h
7671 +++ b/arch/powerpc/include/asm/pgtable.h
7672 @@ -2,6 +2,7 @@
7673 #define _ASM_POWERPC_PGTABLE_H
7674 #ifdef __KERNEL__
7675
7676 +#include <linux/const.h>
7677 #ifndef __ASSEMBLY__
7678 #include <asm/processor.h> /* For TASK_SIZE */
7679 #include <asm/mmu.h>
7680 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7681 index 4aad413..85d86bf 100644
7682 --- a/arch/powerpc/include/asm/pte-hash32.h
7683 +++ b/arch/powerpc/include/asm/pte-hash32.h
7684 @@ -21,6 +21,7 @@
7685 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7686 #define _PAGE_USER 0x004 /* usermode access allowed */
7687 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7688 +#define _PAGE_EXEC _PAGE_GUARDED
7689 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7690 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7691 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7692 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7693 index 99222e2..f629aef 100644
7694 --- a/arch/powerpc/include/asm/reg.h
7695 +++ b/arch/powerpc/include/asm/reg.h
7696 @@ -234,6 +234,7 @@
7697 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7698 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7699 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7700 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7701 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7702 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7703 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7704 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7705 index 48cfc85..891382f 100644
7706 --- a/arch/powerpc/include/asm/smp.h
7707 +++ b/arch/powerpc/include/asm/smp.h
7708 @@ -50,7 +50,7 @@ struct smp_ops_t {
7709 int (*cpu_disable)(void);
7710 void (*cpu_die)(unsigned int nr);
7711 int (*cpu_bootable)(unsigned int nr);
7712 -};
7713 +} __no_const;
7714
7715 extern void smp_send_debugger_break(void);
7716 extern void start_secondary_resume(void);
7717 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7718 index ba7b197..d292e26 100644
7719 --- a/arch/powerpc/include/asm/thread_info.h
7720 +++ b/arch/powerpc/include/asm/thread_info.h
7721 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7722 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7723 TIF_NEED_RESCHED */
7724 #define TIF_32BIT 4 /* 32 bit binary */
7725 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7726 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7727 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7728 #define TIF_SINGLESTEP 8 /* singlestepping active */
7729 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7730 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7731 for stack store? */
7732 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7733 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7734 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7735 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7736
7737 /* as above, but as bit values */
7738 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7739 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7740 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7741 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7742 #define _TIF_NOHZ (1<<TIF_NOHZ)
7743 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7744 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7745 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7746 - _TIF_NOHZ)
7747 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7748
7749 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7750 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7751 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7752 index 9485b43..4718d50 100644
7753 --- a/arch/powerpc/include/asm/uaccess.h
7754 +++ b/arch/powerpc/include/asm/uaccess.h
7755 @@ -318,52 +318,6 @@ do { \
7756 extern unsigned long __copy_tofrom_user(void __user *to,
7757 const void __user *from, unsigned long size);
7758
7759 -#ifndef __powerpc64__
7760 -
7761 -static inline unsigned long copy_from_user(void *to,
7762 - const void __user *from, unsigned long n)
7763 -{
7764 - unsigned long over;
7765 -
7766 - if (access_ok(VERIFY_READ, from, n))
7767 - return __copy_tofrom_user((__force void __user *)to, from, n);
7768 - if ((unsigned long)from < TASK_SIZE) {
7769 - over = (unsigned long)from + n - TASK_SIZE;
7770 - return __copy_tofrom_user((__force void __user *)to, from,
7771 - n - over) + over;
7772 - }
7773 - return n;
7774 -}
7775 -
7776 -static inline unsigned long copy_to_user(void __user *to,
7777 - const void *from, unsigned long n)
7778 -{
7779 - unsigned long over;
7780 -
7781 - if (access_ok(VERIFY_WRITE, to, n))
7782 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7783 - if ((unsigned long)to < TASK_SIZE) {
7784 - over = (unsigned long)to + n - TASK_SIZE;
7785 - return __copy_tofrom_user(to, (__force void __user *)from,
7786 - n - over) + over;
7787 - }
7788 - return n;
7789 -}
7790 -
7791 -#else /* __powerpc64__ */
7792 -
7793 -#define __copy_in_user(to, from, size) \
7794 - __copy_tofrom_user((to), (from), (size))
7795 -
7796 -extern unsigned long copy_from_user(void *to, const void __user *from,
7797 - unsigned long n);
7798 -extern unsigned long copy_to_user(void __user *to, const void *from,
7799 - unsigned long n);
7800 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7801 - unsigned long n);
7802 -
7803 -#endif /* __powerpc64__ */
7804 -
7805 static inline unsigned long __copy_from_user_inatomic(void *to,
7806 const void __user *from, unsigned long n)
7807 {
7808 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7809 if (ret == 0)
7810 return 0;
7811 }
7812 +
7813 + if (!__builtin_constant_p(n))
7814 + check_object_size(to, n, false);
7815 +
7816 return __copy_tofrom_user((__force void __user *)to, from, n);
7817 }
7818
7819 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7820 if (ret == 0)
7821 return 0;
7822 }
7823 +
7824 + if (!__builtin_constant_p(n))
7825 + check_object_size(from, n, true);
7826 +
7827 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7828 }
7829
7830 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7831 return __copy_to_user_inatomic(to, from, size);
7832 }
7833
7834 +#ifndef __powerpc64__
7835 +
7836 +static inline unsigned long __must_check copy_from_user(void *to,
7837 + const void __user *from, unsigned long n)
7838 +{
7839 + unsigned long over;
7840 +
7841 + if ((long)n < 0)
7842 + return n;
7843 +
7844 + if (access_ok(VERIFY_READ, from, n)) {
7845 + if (!__builtin_constant_p(n))
7846 + check_object_size(to, n, false);
7847 + return __copy_tofrom_user((__force void __user *)to, from, n);
7848 + }
7849 + if ((unsigned long)from < TASK_SIZE) {
7850 + over = (unsigned long)from + n - TASK_SIZE;
7851 + if (!__builtin_constant_p(n - over))
7852 + check_object_size(to, n - over, false);
7853 + return __copy_tofrom_user((__force void __user *)to, from,
7854 + n - over) + over;
7855 + }
7856 + return n;
7857 +}
7858 +
7859 +static inline unsigned long __must_check copy_to_user(void __user *to,
7860 + const void *from, unsigned long n)
7861 +{
7862 + unsigned long over;
7863 +
7864 + if ((long)n < 0)
7865 + return n;
7866 +
7867 + if (access_ok(VERIFY_WRITE, to, n)) {
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(from, n, true);
7870 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7871 + }
7872 + if ((unsigned long)to < TASK_SIZE) {
7873 + over = (unsigned long)to + n - TASK_SIZE;
7874 + if (!__builtin_constant_p(n))
7875 + check_object_size(from, n - over, true);
7876 + return __copy_tofrom_user(to, (__force void __user *)from,
7877 + n - over) + over;
7878 + }
7879 + return n;
7880 +}
7881 +
7882 +#else /* __powerpc64__ */
7883 +
7884 +#define __copy_in_user(to, from, size) \
7885 + __copy_tofrom_user((to), (from), (size))
7886 +
7887 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7888 +{
7889 + if ((long)n < 0 || n > INT_MAX)
7890 + return n;
7891 +
7892 + if (!__builtin_constant_p(n))
7893 + check_object_size(to, n, false);
7894 +
7895 + if (likely(access_ok(VERIFY_READ, from, n)))
7896 + n = __copy_from_user(to, from, n);
7897 + else
7898 + memset(to, 0, n);
7899 + return n;
7900 +}
7901 +
7902 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7903 +{
7904 + if ((long)n < 0 || n > INT_MAX)
7905 + return n;
7906 +
7907 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7908 + if (!__builtin_constant_p(n))
7909 + check_object_size(from, n, true);
7910 + n = __copy_to_user(to, from, n);
7911 + }
7912 + return n;
7913 +}
7914 +
7915 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7916 + unsigned long n);
7917 +
7918 +#endif /* __powerpc64__ */
7919 +
7920 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7921
7922 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7923 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7924 index 645170a..6cf0271 100644
7925 --- a/arch/powerpc/kernel/exceptions-64e.S
7926 +++ b/arch/powerpc/kernel/exceptions-64e.S
7927 @@ -757,6 +757,7 @@ storage_fault_common:
7928 std r14,_DAR(r1)
7929 std r15,_DSISR(r1)
7930 addi r3,r1,STACK_FRAME_OVERHEAD
7931 + bl .save_nvgprs
7932 mr r4,r14
7933 mr r5,r15
7934 ld r14,PACA_EXGEN+EX_R14(r13)
7935 @@ -765,8 +766,7 @@ storage_fault_common:
7936 cmpdi r3,0
7937 bne- 1f
7938 b .ret_from_except_lite
7939 -1: bl .save_nvgprs
7940 - mr r5,r3
7941 +1: mr r5,r3
7942 addi r3,r1,STACK_FRAME_OVERHEAD
7943 ld r4,_DAR(r1)
7944 bl .bad_page_fault
7945 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7946 index 902ca3c..e942155 100644
7947 --- a/arch/powerpc/kernel/exceptions-64s.S
7948 +++ b/arch/powerpc/kernel/exceptions-64s.S
7949 @@ -1357,10 +1357,10 @@ handle_page_fault:
7950 11: ld r4,_DAR(r1)
7951 ld r5,_DSISR(r1)
7952 addi r3,r1,STACK_FRAME_OVERHEAD
7953 + bl .save_nvgprs
7954 bl .do_page_fault
7955 cmpdi r3,0
7956 beq+ 12f
7957 - bl .save_nvgprs
7958 mr r5,r3
7959 addi r3,r1,STACK_FRAME_OVERHEAD
7960 lwz r4,_DAR(r1)
7961 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7962 index 2e3200c..72095ce 100644
7963 --- a/arch/powerpc/kernel/module_32.c
7964 +++ b/arch/powerpc/kernel/module_32.c
7965 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7966 me->arch.core_plt_section = i;
7967 }
7968 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7969 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7970 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7971 return -ENOEXEC;
7972 }
7973
7974 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7975
7976 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7977 /* Init, or core PLT? */
7978 - if (location >= mod->module_core
7979 - && location < mod->module_core + mod->core_size)
7980 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7981 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7982 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7983 - else
7984 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7985 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7986 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7987 + else {
7988 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7989 + return ~0UL;
7990 + }
7991
7992 /* Find this entry, or if that fails, the next avail. entry */
7993 while (entry->jump[0]) {
7994 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7995 index 8083be2..10aa352 100644
7996 --- a/arch/powerpc/kernel/process.c
7997 +++ b/arch/powerpc/kernel/process.c
7998 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7999 * Lookup NIP late so we have the best change of getting the
8000 * above info out without failing
8001 */
8002 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8003 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8004 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8005 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8006 #endif
8007 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8008 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8009 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8010 newsp = stack[0];
8011 ip = stack[STACK_FRAME_LR_SAVE];
8012 if (!firstframe || ip != lr) {
8013 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8014 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8015 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8016 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8017 - printk(" (%pS)",
8018 + printk(" (%pA)",
8019 (void *)current->ret_stack[curr_frame].ret);
8020 curr_frame--;
8021 }
8022 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8023 struct pt_regs *regs = (struct pt_regs *)
8024 (sp + STACK_FRAME_OVERHEAD);
8025 lr = regs->link;
8026 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8027 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8028 regs->trap, (void *)regs->nip, (void *)lr);
8029 firstframe = 1;
8030 }
8031 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8032 mtspr(SPRN_CTRLT, ctrl);
8033 }
8034 #endif /* CONFIG_PPC64 */
8035 -
8036 -unsigned long arch_align_stack(unsigned long sp)
8037 -{
8038 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8039 - sp -= get_random_int() & ~PAGE_MASK;
8040 - return sp & ~0xf;
8041 -}
8042 -
8043 -static inline unsigned long brk_rnd(void)
8044 -{
8045 - unsigned long rnd = 0;
8046 -
8047 - /* 8MB for 32bit, 1GB for 64bit */
8048 - if (is_32bit_task())
8049 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8050 - else
8051 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8052 -
8053 - return rnd << PAGE_SHIFT;
8054 -}
8055 -
8056 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8057 -{
8058 - unsigned long base = mm->brk;
8059 - unsigned long ret;
8060 -
8061 -#ifdef CONFIG_PPC_STD_MMU_64
8062 - /*
8063 - * If we are using 1TB segments and we are allowed to randomise
8064 - * the heap, we can put it above 1TB so it is backed by a 1TB
8065 - * segment. Otherwise the heap will be in the bottom 1TB
8066 - * which always uses 256MB segments and this may result in a
8067 - * performance penalty.
8068 - */
8069 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8070 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8071 -#endif
8072 -
8073 - ret = PAGE_ALIGN(base + brk_rnd());
8074 -
8075 - if (ret < mm->brk)
8076 - return mm->brk;
8077 -
8078 - return ret;
8079 -}
8080 -
8081 -unsigned long randomize_et_dyn(unsigned long base)
8082 -{
8083 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8084 -
8085 - if (ret < base)
8086 - return base;
8087 -
8088 - return ret;
8089 -}
8090 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8091 index 9a0d24c..e7fbedf 100644
8092 --- a/arch/powerpc/kernel/ptrace.c
8093 +++ b/arch/powerpc/kernel/ptrace.c
8094 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8095 return ret;
8096 }
8097
8098 +#ifdef CONFIG_GRKERNSEC_SETXID
8099 +extern void gr_delayed_cred_worker(void);
8100 +#endif
8101 +
8102 /*
8103 * We must return the syscall number to actually look up in the table.
8104 * This can be -1L to skip running any syscall at all.
8105 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8106
8107 secure_computing_strict(regs->gpr[0]);
8108
8109 +#ifdef CONFIG_GRKERNSEC_SETXID
8110 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8111 + gr_delayed_cred_worker();
8112 +#endif
8113 +
8114 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8115 tracehook_report_syscall_entry(regs))
8116 /*
8117 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8118 {
8119 int step;
8120
8121 +#ifdef CONFIG_GRKERNSEC_SETXID
8122 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8123 + gr_delayed_cred_worker();
8124 +#endif
8125 +
8126 audit_syscall_exit(regs);
8127
8128 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8129 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8130 index 0f83122..c0aca6a 100644
8131 --- a/arch/powerpc/kernel/signal_32.c
8132 +++ b/arch/powerpc/kernel/signal_32.c
8133 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8134 /* Save user registers on the stack */
8135 frame = &rt_sf->uc.uc_mcontext;
8136 addr = frame;
8137 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8138 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8139 sigret = 0;
8140 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8141 } else {
8142 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8143 index 887e99d..310bc11 100644
8144 --- a/arch/powerpc/kernel/signal_64.c
8145 +++ b/arch/powerpc/kernel/signal_64.c
8146 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8147 #endif
8148
8149 /* Set up to return from userspace. */
8150 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8151 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8152 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8153 } else {
8154 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8155 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8156 index e435bc0..41c2964 100644
8157 --- a/arch/powerpc/kernel/traps.c
8158 +++ b/arch/powerpc/kernel/traps.c
8159 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8160 return flags;
8161 }
8162
8163 +extern void gr_handle_kernel_exploit(void);
8164 +
8165 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8166 int signr)
8167 {
8168 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8169 panic("Fatal exception in interrupt");
8170 if (panic_on_oops)
8171 panic("Fatal exception");
8172 +
8173 + gr_handle_kernel_exploit();
8174 +
8175 do_exit(signr);
8176 }
8177
8178 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8179 index 1d9c926..25f4741 100644
8180 --- a/arch/powerpc/kernel/vdso.c
8181 +++ b/arch/powerpc/kernel/vdso.c
8182 @@ -34,6 +34,7 @@
8183 #include <asm/firmware.h>
8184 #include <asm/vdso.h>
8185 #include <asm/vdso_datapage.h>
8186 +#include <asm/mman.h>
8187
8188 #include "setup.h"
8189
8190 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8191 vdso_base = VDSO32_MBASE;
8192 #endif
8193
8194 - current->mm->context.vdso_base = 0;
8195 + current->mm->context.vdso_base = ~0UL;
8196
8197 /* vDSO has a problem and was disabled, just don't "enable" it for the
8198 * process
8199 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8200 vdso_base = get_unmapped_area(NULL, vdso_base,
8201 (vdso_pages << PAGE_SHIFT) +
8202 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8203 - 0, 0);
8204 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8205 if (IS_ERR_VALUE(vdso_base)) {
8206 rc = vdso_base;
8207 goto fail_mmapsem;
8208 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8209 index 5eea6f3..5d10396 100644
8210 --- a/arch/powerpc/lib/usercopy_64.c
8211 +++ b/arch/powerpc/lib/usercopy_64.c
8212 @@ -9,22 +9,6 @@
8213 #include <linux/module.h>
8214 #include <asm/uaccess.h>
8215
8216 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8217 -{
8218 - if (likely(access_ok(VERIFY_READ, from, n)))
8219 - n = __copy_from_user(to, from, n);
8220 - else
8221 - memset(to, 0, n);
8222 - return n;
8223 -}
8224 -
8225 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8226 -{
8227 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8228 - n = __copy_to_user(to, from, n);
8229 - return n;
8230 -}
8231 -
8232 unsigned long copy_in_user(void __user *to, const void __user *from,
8233 unsigned long n)
8234 {
8235 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8236 return n;
8237 }
8238
8239 -EXPORT_SYMBOL(copy_from_user);
8240 -EXPORT_SYMBOL(copy_to_user);
8241 EXPORT_SYMBOL(copy_in_user);
8242
8243 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8244 index 8726779..a33c512 100644
8245 --- a/arch/powerpc/mm/fault.c
8246 +++ b/arch/powerpc/mm/fault.c
8247 @@ -33,6 +33,10 @@
8248 #include <linux/magic.h>
8249 #include <linux/ratelimit.h>
8250 #include <linux/context_tracking.h>
8251 +#include <linux/slab.h>
8252 +#include <linux/pagemap.h>
8253 +#include <linux/compiler.h>
8254 +#include <linux/unistd.h>
8255
8256 #include <asm/firmware.h>
8257 #include <asm/page.h>
8258 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8259 }
8260 #endif
8261
8262 +#ifdef CONFIG_PAX_PAGEEXEC
8263 +/*
8264 + * PaX: decide what to do with offenders (regs->nip = fault address)
8265 + *
8266 + * returns 1 when task should be killed
8267 + */
8268 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8269 +{
8270 + return 1;
8271 +}
8272 +
8273 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8274 +{
8275 + unsigned long i;
8276 +
8277 + printk(KERN_ERR "PAX: bytes at PC: ");
8278 + for (i = 0; i < 5; i++) {
8279 + unsigned int c;
8280 + if (get_user(c, (unsigned int __user *)pc+i))
8281 + printk(KERN_CONT "???????? ");
8282 + else
8283 + printk(KERN_CONT "%08x ", c);
8284 + }
8285 + printk("\n");
8286 +}
8287 +#endif
8288 +
8289 /*
8290 * Check whether the instruction at regs->nip is a store using
8291 * an update addressing form which will update r1.
8292 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8293 * indicate errors in DSISR but can validly be set in SRR1.
8294 */
8295 if (trap == 0x400)
8296 - error_code &= 0x48200000;
8297 + error_code &= 0x58200000;
8298 else
8299 is_write = error_code & DSISR_ISSTORE;
8300 #else
8301 @@ -371,7 +402,7 @@ good_area:
8302 * "undefined". Of those that can be set, this is the only
8303 * one which seems bad.
8304 */
8305 - if (error_code & 0x10000000)
8306 + if (error_code & DSISR_GUARDED)
8307 /* Guarded storage error. */
8308 goto bad_area;
8309 #endif /* CONFIG_8xx */
8310 @@ -386,7 +417,7 @@ good_area:
8311 * processors use the same I/D cache coherency mechanism
8312 * as embedded.
8313 */
8314 - if (error_code & DSISR_PROTFAULT)
8315 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8316 goto bad_area;
8317 #endif /* CONFIG_PPC_STD_MMU */
8318
8319 @@ -471,6 +502,23 @@ bad_area:
8320 bad_area_nosemaphore:
8321 /* User mode accesses cause a SIGSEGV */
8322 if (user_mode(regs)) {
8323 +
8324 +#ifdef CONFIG_PAX_PAGEEXEC
8325 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8326 +#ifdef CONFIG_PPC_STD_MMU
8327 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8328 +#else
8329 + if (is_exec && regs->nip == address) {
8330 +#endif
8331 + switch (pax_handle_fetch_fault(regs)) {
8332 + }
8333 +
8334 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8335 + do_group_exit(SIGKILL);
8336 + }
8337 + }
8338 +#endif
8339 +
8340 _exception(SIGSEGV, regs, code, address);
8341 goto bail;
8342 }
8343 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8344 index cb8bdbe..d770680 100644
8345 --- a/arch/powerpc/mm/mmap.c
8346 +++ b/arch/powerpc/mm/mmap.c
8347 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8348 {
8349 unsigned long rnd = 0;
8350
8351 +#ifdef CONFIG_PAX_RANDMMAP
8352 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8353 +#endif
8354 +
8355 if (current->flags & PF_RANDOMIZE) {
8356 /* 8MB for 32bit, 1GB for 64bit */
8357 if (is_32bit_task())
8358 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8359 */
8360 if (mmap_is_legacy()) {
8361 mm->mmap_base = TASK_UNMAPPED_BASE;
8362 +
8363 +#ifdef CONFIG_PAX_RANDMMAP
8364 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8365 + mm->mmap_base += mm->delta_mmap;
8366 +#endif
8367 +
8368 mm->get_unmapped_area = arch_get_unmapped_area;
8369 } else {
8370 mm->mmap_base = mmap_base();
8371 +
8372 +#ifdef CONFIG_PAX_RANDMMAP
8373 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8374 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8375 +#endif
8376 +
8377 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8378 }
8379 }
8380 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8381 index 3e99c14..f00953c 100644
8382 --- a/arch/powerpc/mm/slice.c
8383 +++ b/arch/powerpc/mm/slice.c
8384 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8385 if ((mm->task_size - len) < addr)
8386 return 0;
8387 vma = find_vma(mm, addr);
8388 - return (!vma || (addr + len) <= vma->vm_start);
8389 + return check_heap_stack_gap(vma, addr, len, 0);
8390 }
8391
8392 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8393 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8394 info.align_offset = 0;
8395
8396 addr = TASK_UNMAPPED_BASE;
8397 +
8398 +#ifdef CONFIG_PAX_RANDMMAP
8399 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8400 + addr += mm->delta_mmap;
8401 +#endif
8402 +
8403 while (addr < TASK_SIZE) {
8404 info.low_limit = addr;
8405 if (!slice_scan_available(addr, available, 1, &addr))
8406 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8407 if (fixed && addr > (mm->task_size - len))
8408 return -EINVAL;
8409
8410 +#ifdef CONFIG_PAX_RANDMMAP
8411 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8412 + addr = 0;
8413 +#endif
8414 +
8415 /* If hint, make sure it matches our alignment restrictions */
8416 if (!fixed && addr) {
8417 addr = _ALIGN_UP(addr, 1ul << pshift);
8418 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8419 index 9098692..3d54cd1 100644
8420 --- a/arch/powerpc/platforms/cell/spufs/file.c
8421 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8422 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8423 return VM_FAULT_NOPAGE;
8424 }
8425
8426 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8427 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8428 unsigned long address,
8429 - void *buf, int len, int write)
8430 + void *buf, size_t len, int write)
8431 {
8432 struct spu_context *ctx = vma->vm_file->private_data;
8433 unsigned long offset = address - vma->vm_start;
8434 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8435 index c797832..ce575c8 100644
8436 --- a/arch/s390/include/asm/atomic.h
8437 +++ b/arch/s390/include/asm/atomic.h
8438 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8439 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8440 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8441
8442 +#define atomic64_read_unchecked(v) atomic64_read(v)
8443 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8444 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8445 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8446 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8447 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8448 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8449 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8450 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8451 +
8452 #define smp_mb__before_atomic_dec() smp_mb()
8453 #define smp_mb__after_atomic_dec() smp_mb()
8454 #define smp_mb__before_atomic_inc() smp_mb()
8455 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8456 index 4d7ccac..d03d0ad 100644
8457 --- a/arch/s390/include/asm/cache.h
8458 +++ b/arch/s390/include/asm/cache.h
8459 @@ -9,8 +9,10 @@
8460 #ifndef __ARCH_S390_CACHE_H
8461 #define __ARCH_S390_CACHE_H
8462
8463 -#define L1_CACHE_BYTES 256
8464 +#include <linux/const.h>
8465 +
8466 #define L1_CACHE_SHIFT 8
8467 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8468 #define NET_SKB_PAD 32
8469
8470 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8471 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8472 index 78f4f87..598ce39 100644
8473 --- a/arch/s390/include/asm/elf.h
8474 +++ b/arch/s390/include/asm/elf.h
8475 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8476 the loader. We need to make sure that it is out of the way of the program
8477 that it will "exec", and that there is sufficient room for the brk. */
8478
8479 -extern unsigned long randomize_et_dyn(unsigned long base);
8480 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8481 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8482 +
8483 +#ifdef CONFIG_PAX_ASLR
8484 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8485 +
8486 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8487 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8488 +#endif
8489
8490 /* This yields a mask that user programs can use to figure out what
8491 instruction set this CPU supports. */
8492 @@ -222,9 +228,6 @@ struct linux_binprm;
8493 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8494 int arch_setup_additional_pages(struct linux_binprm *, int);
8495
8496 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8497 -#define arch_randomize_brk arch_randomize_brk
8498 -
8499 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8500
8501 #endif
8502 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8503 index c4a93d6..4d2a9b4 100644
8504 --- a/arch/s390/include/asm/exec.h
8505 +++ b/arch/s390/include/asm/exec.h
8506 @@ -7,6 +7,6 @@
8507 #ifndef __ASM_EXEC_H
8508 #define __ASM_EXEC_H
8509
8510 -extern unsigned long arch_align_stack(unsigned long sp);
8511 +#define arch_align_stack(x) ((x) & ~0xfUL)
8512
8513 #endif /* __ASM_EXEC_H */
8514 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8515 index 9c33ed4..e40cbef 100644
8516 --- a/arch/s390/include/asm/uaccess.h
8517 +++ b/arch/s390/include/asm/uaccess.h
8518 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8519 copy_to_user(void __user *to, const void *from, unsigned long n)
8520 {
8521 might_fault();
8522 +
8523 + if ((long)n < 0)
8524 + return n;
8525 +
8526 return __copy_to_user(to, from, n);
8527 }
8528
8529 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8530 static inline unsigned long __must_check
8531 __copy_from_user(void *to, const void __user *from, unsigned long n)
8532 {
8533 + if ((long)n < 0)
8534 + return n;
8535 +
8536 if (__builtin_constant_p(n) && (n <= 256))
8537 return uaccess.copy_from_user_small(n, from, to);
8538 else
8539 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8540 static inline unsigned long __must_check
8541 copy_from_user(void *to, const void __user *from, unsigned long n)
8542 {
8543 - unsigned int sz = __compiletime_object_size(to);
8544 + size_t sz = __compiletime_object_size(to);
8545
8546 might_fault();
8547 - if (unlikely(sz != -1 && sz < n)) {
8548 +
8549 + if ((long)n < 0)
8550 + return n;
8551 +
8552 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8553 copy_from_user_overflow();
8554 return n;
8555 }
8556 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8557 index 7845e15..59c4353 100644
8558 --- a/arch/s390/kernel/module.c
8559 +++ b/arch/s390/kernel/module.c
8560 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8561
8562 /* Increase core size by size of got & plt and set start
8563 offsets for got and plt. */
8564 - me->core_size = ALIGN(me->core_size, 4);
8565 - me->arch.got_offset = me->core_size;
8566 - me->core_size += me->arch.got_size;
8567 - me->arch.plt_offset = me->core_size;
8568 - me->core_size += me->arch.plt_size;
8569 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8570 + me->arch.got_offset = me->core_size_rw;
8571 + me->core_size_rw += me->arch.got_size;
8572 + me->arch.plt_offset = me->core_size_rx;
8573 + me->core_size_rx += me->arch.plt_size;
8574 return 0;
8575 }
8576
8577 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8578 if (info->got_initialized == 0) {
8579 Elf_Addr *gotent;
8580
8581 - gotent = me->module_core + me->arch.got_offset +
8582 + gotent = me->module_core_rw + me->arch.got_offset +
8583 info->got_offset;
8584 *gotent = val;
8585 info->got_initialized = 1;
8586 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8587 rc = apply_rela_bits(loc, val, 0, 64, 0);
8588 else if (r_type == R_390_GOTENT ||
8589 r_type == R_390_GOTPLTENT) {
8590 - val += (Elf_Addr) me->module_core - loc;
8591 + val += (Elf_Addr) me->module_core_rw - loc;
8592 rc = apply_rela_bits(loc, val, 1, 32, 1);
8593 }
8594 break;
8595 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8596 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8597 if (info->plt_initialized == 0) {
8598 unsigned int *ip;
8599 - ip = me->module_core + me->arch.plt_offset +
8600 + ip = me->module_core_rx + me->arch.plt_offset +
8601 info->plt_offset;
8602 #ifndef CONFIG_64BIT
8603 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8604 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8605 val - loc + 0xffffUL < 0x1ffffeUL) ||
8606 (r_type == R_390_PLT32DBL &&
8607 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8608 - val = (Elf_Addr) me->module_core +
8609 + val = (Elf_Addr) me->module_core_rx +
8610 me->arch.plt_offset +
8611 info->plt_offset;
8612 val += rela->r_addend - loc;
8613 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8614 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8615 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8616 val = val + rela->r_addend -
8617 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8618 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8619 if (r_type == R_390_GOTOFF16)
8620 rc = apply_rela_bits(loc, val, 0, 16, 0);
8621 else if (r_type == R_390_GOTOFF32)
8622 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8623 break;
8624 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8625 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8626 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8627 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8628 rela->r_addend - loc;
8629 if (r_type == R_390_GOTPC)
8630 rc = apply_rela_bits(loc, val, 1, 32, 0);
8631 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8632 index 2bc3edd..ab9d598 100644
8633 --- a/arch/s390/kernel/process.c
8634 +++ b/arch/s390/kernel/process.c
8635 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8636 }
8637 return 0;
8638 }
8639 -
8640 -unsigned long arch_align_stack(unsigned long sp)
8641 -{
8642 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8643 - sp -= get_random_int() & ~PAGE_MASK;
8644 - return sp & ~0xf;
8645 -}
8646 -
8647 -static inline unsigned long brk_rnd(void)
8648 -{
8649 - /* 8MB for 32bit, 1GB for 64bit */
8650 - if (is_32bit_task())
8651 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8652 - else
8653 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8654 -}
8655 -
8656 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8657 -{
8658 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8659 -
8660 - if (ret < mm->brk)
8661 - return mm->brk;
8662 - return ret;
8663 -}
8664 -
8665 -unsigned long randomize_et_dyn(unsigned long base)
8666 -{
8667 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8668 -
8669 - if (!(current->flags & PF_RANDOMIZE))
8670 - return base;
8671 - if (ret < base)
8672 - return base;
8673 - return ret;
8674 -}
8675 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8676 index 4002329..99b67cb 100644
8677 --- a/arch/s390/mm/mmap.c
8678 +++ b/arch/s390/mm/mmap.c
8679 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8680 */
8681 if (mmap_is_legacy()) {
8682 mm->mmap_base = TASK_UNMAPPED_BASE;
8683 +
8684 +#ifdef CONFIG_PAX_RANDMMAP
8685 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8686 + mm->mmap_base += mm->delta_mmap;
8687 +#endif
8688 +
8689 mm->get_unmapped_area = arch_get_unmapped_area;
8690 } else {
8691 mm->mmap_base = mmap_base();
8692 +
8693 +#ifdef CONFIG_PAX_RANDMMAP
8694 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8695 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8696 +#endif
8697 +
8698 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8699 }
8700 }
8701 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8702 */
8703 if (mmap_is_legacy()) {
8704 mm->mmap_base = TASK_UNMAPPED_BASE;
8705 +
8706 +#ifdef CONFIG_PAX_RANDMMAP
8707 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8708 + mm->mmap_base += mm->delta_mmap;
8709 +#endif
8710 +
8711 mm->get_unmapped_area = s390_get_unmapped_area;
8712 } else {
8713 mm->mmap_base = mmap_base();
8714 +
8715 +#ifdef CONFIG_PAX_RANDMMAP
8716 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8717 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8718 +#endif
8719 +
8720 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8721 }
8722 }
8723 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8724 index ae3d59f..f65f075 100644
8725 --- a/arch/score/include/asm/cache.h
8726 +++ b/arch/score/include/asm/cache.h
8727 @@ -1,7 +1,9 @@
8728 #ifndef _ASM_SCORE_CACHE_H
8729 #define _ASM_SCORE_CACHE_H
8730
8731 +#include <linux/const.h>
8732 +
8733 #define L1_CACHE_SHIFT 4
8734 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8735 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8736
8737 #endif /* _ASM_SCORE_CACHE_H */
8738 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8739 index f9f3cd5..58ff438 100644
8740 --- a/arch/score/include/asm/exec.h
8741 +++ b/arch/score/include/asm/exec.h
8742 @@ -1,6 +1,6 @@
8743 #ifndef _ASM_SCORE_EXEC_H
8744 #define _ASM_SCORE_EXEC_H
8745
8746 -extern unsigned long arch_align_stack(unsigned long sp);
8747 +#define arch_align_stack(x) (x)
8748
8749 #endif /* _ASM_SCORE_EXEC_H */
8750 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8751 index f4c6d02..e9355c3 100644
8752 --- a/arch/score/kernel/process.c
8753 +++ b/arch/score/kernel/process.c
8754 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8755
8756 return task_pt_regs(task)->cp0_epc;
8757 }
8758 -
8759 -unsigned long arch_align_stack(unsigned long sp)
8760 -{
8761 - return sp;
8762 -}
8763 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8764 index ef9e555..331bd29 100644
8765 --- a/arch/sh/include/asm/cache.h
8766 +++ b/arch/sh/include/asm/cache.h
8767 @@ -9,10 +9,11 @@
8768 #define __ASM_SH_CACHE_H
8769 #ifdef __KERNEL__
8770
8771 +#include <linux/const.h>
8772 #include <linux/init.h>
8773 #include <cpu/cache.h>
8774
8775 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8776 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8777
8778 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8779
8780 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8781 index 6777177..cb5e44f 100644
8782 --- a/arch/sh/mm/mmap.c
8783 +++ b/arch/sh/mm/mmap.c
8784 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8785 struct mm_struct *mm = current->mm;
8786 struct vm_area_struct *vma;
8787 int do_colour_align;
8788 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8789 struct vm_unmapped_area_info info;
8790
8791 if (flags & MAP_FIXED) {
8792 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8793 if (filp || (flags & MAP_SHARED))
8794 do_colour_align = 1;
8795
8796 +#ifdef CONFIG_PAX_RANDMMAP
8797 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8798 +#endif
8799 +
8800 if (addr) {
8801 if (do_colour_align)
8802 addr = COLOUR_ALIGN(addr, pgoff);
8803 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8804 addr = PAGE_ALIGN(addr);
8805
8806 vma = find_vma(mm, addr);
8807 - if (TASK_SIZE - len >= addr &&
8808 - (!vma || addr + len <= vma->vm_start))
8809 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8810 return addr;
8811 }
8812
8813 info.flags = 0;
8814 info.length = len;
8815 - info.low_limit = TASK_UNMAPPED_BASE;
8816 + info.low_limit = mm->mmap_base;
8817 info.high_limit = TASK_SIZE;
8818 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8819 info.align_offset = pgoff << PAGE_SHIFT;
8820 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8821 struct mm_struct *mm = current->mm;
8822 unsigned long addr = addr0;
8823 int do_colour_align;
8824 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8825 struct vm_unmapped_area_info info;
8826
8827 if (flags & MAP_FIXED) {
8828 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8829 if (filp || (flags & MAP_SHARED))
8830 do_colour_align = 1;
8831
8832 +#ifdef CONFIG_PAX_RANDMMAP
8833 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8834 +#endif
8835 +
8836 /* requesting a specific address */
8837 if (addr) {
8838 if (do_colour_align)
8839 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8840 addr = PAGE_ALIGN(addr);
8841
8842 vma = find_vma(mm, addr);
8843 - if (TASK_SIZE - len >= addr &&
8844 - (!vma || addr + len <= vma->vm_start))
8845 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8846 return addr;
8847 }
8848
8849 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8850 VM_BUG_ON(addr != -ENOMEM);
8851 info.flags = 0;
8852 info.low_limit = TASK_UNMAPPED_BASE;
8853 +
8854 +#ifdef CONFIG_PAX_RANDMMAP
8855 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8856 + info.low_limit += mm->delta_mmap;
8857 +#endif
8858 +
8859 info.high_limit = TASK_SIZE;
8860 addr = vm_unmapped_area(&info);
8861 }
8862 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8863 index be56a24..443328f 100644
8864 --- a/arch/sparc/include/asm/atomic_64.h
8865 +++ b/arch/sparc/include/asm/atomic_64.h
8866 @@ -14,18 +14,40 @@
8867 #define ATOMIC64_INIT(i) { (i) }
8868
8869 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8870 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8871 +{
8872 + return v->counter;
8873 +}
8874 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8875 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8876 +{
8877 + return v->counter;
8878 +}
8879
8880 #define atomic_set(v, i) (((v)->counter) = i)
8881 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8882 +{
8883 + v->counter = i;
8884 +}
8885 #define atomic64_set(v, i) (((v)->counter) = i)
8886 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8887 +{
8888 + v->counter = i;
8889 +}
8890
8891 extern void atomic_add(int, atomic_t *);
8892 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8893 extern void atomic64_add(long, atomic64_t *);
8894 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8895 extern void atomic_sub(int, atomic_t *);
8896 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8897 extern void atomic64_sub(long, atomic64_t *);
8898 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8899
8900 extern int atomic_add_ret(int, atomic_t *);
8901 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8902 extern long atomic64_add_ret(long, atomic64_t *);
8903 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8904 extern int atomic_sub_ret(int, atomic_t *);
8905 extern long atomic64_sub_ret(long, atomic64_t *);
8906
8907 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8908 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8909
8910 #define atomic_inc_return(v) atomic_add_ret(1, v)
8911 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8912 +{
8913 + return atomic_add_ret_unchecked(1, v);
8914 +}
8915 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8916 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8917 +{
8918 + return atomic64_add_ret_unchecked(1, v);
8919 +}
8920
8921 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8922 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8923
8924 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8925 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8926 +{
8927 + return atomic_add_ret_unchecked(i, v);
8928 +}
8929 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8930 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8931 +{
8932 + return atomic64_add_ret_unchecked(i, v);
8933 +}
8934
8935 /*
8936 * atomic_inc_and_test - increment and test
8937 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8938 * other cases.
8939 */
8940 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8941 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8942 +{
8943 + return atomic_inc_return_unchecked(v) == 0;
8944 +}
8945 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8946
8947 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8948 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8949 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8950
8951 #define atomic_inc(v) atomic_add(1, v)
8952 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8953 +{
8954 + atomic_add_unchecked(1, v);
8955 +}
8956 #define atomic64_inc(v) atomic64_add(1, v)
8957 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8958 +{
8959 + atomic64_add_unchecked(1, v);
8960 +}
8961
8962 #define atomic_dec(v) atomic_sub(1, v)
8963 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8964 +{
8965 + atomic_sub_unchecked(1, v);
8966 +}
8967 #define atomic64_dec(v) atomic64_sub(1, v)
8968 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8969 +{
8970 + atomic64_sub_unchecked(1, v);
8971 +}
8972
8973 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8974 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8975
8976 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8977 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8978 +{
8979 + return cmpxchg(&v->counter, old, new);
8980 +}
8981 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8982 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8983 +{
8984 + return xchg(&v->counter, new);
8985 +}
8986
8987 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8988 {
8989 - int c, old;
8990 + int c, old, new;
8991 c = atomic_read(v);
8992 for (;;) {
8993 - if (unlikely(c == (u)))
8994 + if (unlikely(c == u))
8995 break;
8996 - old = atomic_cmpxchg((v), c, c + (a));
8997 +
8998 + asm volatile("addcc %2, %0, %0\n"
8999 +
9000 +#ifdef CONFIG_PAX_REFCOUNT
9001 + "tvs %%icc, 6\n"
9002 +#endif
9003 +
9004 + : "=r" (new)
9005 + : "0" (c), "ir" (a)
9006 + : "cc");
9007 +
9008 + old = atomic_cmpxchg(v, c, new);
9009 if (likely(old == c))
9010 break;
9011 c = old;
9012 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9013 #define atomic64_cmpxchg(v, o, n) \
9014 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9015 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9016 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9017 +{
9018 + return xchg(&v->counter, new);
9019 +}
9020
9021 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9022 {
9023 - long c, old;
9024 + long c, old, new;
9025 c = atomic64_read(v);
9026 for (;;) {
9027 - if (unlikely(c == (u)))
9028 + if (unlikely(c == u))
9029 break;
9030 - old = atomic64_cmpxchg((v), c, c + (a));
9031 +
9032 + asm volatile("addcc %2, %0, %0\n"
9033 +
9034 +#ifdef CONFIG_PAX_REFCOUNT
9035 + "tvs %%xcc, 6\n"
9036 +#endif
9037 +
9038 + : "=r" (new)
9039 + : "0" (c), "ir" (a)
9040 + : "cc");
9041 +
9042 + old = atomic64_cmpxchg(v, c, new);
9043 if (likely(old == c))
9044 break;
9045 c = old;
9046 }
9047 - return c != (u);
9048 + return c != u;
9049 }
9050
9051 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9052 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9053 index 5bb6991..5c2132e 100644
9054 --- a/arch/sparc/include/asm/cache.h
9055 +++ b/arch/sparc/include/asm/cache.h
9056 @@ -7,10 +7,12 @@
9057 #ifndef _SPARC_CACHE_H
9058 #define _SPARC_CACHE_H
9059
9060 +#include <linux/const.h>
9061 +
9062 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9063
9064 #define L1_CACHE_SHIFT 5
9065 -#define L1_CACHE_BYTES 32
9066 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9067
9068 #ifdef CONFIG_SPARC32
9069 #define SMP_CACHE_BYTES_SHIFT 5
9070 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9071 index a24e41f..47677ff 100644
9072 --- a/arch/sparc/include/asm/elf_32.h
9073 +++ b/arch/sparc/include/asm/elf_32.h
9074 @@ -114,6 +114,13 @@ typedef struct {
9075
9076 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9077
9078 +#ifdef CONFIG_PAX_ASLR
9079 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9080 +
9081 +#define PAX_DELTA_MMAP_LEN 16
9082 +#define PAX_DELTA_STACK_LEN 16
9083 +#endif
9084 +
9085 /* This yields a mask that user programs can use to figure out what
9086 instruction set this cpu supports. This can NOT be done in userspace
9087 on Sparc. */
9088 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9089 index 370ca1e..d4f4a98 100644
9090 --- a/arch/sparc/include/asm/elf_64.h
9091 +++ b/arch/sparc/include/asm/elf_64.h
9092 @@ -189,6 +189,13 @@ typedef struct {
9093 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9094 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9095
9096 +#ifdef CONFIG_PAX_ASLR
9097 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9098 +
9099 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9100 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9101 +#endif
9102 +
9103 extern unsigned long sparc64_elf_hwcap;
9104 #define ELF_HWCAP sparc64_elf_hwcap
9105
9106 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9107 index 9b1c36d..209298b 100644
9108 --- a/arch/sparc/include/asm/pgalloc_32.h
9109 +++ b/arch/sparc/include/asm/pgalloc_32.h
9110 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9111 }
9112
9113 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9114 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9115
9116 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9117 unsigned long address)
9118 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9119 index bcfe063..b333142 100644
9120 --- a/arch/sparc/include/asm/pgalloc_64.h
9121 +++ b/arch/sparc/include/asm/pgalloc_64.h
9122 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9123 }
9124
9125 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9126 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9127
9128 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9129 {
9130 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9131 index 502f632..da1917f 100644
9132 --- a/arch/sparc/include/asm/pgtable_32.h
9133 +++ b/arch/sparc/include/asm/pgtable_32.h
9134 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9135 #define PAGE_SHARED SRMMU_PAGE_SHARED
9136 #define PAGE_COPY SRMMU_PAGE_COPY
9137 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9138 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9139 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9140 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9141 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9142
9143 /* Top-level page directory - dummy used by init-mm.
9144 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9145
9146 /* xwr */
9147 #define __P000 PAGE_NONE
9148 -#define __P001 PAGE_READONLY
9149 -#define __P010 PAGE_COPY
9150 -#define __P011 PAGE_COPY
9151 +#define __P001 PAGE_READONLY_NOEXEC
9152 +#define __P010 PAGE_COPY_NOEXEC
9153 +#define __P011 PAGE_COPY_NOEXEC
9154 #define __P100 PAGE_READONLY
9155 #define __P101 PAGE_READONLY
9156 #define __P110 PAGE_COPY
9157 #define __P111 PAGE_COPY
9158
9159 #define __S000 PAGE_NONE
9160 -#define __S001 PAGE_READONLY
9161 -#define __S010 PAGE_SHARED
9162 -#define __S011 PAGE_SHARED
9163 +#define __S001 PAGE_READONLY_NOEXEC
9164 +#define __S010 PAGE_SHARED_NOEXEC
9165 +#define __S011 PAGE_SHARED_NOEXEC
9166 #define __S100 PAGE_READONLY
9167 #define __S101 PAGE_READONLY
9168 #define __S110 PAGE_SHARED
9169 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9170 index 79da178..c2eede8 100644
9171 --- a/arch/sparc/include/asm/pgtsrmmu.h
9172 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9173 @@ -115,6 +115,11 @@
9174 SRMMU_EXEC | SRMMU_REF)
9175 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9176 SRMMU_EXEC | SRMMU_REF)
9177 +
9178 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9179 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9180 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9181 +
9182 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9183 SRMMU_DIRTY | SRMMU_REF)
9184
9185 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9186 index 9689176..63c18ea 100644
9187 --- a/arch/sparc/include/asm/spinlock_64.h
9188 +++ b/arch/sparc/include/asm/spinlock_64.h
9189 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9190
9191 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9192
9193 -static void inline arch_read_lock(arch_rwlock_t *lock)
9194 +static inline void arch_read_lock(arch_rwlock_t *lock)
9195 {
9196 unsigned long tmp1, tmp2;
9197
9198 __asm__ __volatile__ (
9199 "1: ldsw [%2], %0\n"
9200 " brlz,pn %0, 2f\n"
9201 -"4: add %0, 1, %1\n"
9202 +"4: addcc %0, 1, %1\n"
9203 +
9204 +#ifdef CONFIG_PAX_REFCOUNT
9205 +" tvs %%icc, 6\n"
9206 +#endif
9207 +
9208 " cas [%2], %0, %1\n"
9209 " cmp %0, %1\n"
9210 " bne,pn %%icc, 1b\n"
9211 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9212 " .previous"
9213 : "=&r" (tmp1), "=&r" (tmp2)
9214 : "r" (lock)
9215 - : "memory");
9216 + : "memory", "cc");
9217 }
9218
9219 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9220 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9221 {
9222 int tmp1, tmp2;
9223
9224 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9225 "1: ldsw [%2], %0\n"
9226 " brlz,a,pn %0, 2f\n"
9227 " mov 0, %0\n"
9228 -" add %0, 1, %1\n"
9229 +" addcc %0, 1, %1\n"
9230 +
9231 +#ifdef CONFIG_PAX_REFCOUNT
9232 +" tvs %%icc, 6\n"
9233 +#endif
9234 +
9235 " cas [%2], %0, %1\n"
9236 " cmp %0, %1\n"
9237 " bne,pn %%icc, 1b\n"
9238 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9239 return tmp1;
9240 }
9241
9242 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9243 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9244 {
9245 unsigned long tmp1, tmp2;
9246
9247 __asm__ __volatile__(
9248 "1: lduw [%2], %0\n"
9249 -" sub %0, 1, %1\n"
9250 +" subcc %0, 1, %1\n"
9251 +
9252 +#ifdef CONFIG_PAX_REFCOUNT
9253 +" tvs %%icc, 6\n"
9254 +#endif
9255 +
9256 " cas [%2], %0, %1\n"
9257 " cmp %0, %1\n"
9258 " bne,pn %%xcc, 1b\n"
9259 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9260 : "memory");
9261 }
9262
9263 -static void inline arch_write_lock(arch_rwlock_t *lock)
9264 +static inline void arch_write_lock(arch_rwlock_t *lock)
9265 {
9266 unsigned long mask, tmp1, tmp2;
9267
9268 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9269 : "memory");
9270 }
9271
9272 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9273 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9274 {
9275 __asm__ __volatile__(
9276 " stw %%g0, [%0]"
9277 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9278 : "memory");
9279 }
9280
9281 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9282 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9283 {
9284 unsigned long mask, tmp1, tmp2, result;
9285
9286 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9287 index dd38075..e7cac83 100644
9288 --- a/arch/sparc/include/asm/thread_info_32.h
9289 +++ b/arch/sparc/include/asm/thread_info_32.h
9290 @@ -49,6 +49,8 @@ struct thread_info {
9291 unsigned long w_saved;
9292
9293 struct restart_block restart_block;
9294 +
9295 + unsigned long lowest_stack;
9296 };
9297
9298 /*
9299 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9300 index d5e5042..9bfee76 100644
9301 --- a/arch/sparc/include/asm/thread_info_64.h
9302 +++ b/arch/sparc/include/asm/thread_info_64.h
9303 @@ -63,6 +63,8 @@ struct thread_info {
9304 struct pt_regs *kern_una_regs;
9305 unsigned int kern_una_insn;
9306
9307 + unsigned long lowest_stack;
9308 +
9309 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9310 };
9311
9312 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9313 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9314 /* flag bit 6 is available */
9315 #define TIF_32BIT 7 /* 32-bit binary */
9316 -/* flag bit 8 is available */
9317 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9318 #define TIF_SECCOMP 9 /* secure computing */
9319 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9320 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9321 +
9322 /* NOTE: Thread flags >= 12 should be ones we have no interest
9323 * in using in assembly, else we can't use the mask as
9324 * an immediate value in instructions such as andcc.
9325 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9326 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9327 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9328 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9329 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9330
9331 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9332 _TIF_DO_NOTIFY_RESUME_MASK | \
9333 _TIF_NEED_RESCHED)
9334 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9335
9336 +#define _TIF_WORK_SYSCALL \
9337 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9338 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9339 +
9340 +
9341 /*
9342 * Thread-synchronous status.
9343 *
9344 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9345 index 0167d26..767bb0c 100644
9346 --- a/arch/sparc/include/asm/uaccess.h
9347 +++ b/arch/sparc/include/asm/uaccess.h
9348 @@ -1,5 +1,6 @@
9349 #ifndef ___ASM_SPARC_UACCESS_H
9350 #define ___ASM_SPARC_UACCESS_H
9351 +
9352 #if defined(__sparc__) && defined(__arch64__)
9353 #include <asm/uaccess_64.h>
9354 #else
9355 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9356 index 53a28dd..50c38c3 100644
9357 --- a/arch/sparc/include/asm/uaccess_32.h
9358 +++ b/arch/sparc/include/asm/uaccess_32.h
9359 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9360
9361 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9362 {
9363 - if (n && __access_ok((unsigned long) to, n))
9364 + if ((long)n < 0)
9365 + return n;
9366 +
9367 + if (n && __access_ok((unsigned long) to, n)) {
9368 + if (!__builtin_constant_p(n))
9369 + check_object_size(from, n, true);
9370 return __copy_user(to, (__force void __user *) from, n);
9371 - else
9372 + } else
9373 return n;
9374 }
9375
9376 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9377 {
9378 + if ((long)n < 0)
9379 + return n;
9380 +
9381 + if (!__builtin_constant_p(n))
9382 + check_object_size(from, n, true);
9383 +
9384 return __copy_user(to, (__force void __user *) from, n);
9385 }
9386
9387 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9388 {
9389 - if (n && __access_ok((unsigned long) from, n))
9390 + if ((long)n < 0)
9391 + return n;
9392 +
9393 + if (n && __access_ok((unsigned long) from, n)) {
9394 + if (!__builtin_constant_p(n))
9395 + check_object_size(to, n, false);
9396 return __copy_user((__force void __user *) to, from, n);
9397 - else
9398 + } else
9399 return n;
9400 }
9401
9402 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9403 {
9404 + if ((long)n < 0)
9405 + return n;
9406 +
9407 return __copy_user((__force void __user *) to, from, n);
9408 }
9409
9410 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9411 index e562d3c..191f176 100644
9412 --- a/arch/sparc/include/asm/uaccess_64.h
9413 +++ b/arch/sparc/include/asm/uaccess_64.h
9414 @@ -10,6 +10,7 @@
9415 #include <linux/compiler.h>
9416 #include <linux/string.h>
9417 #include <linux/thread_info.h>
9418 +#include <linux/kernel.h>
9419 #include <asm/asi.h>
9420 #include <asm/spitfire.h>
9421 #include <asm-generic/uaccess-unaligned.h>
9422 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9423 static inline unsigned long __must_check
9424 copy_from_user(void *to, const void __user *from, unsigned long size)
9425 {
9426 - unsigned long ret = ___copy_from_user(to, from, size);
9427 + unsigned long ret;
9428
9429 + if ((long)size < 0 || size > INT_MAX)
9430 + return size;
9431 +
9432 + if (!__builtin_constant_p(size))
9433 + check_object_size(to, size, false);
9434 +
9435 + ret = ___copy_from_user(to, from, size);
9436 if (unlikely(ret))
9437 ret = copy_from_user_fixup(to, from, size);
9438
9439 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9440 static inline unsigned long __must_check
9441 copy_to_user(void __user *to, const void *from, unsigned long size)
9442 {
9443 - unsigned long ret = ___copy_to_user(to, from, size);
9444 + unsigned long ret;
9445
9446 + if ((long)size < 0 || size > INT_MAX)
9447 + return size;
9448 +
9449 + if (!__builtin_constant_p(size))
9450 + check_object_size(from, size, true);
9451 +
9452 + ret = ___copy_to_user(to, from, size);
9453 if (unlikely(ret))
9454 ret = copy_to_user_fixup(to, from, size);
9455 return ret;
9456 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9457 index d432fb2..6056af1 100644
9458 --- a/arch/sparc/kernel/Makefile
9459 +++ b/arch/sparc/kernel/Makefile
9460 @@ -3,7 +3,7 @@
9461 #
9462
9463 asflags-y := -ansi
9464 -ccflags-y := -Werror
9465 +#ccflags-y := -Werror
9466
9467 extra-y := head_$(BITS).o
9468
9469 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9470 index fdd819d..5af08c8 100644
9471 --- a/arch/sparc/kernel/process_32.c
9472 +++ b/arch/sparc/kernel/process_32.c
9473 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9474
9475 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9476 r->psr, r->pc, r->npc, r->y, print_tainted());
9477 - printk("PC: <%pS>\n", (void *) r->pc);
9478 + printk("PC: <%pA>\n", (void *) r->pc);
9479 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9480 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9481 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9482 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9483 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9484 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9485 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9486 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9487
9488 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9489 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9490 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9491 rw = (struct reg_window32 *) fp;
9492 pc = rw->ins[7];
9493 printk("[%08lx : ", pc);
9494 - printk("%pS ] ", (void *) pc);
9495 + printk("%pA ] ", (void *) pc);
9496 fp = rw->ins[6];
9497 } while (++count < 16);
9498 printk("\n");
9499 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9500 index baebab2..9cd13b1 100644
9501 --- a/arch/sparc/kernel/process_64.c
9502 +++ b/arch/sparc/kernel/process_64.c
9503 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9504 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9505 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9506 if (regs->tstate & TSTATE_PRIV)
9507 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9508 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9509 }
9510
9511 void show_regs(struct pt_regs *regs)
9512 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9513
9514 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9515 regs->tpc, regs->tnpc, regs->y, print_tainted());
9516 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9517 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9518 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9519 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9520 regs->u_regs[3]);
9521 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9522 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9523 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9524 regs->u_regs[15]);
9525 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9526 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9527 show_regwindow(regs);
9528 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9529 }
9530 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9531 ((tp && tp->task) ? tp->task->pid : -1));
9532
9533 if (gp->tstate & TSTATE_PRIV) {
9534 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9535 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9536 (void *) gp->tpc,
9537 (void *) gp->o7,
9538 (void *) gp->i7,
9539 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9540 index 79cc0d1..ec62734 100644
9541 --- a/arch/sparc/kernel/prom_common.c
9542 +++ b/arch/sparc/kernel/prom_common.c
9543 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9544
9545 unsigned int prom_early_allocated __initdata;
9546
9547 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9548 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9549 .nextprop = prom_common_nextprop,
9550 .getproplen = prom_getproplen,
9551 .getproperty = prom_getproperty,
9552 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9553 index 7ff45e4..a58f271 100644
9554 --- a/arch/sparc/kernel/ptrace_64.c
9555 +++ b/arch/sparc/kernel/ptrace_64.c
9556 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9557 return ret;
9558 }
9559
9560 +#ifdef CONFIG_GRKERNSEC_SETXID
9561 +extern void gr_delayed_cred_worker(void);
9562 +#endif
9563 +
9564 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9565 {
9566 int ret = 0;
9567 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9568 /* do the secure computing check first */
9569 secure_computing_strict(regs->u_regs[UREG_G1]);
9570
9571 +#ifdef CONFIG_GRKERNSEC_SETXID
9572 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9573 + gr_delayed_cred_worker();
9574 +#endif
9575 +
9576 if (test_thread_flag(TIF_SYSCALL_TRACE))
9577 ret = tracehook_report_syscall_entry(regs);
9578
9579 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9580
9581 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9582 {
9583 +#ifdef CONFIG_GRKERNSEC_SETXID
9584 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9585 + gr_delayed_cred_worker();
9586 +#endif
9587 +
9588 audit_syscall_exit(regs);
9589
9590 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9591 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9592 index e142545..fd29654 100644
9593 --- a/arch/sparc/kernel/smp_64.c
9594 +++ b/arch/sparc/kernel/smp_64.c
9595 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9596 extern unsigned long xcall_flush_dcache_page_spitfire;
9597
9598 #ifdef CONFIG_DEBUG_DCFLUSH
9599 -extern atomic_t dcpage_flushes;
9600 -extern atomic_t dcpage_flushes_xcall;
9601 +extern atomic_unchecked_t dcpage_flushes;
9602 +extern atomic_unchecked_t dcpage_flushes_xcall;
9603 #endif
9604
9605 static inline void __local_flush_dcache_page(struct page *page)
9606 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9607 return;
9608
9609 #ifdef CONFIG_DEBUG_DCFLUSH
9610 - atomic_inc(&dcpage_flushes);
9611 + atomic_inc_unchecked(&dcpage_flushes);
9612 #endif
9613
9614 this_cpu = get_cpu();
9615 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9616 xcall_deliver(data0, __pa(pg_addr),
9617 (u64) pg_addr, cpumask_of(cpu));
9618 #ifdef CONFIG_DEBUG_DCFLUSH
9619 - atomic_inc(&dcpage_flushes_xcall);
9620 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9621 #endif
9622 }
9623 }
9624 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9625 preempt_disable();
9626
9627 #ifdef CONFIG_DEBUG_DCFLUSH
9628 - atomic_inc(&dcpage_flushes);
9629 + atomic_inc_unchecked(&dcpage_flushes);
9630 #endif
9631 data0 = 0;
9632 pg_addr = page_address(page);
9633 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9634 xcall_deliver(data0, __pa(pg_addr),
9635 (u64) pg_addr, cpu_online_mask);
9636 #ifdef CONFIG_DEBUG_DCFLUSH
9637 - atomic_inc(&dcpage_flushes_xcall);
9638 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9639 #endif
9640 }
9641 __local_flush_dcache_page(page);
9642 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9643 index 3a8d184..49498a8 100644
9644 --- a/arch/sparc/kernel/sys_sparc_32.c
9645 +++ b/arch/sparc/kernel/sys_sparc_32.c
9646 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9647 if (len > TASK_SIZE - PAGE_SIZE)
9648 return -ENOMEM;
9649 if (!addr)
9650 - addr = TASK_UNMAPPED_BASE;
9651 + addr = current->mm->mmap_base;
9652
9653 info.flags = 0;
9654 info.length = len;
9655 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9656 index 51561b8..8256764 100644
9657 --- a/arch/sparc/kernel/sys_sparc_64.c
9658 +++ b/arch/sparc/kernel/sys_sparc_64.c
9659 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9660 struct vm_area_struct * vma;
9661 unsigned long task_size = TASK_SIZE;
9662 int do_color_align;
9663 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9664 struct vm_unmapped_area_info info;
9665
9666 if (flags & MAP_FIXED) {
9667 /* We do not accept a shared mapping if it would violate
9668 * cache aliasing constraints.
9669 */
9670 - if ((flags & MAP_SHARED) &&
9671 + if ((filp || (flags & MAP_SHARED)) &&
9672 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9673 return -EINVAL;
9674 return addr;
9675 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9676 if (filp || (flags & MAP_SHARED))
9677 do_color_align = 1;
9678
9679 +#ifdef CONFIG_PAX_RANDMMAP
9680 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9681 +#endif
9682 +
9683 if (addr) {
9684 if (do_color_align)
9685 addr = COLOR_ALIGN(addr, pgoff);
9686 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9687 addr = PAGE_ALIGN(addr);
9688
9689 vma = find_vma(mm, addr);
9690 - if (task_size - len >= addr &&
9691 - (!vma || addr + len <= vma->vm_start))
9692 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9693 return addr;
9694 }
9695
9696 info.flags = 0;
9697 info.length = len;
9698 - info.low_limit = TASK_UNMAPPED_BASE;
9699 + info.low_limit = mm->mmap_base;
9700 info.high_limit = min(task_size, VA_EXCLUDE_START);
9701 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9702 info.align_offset = pgoff << PAGE_SHIFT;
9703 + info.threadstack_offset = offset;
9704 addr = vm_unmapped_area(&info);
9705
9706 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9707 VM_BUG_ON(addr != -ENOMEM);
9708 info.low_limit = VA_EXCLUDE_END;
9709 +
9710 +#ifdef CONFIG_PAX_RANDMMAP
9711 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9712 + info.low_limit += mm->delta_mmap;
9713 +#endif
9714 +
9715 info.high_limit = task_size;
9716 addr = vm_unmapped_area(&info);
9717 }
9718 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9719 unsigned long task_size = STACK_TOP32;
9720 unsigned long addr = addr0;
9721 int do_color_align;
9722 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9723 struct vm_unmapped_area_info info;
9724
9725 /* This should only ever run for 32-bit processes. */
9726 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9727 /* We do not accept a shared mapping if it would violate
9728 * cache aliasing constraints.
9729 */
9730 - if ((flags & MAP_SHARED) &&
9731 + if ((filp || (flags & MAP_SHARED)) &&
9732 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9733 return -EINVAL;
9734 return addr;
9735 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9736 if (filp || (flags & MAP_SHARED))
9737 do_color_align = 1;
9738
9739 +#ifdef CONFIG_PAX_RANDMMAP
9740 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9741 +#endif
9742 +
9743 /* requesting a specific address */
9744 if (addr) {
9745 if (do_color_align)
9746 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9747 addr = PAGE_ALIGN(addr);
9748
9749 vma = find_vma(mm, addr);
9750 - if (task_size - len >= addr &&
9751 - (!vma || addr + len <= vma->vm_start))
9752 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9753 return addr;
9754 }
9755
9756 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9757 info.high_limit = mm->mmap_base;
9758 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9759 info.align_offset = pgoff << PAGE_SHIFT;
9760 + info.threadstack_offset = offset;
9761 addr = vm_unmapped_area(&info);
9762
9763 /*
9764 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9765 VM_BUG_ON(addr != -ENOMEM);
9766 info.flags = 0;
9767 info.low_limit = TASK_UNMAPPED_BASE;
9768 +
9769 +#ifdef CONFIG_PAX_RANDMMAP
9770 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9771 + info.low_limit += mm->delta_mmap;
9772 +#endif
9773 +
9774 info.high_limit = STACK_TOP32;
9775 addr = vm_unmapped_area(&info);
9776 }
9777 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9778 EXPORT_SYMBOL(get_fb_unmapped_area);
9779
9780 /* Essentially the same as PowerPC. */
9781 -static unsigned long mmap_rnd(void)
9782 +static unsigned long mmap_rnd(struct mm_struct *mm)
9783 {
9784 unsigned long rnd = 0UL;
9785
9786 +#ifdef CONFIG_PAX_RANDMMAP
9787 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9788 +#endif
9789 +
9790 if (current->flags & PF_RANDOMIZE) {
9791 unsigned long val = get_random_int();
9792 if (test_thread_flag(TIF_32BIT))
9793 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9794
9795 void arch_pick_mmap_layout(struct mm_struct *mm)
9796 {
9797 - unsigned long random_factor = mmap_rnd();
9798 + unsigned long random_factor = mmap_rnd(mm);
9799 unsigned long gap;
9800
9801 /*
9802 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9803 gap == RLIM_INFINITY ||
9804 sysctl_legacy_va_layout) {
9805 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9806 +
9807 +#ifdef CONFIG_PAX_RANDMMAP
9808 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9809 + mm->mmap_base += mm->delta_mmap;
9810 +#endif
9811 +
9812 mm->get_unmapped_area = arch_get_unmapped_area;
9813 } else {
9814 /* We know it's 32-bit */
9815 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9816 gap = (task_size / 6 * 5);
9817
9818 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9819 +
9820 +#ifdef CONFIG_PAX_RANDMMAP
9821 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9822 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9823 +#endif
9824 +
9825 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9826 }
9827 }
9828 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9829 index 73ec8a7..4611979 100644
9830 --- a/arch/sparc/kernel/syscalls.S
9831 +++ b/arch/sparc/kernel/syscalls.S
9832 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9833 #endif
9834 .align 32
9835 1: ldx [%g6 + TI_FLAGS], %l5
9836 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9837 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9838 be,pt %icc, rtrap
9839 nop
9840 call syscall_trace_leave
9841 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9842
9843 srl %i3, 0, %o3 ! IEU0
9844 srl %i2, 0, %o2 ! IEU0 Group
9845 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9846 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9847 bne,pn %icc, linux_syscall_trace32 ! CTI
9848 mov %i0, %l5 ! IEU1
9849 5: call %l7 ! CTI Group brk forced
9850 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9851
9852 mov %i3, %o3 ! IEU1
9853 mov %i4, %o4 ! IEU0 Group
9854 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9855 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9856 bne,pn %icc, linux_syscall_trace ! CTI Group
9857 mov %i0, %l5 ! IEU0
9858 2: call %l7 ! CTI Group brk forced
9859 @@ -223,7 +223,7 @@ ret_sys_call:
9860
9861 cmp %o0, -ERESTART_RESTARTBLOCK
9862 bgeu,pn %xcc, 1f
9863 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9864 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9865 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9866
9867 2:
9868 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9869 index 6629829..036032d 100644
9870 --- a/arch/sparc/kernel/traps_32.c
9871 +++ b/arch/sparc/kernel/traps_32.c
9872 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9873 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9874 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9875
9876 +extern void gr_handle_kernel_exploit(void);
9877 +
9878 void die_if_kernel(char *str, struct pt_regs *regs)
9879 {
9880 static int die_counter;
9881 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9882 count++ < 30 &&
9883 (((unsigned long) rw) >= PAGE_OFFSET) &&
9884 !(((unsigned long) rw) & 0x7)) {
9885 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9886 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9887 (void *) rw->ins[7]);
9888 rw = (struct reg_window32 *)rw->ins[6];
9889 }
9890 }
9891 printk("Instruction DUMP:");
9892 instruction_dump ((unsigned long *) regs->pc);
9893 - if(regs->psr & PSR_PS)
9894 + if(regs->psr & PSR_PS) {
9895 + gr_handle_kernel_exploit();
9896 do_exit(SIGKILL);
9897 + }
9898 do_exit(SIGSEGV);
9899 }
9900
9901 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9902 index b3f833a..f485f80 100644
9903 --- a/arch/sparc/kernel/traps_64.c
9904 +++ b/arch/sparc/kernel/traps_64.c
9905 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9906 i + 1,
9907 p->trapstack[i].tstate, p->trapstack[i].tpc,
9908 p->trapstack[i].tnpc, p->trapstack[i].tt);
9909 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9910 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9911 }
9912 }
9913
9914 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9915
9916 lvl -= 0x100;
9917 if (regs->tstate & TSTATE_PRIV) {
9918 +
9919 +#ifdef CONFIG_PAX_REFCOUNT
9920 + if (lvl == 6)
9921 + pax_report_refcount_overflow(regs);
9922 +#endif
9923 +
9924 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9925 die_if_kernel(buffer, regs);
9926 }
9927 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9928 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9929 {
9930 char buffer[32];
9931 -
9932 +
9933 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9934 0, lvl, SIGTRAP) == NOTIFY_STOP)
9935 return;
9936
9937 +#ifdef CONFIG_PAX_REFCOUNT
9938 + if (lvl == 6)
9939 + pax_report_refcount_overflow(regs);
9940 +#endif
9941 +
9942 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9943
9944 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9945 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9946 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9947 printk("%s" "ERROR(%d): ",
9948 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9949 - printk("TPC<%pS>\n", (void *) regs->tpc);
9950 + printk("TPC<%pA>\n", (void *) regs->tpc);
9951 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9952 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9953 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9954 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9955 smp_processor_id(),
9956 (type & 0x1) ? 'I' : 'D',
9957 regs->tpc);
9958 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9959 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9960 panic("Irrecoverable Cheetah+ parity error.");
9961 }
9962
9963 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9964 smp_processor_id(),
9965 (type & 0x1) ? 'I' : 'D',
9966 regs->tpc);
9967 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9968 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9969 }
9970
9971 struct sun4v_error_entry {
9972 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9973 /*0x38*/u64 reserved_5;
9974 };
9975
9976 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9977 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9978 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9979 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9980
9981 static const char *sun4v_err_type_to_str(u8 type)
9982 {
9983 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9984 }
9985
9986 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9987 - int cpu, const char *pfx, atomic_t *ocnt)
9988 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9989 {
9990 u64 *raw_ptr = (u64 *) ent;
9991 u32 attrs;
9992 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9993
9994 show_regs(regs);
9995
9996 - if ((cnt = atomic_read(ocnt)) != 0) {
9997 - atomic_set(ocnt, 0);
9998 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9999 + atomic_set_unchecked(ocnt, 0);
10000 wmb();
10001 printk("%s: Queue overflowed %d times.\n",
10002 pfx, cnt);
10003 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10004 */
10005 void sun4v_resum_overflow(struct pt_regs *regs)
10006 {
10007 - atomic_inc(&sun4v_resum_oflow_cnt);
10008 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10009 }
10010
10011 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10012 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10013 /* XXX Actually even this can make not that much sense. Perhaps
10014 * XXX we should just pull the plug and panic directly from here?
10015 */
10016 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10017 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10018 }
10019
10020 unsigned long sun4v_err_itlb_vaddr;
10021 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10022
10023 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10024 regs->tpc, tl);
10025 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10026 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10027 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10028 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10029 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10030 (void *) regs->u_regs[UREG_I7]);
10031 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10032 "pte[%lx] error[%lx]\n",
10033 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10034
10035 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10036 regs->tpc, tl);
10037 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10038 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10039 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10040 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10041 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10042 (void *) regs->u_regs[UREG_I7]);
10043 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10044 "pte[%lx] error[%lx]\n",
10045 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10046 fp = (unsigned long)sf->fp + STACK_BIAS;
10047 }
10048
10049 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10050 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10051 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10052 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10053 int index = tsk->curr_ret_stack;
10054 if (tsk->ret_stack && index >= graph) {
10055 pc = tsk->ret_stack[index - graph].ret;
10056 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10057 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10058 graph++;
10059 }
10060 }
10061 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10062 return (struct reg_window *) (fp + STACK_BIAS);
10063 }
10064
10065 +extern void gr_handle_kernel_exploit(void);
10066 +
10067 void die_if_kernel(char *str, struct pt_regs *regs)
10068 {
10069 static int die_counter;
10070 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10071 while (rw &&
10072 count++ < 30 &&
10073 kstack_valid(tp, (unsigned long) rw)) {
10074 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10075 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10076 (void *) rw->ins[7]);
10077
10078 rw = kernel_stack_up(rw);
10079 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10080 }
10081 user_instruction_dump ((unsigned int __user *) regs->tpc);
10082 }
10083 - if (regs->tstate & TSTATE_PRIV)
10084 + if (regs->tstate & TSTATE_PRIV) {
10085 + gr_handle_kernel_exploit();
10086 do_exit(SIGKILL);
10087 + }
10088 do_exit(SIGSEGV);
10089 }
10090 EXPORT_SYMBOL(die_if_kernel);
10091 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10092 index 8201c25e..072a2a7 100644
10093 --- a/arch/sparc/kernel/unaligned_64.c
10094 +++ b/arch/sparc/kernel/unaligned_64.c
10095 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10096 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10097
10098 if (__ratelimit(&ratelimit)) {
10099 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10100 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10101 regs->tpc, (void *) regs->tpc);
10102 }
10103 }
10104 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10105 index dbe119b..089c7c1 100644
10106 --- a/arch/sparc/lib/Makefile
10107 +++ b/arch/sparc/lib/Makefile
10108 @@ -2,7 +2,7 @@
10109 #
10110
10111 asflags-y := -ansi -DST_DIV0=0x02
10112 -ccflags-y := -Werror
10113 +#ccflags-y := -Werror
10114
10115 lib-$(CONFIG_SPARC32) += ashrdi3.o
10116 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10117 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10118 index 85c233d..68500e0 100644
10119 --- a/arch/sparc/lib/atomic_64.S
10120 +++ b/arch/sparc/lib/atomic_64.S
10121 @@ -17,7 +17,12 @@
10122 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10123 BACKOFF_SETUP(%o2)
10124 1: lduw [%o1], %g1
10125 - add %g1, %o0, %g7
10126 + addcc %g1, %o0, %g7
10127 +
10128 +#ifdef CONFIG_PAX_REFCOUNT
10129 + tvs %icc, 6
10130 +#endif
10131 +
10132 cas [%o1], %g1, %g7
10133 cmp %g1, %g7
10134 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10135 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10136 2: BACKOFF_SPIN(%o2, %o3, 1b)
10137 ENDPROC(atomic_add)
10138
10139 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10140 + BACKOFF_SETUP(%o2)
10141 +1: lduw [%o1], %g1
10142 + add %g1, %o0, %g7
10143 + cas [%o1], %g1, %g7
10144 + cmp %g1, %g7
10145 + bne,pn %icc, 2f
10146 + nop
10147 + retl
10148 + nop
10149 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10150 +ENDPROC(atomic_add_unchecked)
10151 +
10152 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10153 BACKOFF_SETUP(%o2)
10154 1: lduw [%o1], %g1
10155 - sub %g1, %o0, %g7
10156 + subcc %g1, %o0, %g7
10157 +
10158 +#ifdef CONFIG_PAX_REFCOUNT
10159 + tvs %icc, 6
10160 +#endif
10161 +
10162 cas [%o1], %g1, %g7
10163 cmp %g1, %g7
10164 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10165 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10166 2: BACKOFF_SPIN(%o2, %o3, 1b)
10167 ENDPROC(atomic_sub)
10168
10169 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10170 + BACKOFF_SETUP(%o2)
10171 +1: lduw [%o1], %g1
10172 + sub %g1, %o0, %g7
10173 + cas [%o1], %g1, %g7
10174 + cmp %g1, %g7
10175 + bne,pn %icc, 2f
10176 + nop
10177 + retl
10178 + nop
10179 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10180 +ENDPROC(atomic_sub_unchecked)
10181 +
10182 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10183 BACKOFF_SETUP(%o2)
10184 1: lduw [%o1], %g1
10185 - add %g1, %o0, %g7
10186 + addcc %g1, %o0, %g7
10187 +
10188 +#ifdef CONFIG_PAX_REFCOUNT
10189 + tvs %icc, 6
10190 +#endif
10191 +
10192 cas [%o1], %g1, %g7
10193 cmp %g1, %g7
10194 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10195 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10196 2: BACKOFF_SPIN(%o2, %o3, 1b)
10197 ENDPROC(atomic_add_ret)
10198
10199 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10200 + BACKOFF_SETUP(%o2)
10201 +1: lduw [%o1], %g1
10202 + addcc %g1, %o0, %g7
10203 + cas [%o1], %g1, %g7
10204 + cmp %g1, %g7
10205 + bne,pn %icc, 2f
10206 + add %g7, %o0, %g7
10207 + sra %g7, 0, %o0
10208 + retl
10209 + nop
10210 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10211 +ENDPROC(atomic_add_ret_unchecked)
10212 +
10213 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10214 BACKOFF_SETUP(%o2)
10215 1: lduw [%o1], %g1
10216 - sub %g1, %o0, %g7
10217 + subcc %g1, %o0, %g7
10218 +
10219 +#ifdef CONFIG_PAX_REFCOUNT
10220 + tvs %icc, 6
10221 +#endif
10222 +
10223 cas [%o1], %g1, %g7
10224 cmp %g1, %g7
10225 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10226 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10227 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10228 BACKOFF_SETUP(%o2)
10229 1: ldx [%o1], %g1
10230 - add %g1, %o0, %g7
10231 + addcc %g1, %o0, %g7
10232 +
10233 +#ifdef CONFIG_PAX_REFCOUNT
10234 + tvs %xcc, 6
10235 +#endif
10236 +
10237 casx [%o1], %g1, %g7
10238 cmp %g1, %g7
10239 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10240 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10241 2: BACKOFF_SPIN(%o2, %o3, 1b)
10242 ENDPROC(atomic64_add)
10243
10244 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10245 + BACKOFF_SETUP(%o2)
10246 +1: ldx [%o1], %g1
10247 + addcc %g1, %o0, %g7
10248 + casx [%o1], %g1, %g7
10249 + cmp %g1, %g7
10250 + bne,pn %xcc, 2f
10251 + nop
10252 + retl
10253 + nop
10254 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10255 +ENDPROC(atomic64_add_unchecked)
10256 +
10257 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10258 BACKOFF_SETUP(%o2)
10259 1: ldx [%o1], %g1
10260 - sub %g1, %o0, %g7
10261 + subcc %g1, %o0, %g7
10262 +
10263 +#ifdef CONFIG_PAX_REFCOUNT
10264 + tvs %xcc, 6
10265 +#endif
10266 +
10267 casx [%o1], %g1, %g7
10268 cmp %g1, %g7
10269 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10270 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10271 2: BACKOFF_SPIN(%o2, %o3, 1b)
10272 ENDPROC(atomic64_sub)
10273
10274 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10275 + BACKOFF_SETUP(%o2)
10276 +1: ldx [%o1], %g1
10277 + subcc %g1, %o0, %g7
10278 + casx [%o1], %g1, %g7
10279 + cmp %g1, %g7
10280 + bne,pn %xcc, 2f
10281 + nop
10282 + retl
10283 + nop
10284 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10285 +ENDPROC(atomic64_sub_unchecked)
10286 +
10287 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10288 BACKOFF_SETUP(%o2)
10289 1: ldx [%o1], %g1
10290 - add %g1, %o0, %g7
10291 + addcc %g1, %o0, %g7
10292 +
10293 +#ifdef CONFIG_PAX_REFCOUNT
10294 + tvs %xcc, 6
10295 +#endif
10296 +
10297 casx [%o1], %g1, %g7
10298 cmp %g1, %g7
10299 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10300 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10301 2: BACKOFF_SPIN(%o2, %o3, 1b)
10302 ENDPROC(atomic64_add_ret)
10303
10304 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10305 + BACKOFF_SETUP(%o2)
10306 +1: ldx [%o1], %g1
10307 + addcc %g1, %o0, %g7
10308 + casx [%o1], %g1, %g7
10309 + cmp %g1, %g7
10310 + bne,pn %xcc, 2f
10311 + add %g7, %o0, %g7
10312 + mov %g7, %o0
10313 + retl
10314 + nop
10315 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10316 +ENDPROC(atomic64_add_ret_unchecked)
10317 +
10318 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10319 BACKOFF_SETUP(%o2)
10320 1: ldx [%o1], %g1
10321 - sub %g1, %o0, %g7
10322 + subcc %g1, %o0, %g7
10323 +
10324 +#ifdef CONFIG_PAX_REFCOUNT
10325 + tvs %xcc, 6
10326 +#endif
10327 +
10328 casx [%o1], %g1, %g7
10329 cmp %g1, %g7
10330 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10331 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10332 index 323335b..ed85ea2 100644
10333 --- a/arch/sparc/lib/ksyms.c
10334 +++ b/arch/sparc/lib/ksyms.c
10335 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10336
10337 /* Atomic counter implementation. */
10338 EXPORT_SYMBOL(atomic_add);
10339 +EXPORT_SYMBOL(atomic_add_unchecked);
10340 EXPORT_SYMBOL(atomic_add_ret);
10341 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10342 EXPORT_SYMBOL(atomic_sub);
10343 +EXPORT_SYMBOL(atomic_sub_unchecked);
10344 EXPORT_SYMBOL(atomic_sub_ret);
10345 EXPORT_SYMBOL(atomic64_add);
10346 +EXPORT_SYMBOL(atomic64_add_unchecked);
10347 EXPORT_SYMBOL(atomic64_add_ret);
10348 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10349 EXPORT_SYMBOL(atomic64_sub);
10350 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10351 EXPORT_SYMBOL(atomic64_sub_ret);
10352 EXPORT_SYMBOL(atomic64_dec_if_positive);
10353
10354 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10355 index 30c3ecc..736f015 100644
10356 --- a/arch/sparc/mm/Makefile
10357 +++ b/arch/sparc/mm/Makefile
10358 @@ -2,7 +2,7 @@
10359 #
10360
10361 asflags-y := -ansi
10362 -ccflags-y := -Werror
10363 +#ccflags-y := -Werror
10364
10365 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10366 obj-y += fault_$(BITS).o
10367 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10368 index e98bfda..ea8d221 100644
10369 --- a/arch/sparc/mm/fault_32.c
10370 +++ b/arch/sparc/mm/fault_32.c
10371 @@ -21,6 +21,9 @@
10372 #include <linux/perf_event.h>
10373 #include <linux/interrupt.h>
10374 #include <linux/kdebug.h>
10375 +#include <linux/slab.h>
10376 +#include <linux/pagemap.h>
10377 +#include <linux/compiler.h>
10378
10379 #include <asm/page.h>
10380 #include <asm/pgtable.h>
10381 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10382 return safe_compute_effective_address(regs, insn);
10383 }
10384
10385 +#ifdef CONFIG_PAX_PAGEEXEC
10386 +#ifdef CONFIG_PAX_DLRESOLVE
10387 +static void pax_emuplt_close(struct vm_area_struct *vma)
10388 +{
10389 + vma->vm_mm->call_dl_resolve = 0UL;
10390 +}
10391 +
10392 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10393 +{
10394 + unsigned int *kaddr;
10395 +
10396 + vmf->page = alloc_page(GFP_HIGHUSER);
10397 + if (!vmf->page)
10398 + return VM_FAULT_OOM;
10399 +
10400 + kaddr = kmap(vmf->page);
10401 + memset(kaddr, 0, PAGE_SIZE);
10402 + kaddr[0] = 0x9DE3BFA8U; /* save */
10403 + flush_dcache_page(vmf->page);
10404 + kunmap(vmf->page);
10405 + return VM_FAULT_MAJOR;
10406 +}
10407 +
10408 +static const struct vm_operations_struct pax_vm_ops = {
10409 + .close = pax_emuplt_close,
10410 + .fault = pax_emuplt_fault
10411 +};
10412 +
10413 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10414 +{
10415 + int ret;
10416 +
10417 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10418 + vma->vm_mm = current->mm;
10419 + vma->vm_start = addr;
10420 + vma->vm_end = addr + PAGE_SIZE;
10421 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10422 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10423 + vma->vm_ops = &pax_vm_ops;
10424 +
10425 + ret = insert_vm_struct(current->mm, vma);
10426 + if (ret)
10427 + return ret;
10428 +
10429 + ++current->mm->total_vm;
10430 + return 0;
10431 +}
10432 +#endif
10433 +
10434 +/*
10435 + * PaX: decide what to do with offenders (regs->pc = fault address)
10436 + *
10437 + * returns 1 when task should be killed
10438 + * 2 when patched PLT trampoline was detected
10439 + * 3 when unpatched PLT trampoline was detected
10440 + */
10441 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10442 +{
10443 +
10444 +#ifdef CONFIG_PAX_EMUPLT
10445 + int err;
10446 +
10447 + do { /* PaX: patched PLT emulation #1 */
10448 + unsigned int sethi1, sethi2, jmpl;
10449 +
10450 + err = get_user(sethi1, (unsigned int *)regs->pc);
10451 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10452 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10453 +
10454 + if (err)
10455 + break;
10456 +
10457 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10458 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10459 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10460 + {
10461 + unsigned int addr;
10462 +
10463 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10464 + addr = regs->u_regs[UREG_G1];
10465 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10466 + regs->pc = addr;
10467 + regs->npc = addr+4;
10468 + return 2;
10469 + }
10470 + } while (0);
10471 +
10472 + do { /* PaX: patched PLT emulation #2 */
10473 + unsigned int ba;
10474 +
10475 + err = get_user(ba, (unsigned int *)regs->pc);
10476 +
10477 + if (err)
10478 + break;
10479 +
10480 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10481 + unsigned int addr;
10482 +
10483 + if ((ba & 0xFFC00000U) == 0x30800000U)
10484 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10485 + else
10486 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10487 + regs->pc = addr;
10488 + regs->npc = addr+4;
10489 + return 2;
10490 + }
10491 + } while (0);
10492 +
10493 + do { /* PaX: patched PLT emulation #3 */
10494 + unsigned int sethi, bajmpl, nop;
10495 +
10496 + err = get_user(sethi, (unsigned int *)regs->pc);
10497 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10498 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10499 +
10500 + if (err)
10501 + break;
10502 +
10503 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10504 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10505 + nop == 0x01000000U)
10506 + {
10507 + unsigned int addr;
10508 +
10509 + addr = (sethi & 0x003FFFFFU) << 10;
10510 + regs->u_regs[UREG_G1] = addr;
10511 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10512 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10513 + else
10514 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10515 + regs->pc = addr;
10516 + regs->npc = addr+4;
10517 + return 2;
10518 + }
10519 + } while (0);
10520 +
10521 + do { /* PaX: unpatched PLT emulation step 1 */
10522 + unsigned int sethi, ba, nop;
10523 +
10524 + err = get_user(sethi, (unsigned int *)regs->pc);
10525 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10526 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10527 +
10528 + if (err)
10529 + break;
10530 +
10531 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10532 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10533 + nop == 0x01000000U)
10534 + {
10535 + unsigned int addr, save, call;
10536 +
10537 + if ((ba & 0xFFC00000U) == 0x30800000U)
10538 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10539 + else
10540 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10541 +
10542 + err = get_user(save, (unsigned int *)addr);
10543 + err |= get_user(call, (unsigned int *)(addr+4));
10544 + err |= get_user(nop, (unsigned int *)(addr+8));
10545 + if (err)
10546 + break;
10547 +
10548 +#ifdef CONFIG_PAX_DLRESOLVE
10549 + if (save == 0x9DE3BFA8U &&
10550 + (call & 0xC0000000U) == 0x40000000U &&
10551 + nop == 0x01000000U)
10552 + {
10553 + struct vm_area_struct *vma;
10554 + unsigned long call_dl_resolve;
10555 +
10556 + down_read(&current->mm->mmap_sem);
10557 + call_dl_resolve = current->mm->call_dl_resolve;
10558 + up_read(&current->mm->mmap_sem);
10559 + if (likely(call_dl_resolve))
10560 + goto emulate;
10561 +
10562 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10563 +
10564 + down_write(&current->mm->mmap_sem);
10565 + if (current->mm->call_dl_resolve) {
10566 + call_dl_resolve = current->mm->call_dl_resolve;
10567 + up_write(&current->mm->mmap_sem);
10568 + if (vma)
10569 + kmem_cache_free(vm_area_cachep, vma);
10570 + goto emulate;
10571 + }
10572 +
10573 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10574 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10575 + up_write(&current->mm->mmap_sem);
10576 + if (vma)
10577 + kmem_cache_free(vm_area_cachep, vma);
10578 + return 1;
10579 + }
10580 +
10581 + if (pax_insert_vma(vma, call_dl_resolve)) {
10582 + up_write(&current->mm->mmap_sem);
10583 + kmem_cache_free(vm_area_cachep, vma);
10584 + return 1;
10585 + }
10586 +
10587 + current->mm->call_dl_resolve = call_dl_resolve;
10588 + up_write(&current->mm->mmap_sem);
10589 +
10590 +emulate:
10591 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10592 + regs->pc = call_dl_resolve;
10593 + regs->npc = addr+4;
10594 + return 3;
10595 + }
10596 +#endif
10597 +
10598 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10599 + if ((save & 0xFFC00000U) == 0x05000000U &&
10600 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10604 + regs->u_regs[UREG_G2] = addr + 4;
10605 + addr = (save & 0x003FFFFFU) << 10;
10606 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10607 + regs->pc = addr;
10608 + regs->npc = addr+4;
10609 + return 3;
10610 + }
10611 + }
10612 + } while (0);
10613 +
10614 + do { /* PaX: unpatched PLT emulation step 2 */
10615 + unsigned int save, call, nop;
10616 +
10617 + err = get_user(save, (unsigned int *)(regs->pc-4));
10618 + err |= get_user(call, (unsigned int *)regs->pc);
10619 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10620 + if (err)
10621 + break;
10622 +
10623 + if (save == 0x9DE3BFA8U &&
10624 + (call & 0xC0000000U) == 0x40000000U &&
10625 + nop == 0x01000000U)
10626 + {
10627 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10628 +
10629 + regs->u_regs[UREG_RETPC] = regs->pc;
10630 + regs->pc = dl_resolve;
10631 + regs->npc = dl_resolve+4;
10632 + return 3;
10633 + }
10634 + } while (0);
10635 +#endif
10636 +
10637 + return 1;
10638 +}
10639 +
10640 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10641 +{
10642 + unsigned long i;
10643 +
10644 + printk(KERN_ERR "PAX: bytes at PC: ");
10645 + for (i = 0; i < 8; i++) {
10646 + unsigned int c;
10647 + if (get_user(c, (unsigned int *)pc+i))
10648 + printk(KERN_CONT "???????? ");
10649 + else
10650 + printk(KERN_CONT "%08x ", c);
10651 + }
10652 + printk("\n");
10653 +}
10654 +#endif
10655 +
10656 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10657 int text_fault)
10658 {
10659 @@ -230,6 +504,24 @@ good_area:
10660 if (!(vma->vm_flags & VM_WRITE))
10661 goto bad_area;
10662 } else {
10663 +
10664 +#ifdef CONFIG_PAX_PAGEEXEC
10665 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10666 + up_read(&mm->mmap_sem);
10667 + switch (pax_handle_fetch_fault(regs)) {
10668 +
10669 +#ifdef CONFIG_PAX_EMUPLT
10670 + case 2:
10671 + case 3:
10672 + return;
10673 +#endif
10674 +
10675 + }
10676 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10677 + do_group_exit(SIGKILL);
10678 + }
10679 +#endif
10680 +
10681 /* Allow reads even for write-only mappings */
10682 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10683 goto bad_area;
10684 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10685 index 5062ff3..e0b75f3 100644
10686 --- a/arch/sparc/mm/fault_64.c
10687 +++ b/arch/sparc/mm/fault_64.c
10688 @@ -21,6 +21,9 @@
10689 #include <linux/kprobes.h>
10690 #include <linux/kdebug.h>
10691 #include <linux/percpu.h>
10692 +#include <linux/slab.h>
10693 +#include <linux/pagemap.h>
10694 +#include <linux/compiler.h>
10695
10696 #include <asm/page.h>
10697 #include <asm/pgtable.h>
10698 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10699 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10700 regs->tpc);
10701 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10702 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10703 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10704 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10705 dump_stack();
10706 unhandled_fault(regs->tpc, current, regs);
10707 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10708 show_regs(regs);
10709 }
10710
10711 +#ifdef CONFIG_PAX_PAGEEXEC
10712 +#ifdef CONFIG_PAX_DLRESOLVE
10713 +static void pax_emuplt_close(struct vm_area_struct *vma)
10714 +{
10715 + vma->vm_mm->call_dl_resolve = 0UL;
10716 +}
10717 +
10718 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10719 +{
10720 + unsigned int *kaddr;
10721 +
10722 + vmf->page = alloc_page(GFP_HIGHUSER);
10723 + if (!vmf->page)
10724 + return VM_FAULT_OOM;
10725 +
10726 + kaddr = kmap(vmf->page);
10727 + memset(kaddr, 0, PAGE_SIZE);
10728 + kaddr[0] = 0x9DE3BFA8U; /* save */
10729 + flush_dcache_page(vmf->page);
10730 + kunmap(vmf->page);
10731 + return VM_FAULT_MAJOR;
10732 +}
10733 +
10734 +static const struct vm_operations_struct pax_vm_ops = {
10735 + .close = pax_emuplt_close,
10736 + .fault = pax_emuplt_fault
10737 +};
10738 +
10739 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10740 +{
10741 + int ret;
10742 +
10743 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10744 + vma->vm_mm = current->mm;
10745 + vma->vm_start = addr;
10746 + vma->vm_end = addr + PAGE_SIZE;
10747 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10748 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10749 + vma->vm_ops = &pax_vm_ops;
10750 +
10751 + ret = insert_vm_struct(current->mm, vma);
10752 + if (ret)
10753 + return ret;
10754 +
10755 + ++current->mm->total_vm;
10756 + return 0;
10757 +}
10758 +#endif
10759 +
10760 +/*
10761 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10762 + *
10763 + * returns 1 when task should be killed
10764 + * 2 when patched PLT trampoline was detected
10765 + * 3 when unpatched PLT trampoline was detected
10766 + */
10767 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10768 +{
10769 +
10770 +#ifdef CONFIG_PAX_EMUPLT
10771 + int err;
10772 +
10773 + do { /* PaX: patched PLT emulation #1 */
10774 + unsigned int sethi1, sethi2, jmpl;
10775 +
10776 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10777 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10778 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10779 +
10780 + if (err)
10781 + break;
10782 +
10783 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10784 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10785 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10786 + {
10787 + unsigned long addr;
10788 +
10789 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10790 + addr = regs->u_regs[UREG_G1];
10791 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10792 +
10793 + if (test_thread_flag(TIF_32BIT))
10794 + addr &= 0xFFFFFFFFUL;
10795 +
10796 + regs->tpc = addr;
10797 + regs->tnpc = addr+4;
10798 + return 2;
10799 + }
10800 + } while (0);
10801 +
10802 + do { /* PaX: patched PLT emulation #2 */
10803 + unsigned int ba;
10804 +
10805 + err = get_user(ba, (unsigned int *)regs->tpc);
10806 +
10807 + if (err)
10808 + break;
10809 +
10810 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10811 + unsigned long addr;
10812 +
10813 + if ((ba & 0xFFC00000U) == 0x30800000U)
10814 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10815 + else
10816 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10817 +
10818 + if (test_thread_flag(TIF_32BIT))
10819 + addr &= 0xFFFFFFFFUL;
10820 +
10821 + regs->tpc = addr;
10822 + regs->tnpc = addr+4;
10823 + return 2;
10824 + }
10825 + } while (0);
10826 +
10827 + do { /* PaX: patched PLT emulation #3 */
10828 + unsigned int sethi, bajmpl, nop;
10829 +
10830 + err = get_user(sethi, (unsigned int *)regs->tpc);
10831 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10832 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10833 +
10834 + if (err)
10835 + break;
10836 +
10837 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10838 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10839 + nop == 0x01000000U)
10840 + {
10841 + unsigned long addr;
10842 +
10843 + addr = (sethi & 0x003FFFFFU) << 10;
10844 + regs->u_regs[UREG_G1] = addr;
10845 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10846 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10847 + else
10848 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10849 +
10850 + if (test_thread_flag(TIF_32BIT))
10851 + addr &= 0xFFFFFFFFUL;
10852 +
10853 + regs->tpc = addr;
10854 + regs->tnpc = addr+4;
10855 + return 2;
10856 + }
10857 + } while (0);
10858 +
10859 + do { /* PaX: patched PLT emulation #4 */
10860 + unsigned int sethi, mov1, call, mov2;
10861 +
10862 + err = get_user(sethi, (unsigned int *)regs->tpc);
10863 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10864 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10865 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10866 +
10867 + if (err)
10868 + break;
10869 +
10870 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10871 + mov1 == 0x8210000FU &&
10872 + (call & 0xC0000000U) == 0x40000000U &&
10873 + mov2 == 0x9E100001U)
10874 + {
10875 + unsigned long addr;
10876 +
10877 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10878 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10879 +
10880 + if (test_thread_flag(TIF_32BIT))
10881 + addr &= 0xFFFFFFFFUL;
10882 +
10883 + regs->tpc = addr;
10884 + regs->tnpc = addr+4;
10885 + return 2;
10886 + }
10887 + } while (0);
10888 +
10889 + do { /* PaX: patched PLT emulation #5 */
10890 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10891 +
10892 + err = get_user(sethi, (unsigned int *)regs->tpc);
10893 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10894 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10895 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10896 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10897 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10898 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10899 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10900 +
10901 + if (err)
10902 + break;
10903 +
10904 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10905 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10906 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10907 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10908 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10909 + sllx == 0x83287020U &&
10910 + jmpl == 0x81C04005U &&
10911 + nop == 0x01000000U)
10912 + {
10913 + unsigned long addr;
10914 +
10915 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10916 + regs->u_regs[UREG_G1] <<= 32;
10917 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10918 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10919 + regs->tpc = addr;
10920 + regs->tnpc = addr+4;
10921 + return 2;
10922 + }
10923 + } while (0);
10924 +
10925 + do { /* PaX: patched PLT emulation #6 */
10926 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10927 +
10928 + err = get_user(sethi, (unsigned int *)regs->tpc);
10929 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10930 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10931 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10932 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10933 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10934 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10935 +
10936 + if (err)
10937 + break;
10938 +
10939 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10940 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10941 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10942 + sllx == 0x83287020U &&
10943 + (or & 0xFFFFE000U) == 0x8A116000U &&
10944 + jmpl == 0x81C04005U &&
10945 + nop == 0x01000000U)
10946 + {
10947 + unsigned long addr;
10948 +
10949 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10950 + regs->u_regs[UREG_G1] <<= 32;
10951 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10952 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10953 + regs->tpc = addr;
10954 + regs->tnpc = addr+4;
10955 + return 2;
10956 + }
10957 + } while (0);
10958 +
10959 + do { /* PaX: unpatched PLT emulation step 1 */
10960 + unsigned int sethi, ba, nop;
10961 +
10962 + err = get_user(sethi, (unsigned int *)regs->tpc);
10963 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10964 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10965 +
10966 + if (err)
10967 + break;
10968 +
10969 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10970 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10971 + nop == 0x01000000U)
10972 + {
10973 + unsigned long addr;
10974 + unsigned int save, call;
10975 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10976 +
10977 + if ((ba & 0xFFC00000U) == 0x30800000U)
10978 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10979 + else
10980 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10981 +
10982 + if (test_thread_flag(TIF_32BIT))
10983 + addr &= 0xFFFFFFFFUL;
10984 +
10985 + err = get_user(save, (unsigned int *)addr);
10986 + err |= get_user(call, (unsigned int *)(addr+4));
10987 + err |= get_user(nop, (unsigned int *)(addr+8));
10988 + if (err)
10989 + break;
10990 +
10991 +#ifdef CONFIG_PAX_DLRESOLVE
10992 + if (save == 0x9DE3BFA8U &&
10993 + (call & 0xC0000000U) == 0x40000000U &&
10994 + nop == 0x01000000U)
10995 + {
10996 + struct vm_area_struct *vma;
10997 + unsigned long call_dl_resolve;
10998 +
10999 + down_read(&current->mm->mmap_sem);
11000 + call_dl_resolve = current->mm->call_dl_resolve;
11001 + up_read(&current->mm->mmap_sem);
11002 + if (likely(call_dl_resolve))
11003 + goto emulate;
11004 +
11005 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11006 +
11007 + down_write(&current->mm->mmap_sem);
11008 + if (current->mm->call_dl_resolve) {
11009 + call_dl_resolve = current->mm->call_dl_resolve;
11010 + up_write(&current->mm->mmap_sem);
11011 + if (vma)
11012 + kmem_cache_free(vm_area_cachep, vma);
11013 + goto emulate;
11014 + }
11015 +
11016 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11017 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11018 + up_write(&current->mm->mmap_sem);
11019 + if (vma)
11020 + kmem_cache_free(vm_area_cachep, vma);
11021 + return 1;
11022 + }
11023 +
11024 + if (pax_insert_vma(vma, call_dl_resolve)) {
11025 + up_write(&current->mm->mmap_sem);
11026 + kmem_cache_free(vm_area_cachep, vma);
11027 + return 1;
11028 + }
11029 +
11030 + current->mm->call_dl_resolve = call_dl_resolve;
11031 + up_write(&current->mm->mmap_sem);
11032 +
11033 +emulate:
11034 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11035 + regs->tpc = call_dl_resolve;
11036 + regs->tnpc = addr+4;
11037 + return 3;
11038 + }
11039 +#endif
11040 +
11041 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11042 + if ((save & 0xFFC00000U) == 0x05000000U &&
11043 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11044 + nop == 0x01000000U)
11045 + {
11046 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11047 + regs->u_regs[UREG_G2] = addr + 4;
11048 + addr = (save & 0x003FFFFFU) << 10;
11049 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11050 +
11051 + if (test_thread_flag(TIF_32BIT))
11052 + addr &= 0xFFFFFFFFUL;
11053 +
11054 + regs->tpc = addr;
11055 + regs->tnpc = addr+4;
11056 + return 3;
11057 + }
11058 +
11059 + /* PaX: 64-bit PLT stub */
11060 + err = get_user(sethi1, (unsigned int *)addr);
11061 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11062 + err |= get_user(or1, (unsigned int *)(addr+8));
11063 + err |= get_user(or2, (unsigned int *)(addr+12));
11064 + err |= get_user(sllx, (unsigned int *)(addr+16));
11065 + err |= get_user(add, (unsigned int *)(addr+20));
11066 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11067 + err |= get_user(nop, (unsigned int *)(addr+28));
11068 + if (err)
11069 + break;
11070 +
11071 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11072 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11073 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11074 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11075 + sllx == 0x89293020U &&
11076 + add == 0x8A010005U &&
11077 + jmpl == 0x89C14000U &&
11078 + nop == 0x01000000U)
11079 + {
11080 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11081 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11082 + regs->u_regs[UREG_G4] <<= 32;
11083 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11084 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11085 + regs->u_regs[UREG_G4] = addr + 24;
11086 + addr = regs->u_regs[UREG_G5];
11087 + regs->tpc = addr;
11088 + regs->tnpc = addr+4;
11089 + return 3;
11090 + }
11091 + }
11092 + } while (0);
11093 +
11094 +#ifdef CONFIG_PAX_DLRESOLVE
11095 + do { /* PaX: unpatched PLT emulation step 2 */
11096 + unsigned int save, call, nop;
11097 +
11098 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11099 + err |= get_user(call, (unsigned int *)regs->tpc);
11100 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11101 + if (err)
11102 + break;
11103 +
11104 + if (save == 0x9DE3BFA8U &&
11105 + (call & 0xC0000000U) == 0x40000000U &&
11106 + nop == 0x01000000U)
11107 + {
11108 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11109 +
11110 + if (test_thread_flag(TIF_32BIT))
11111 + dl_resolve &= 0xFFFFFFFFUL;
11112 +
11113 + regs->u_regs[UREG_RETPC] = regs->tpc;
11114 + regs->tpc = dl_resolve;
11115 + regs->tnpc = dl_resolve+4;
11116 + return 3;
11117 + }
11118 + } while (0);
11119 +#endif
11120 +
11121 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11122 + unsigned int sethi, ba, nop;
11123 +
11124 + err = get_user(sethi, (unsigned int *)regs->tpc);
11125 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11126 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11127 +
11128 + if (err)
11129 + break;
11130 +
11131 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11132 + (ba & 0xFFF00000U) == 0x30600000U &&
11133 + nop == 0x01000000U)
11134 + {
11135 + unsigned long addr;
11136 +
11137 + addr = (sethi & 0x003FFFFFU) << 10;
11138 + regs->u_regs[UREG_G1] = addr;
11139 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11140 +
11141 + if (test_thread_flag(TIF_32BIT))
11142 + addr &= 0xFFFFFFFFUL;
11143 +
11144 + regs->tpc = addr;
11145 + regs->tnpc = addr+4;
11146 + return 2;
11147 + }
11148 + } while (0);
11149 +
11150 +#endif
11151 +
11152 + return 1;
11153 +}
11154 +
11155 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11156 +{
11157 + unsigned long i;
11158 +
11159 + printk(KERN_ERR "PAX: bytes at PC: ");
11160 + for (i = 0; i < 8; i++) {
11161 + unsigned int c;
11162 + if (get_user(c, (unsigned int *)pc+i))
11163 + printk(KERN_CONT "???????? ");
11164 + else
11165 + printk(KERN_CONT "%08x ", c);
11166 + }
11167 + printk("\n");
11168 +}
11169 +#endif
11170 +
11171 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11172 {
11173 struct mm_struct *mm = current->mm;
11174 @@ -341,6 +804,29 @@ retry:
11175 if (!vma)
11176 goto bad_area;
11177
11178 +#ifdef CONFIG_PAX_PAGEEXEC
11179 + /* PaX: detect ITLB misses on non-exec pages */
11180 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11181 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11182 + {
11183 + if (address != regs->tpc)
11184 + goto good_area;
11185 +
11186 + up_read(&mm->mmap_sem);
11187 + switch (pax_handle_fetch_fault(regs)) {
11188 +
11189 +#ifdef CONFIG_PAX_EMUPLT
11190 + case 2:
11191 + case 3:
11192 + return;
11193 +#endif
11194 +
11195 + }
11196 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11197 + do_group_exit(SIGKILL);
11198 + }
11199 +#endif
11200 +
11201 /* Pure DTLB misses do not tell us whether the fault causing
11202 * load/store/atomic was a write or not, it only says that there
11203 * was no match. So in such a case we (carefully) read the
11204 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11205 index d2b5944..d878f3c 100644
11206 --- a/arch/sparc/mm/hugetlbpage.c
11207 +++ b/arch/sparc/mm/hugetlbpage.c
11208 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11209 unsigned long addr,
11210 unsigned long len,
11211 unsigned long pgoff,
11212 - unsigned long flags)
11213 + unsigned long flags,
11214 + unsigned long offset)
11215 {
11216 unsigned long task_size = TASK_SIZE;
11217 struct vm_unmapped_area_info info;
11218 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11219
11220 info.flags = 0;
11221 info.length = len;
11222 - info.low_limit = TASK_UNMAPPED_BASE;
11223 + info.low_limit = mm->mmap_base;
11224 info.high_limit = min(task_size, VA_EXCLUDE_START);
11225 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11226 info.align_offset = 0;
11227 + info.threadstack_offset = offset;
11228 addr = vm_unmapped_area(&info);
11229
11230 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11231 VM_BUG_ON(addr != -ENOMEM);
11232 info.low_limit = VA_EXCLUDE_END;
11233 +
11234 +#ifdef CONFIG_PAX_RANDMMAP
11235 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11236 + info.low_limit += mm->delta_mmap;
11237 +#endif
11238 +
11239 info.high_limit = task_size;
11240 addr = vm_unmapped_area(&info);
11241 }
11242 @@ -58,7 +66,8 @@ static unsigned long
11243 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11244 const unsigned long len,
11245 const unsigned long pgoff,
11246 - const unsigned long flags)
11247 + const unsigned long flags,
11248 + const unsigned long offset)
11249 {
11250 struct mm_struct *mm = current->mm;
11251 unsigned long addr = addr0;
11252 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11253 info.high_limit = mm->mmap_base;
11254 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11255 info.align_offset = 0;
11256 + info.threadstack_offset = offset;
11257 addr = vm_unmapped_area(&info);
11258
11259 /*
11260 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11261 VM_BUG_ON(addr != -ENOMEM);
11262 info.flags = 0;
11263 info.low_limit = TASK_UNMAPPED_BASE;
11264 +
11265 +#ifdef CONFIG_PAX_RANDMMAP
11266 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11267 + info.low_limit += mm->delta_mmap;
11268 +#endif
11269 +
11270 info.high_limit = STACK_TOP32;
11271 addr = vm_unmapped_area(&info);
11272 }
11273 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11274 struct mm_struct *mm = current->mm;
11275 struct vm_area_struct *vma;
11276 unsigned long task_size = TASK_SIZE;
11277 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11278
11279 if (test_thread_flag(TIF_32BIT))
11280 task_size = STACK_TOP32;
11281 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11282 return addr;
11283 }
11284
11285 +#ifdef CONFIG_PAX_RANDMMAP
11286 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11287 +#endif
11288 +
11289 if (addr) {
11290 addr = ALIGN(addr, HPAGE_SIZE);
11291 vma = find_vma(mm, addr);
11292 - if (task_size - len >= addr &&
11293 - (!vma || addr + len <= vma->vm_start))
11294 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11295 return addr;
11296 }
11297 if (mm->get_unmapped_area == arch_get_unmapped_area)
11298 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11299 - pgoff, flags);
11300 + pgoff, flags, offset);
11301 else
11302 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11303 - pgoff, flags);
11304 + pgoff, flags, offset);
11305 }
11306
11307 pte_t *huge_pte_alloc(struct mm_struct *mm,
11308 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11309 index ed82eda..0d80e77 100644
11310 --- a/arch/sparc/mm/init_64.c
11311 +++ b/arch/sparc/mm/init_64.c
11312 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11313 int num_kernel_image_mappings;
11314
11315 #ifdef CONFIG_DEBUG_DCFLUSH
11316 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11317 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11318 #ifdef CONFIG_SMP
11319 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11320 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11321 #endif
11322 #endif
11323
11324 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11325 {
11326 BUG_ON(tlb_type == hypervisor);
11327 #ifdef CONFIG_DEBUG_DCFLUSH
11328 - atomic_inc(&dcpage_flushes);
11329 + atomic_inc_unchecked(&dcpage_flushes);
11330 #endif
11331
11332 #ifdef DCACHE_ALIASING_POSSIBLE
11333 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11334
11335 #ifdef CONFIG_DEBUG_DCFLUSH
11336 seq_printf(m, "DCPageFlushes\t: %d\n",
11337 - atomic_read(&dcpage_flushes));
11338 + atomic_read_unchecked(&dcpage_flushes));
11339 #ifdef CONFIG_SMP
11340 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11341 - atomic_read(&dcpage_flushes_xcall));
11342 + atomic_read_unchecked(&dcpage_flushes_xcall));
11343 #endif /* CONFIG_SMP */
11344 #endif /* CONFIG_DEBUG_DCFLUSH */
11345 }
11346 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11347 index f4500c6..889656c 100644
11348 --- a/arch/tile/include/asm/atomic_64.h
11349 +++ b/arch/tile/include/asm/atomic_64.h
11350 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11351
11352 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11353
11354 +#define atomic64_read_unchecked(v) atomic64_read(v)
11355 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11356 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11357 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11358 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11359 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11360 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11361 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11362 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11363 +
11364 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11365 #define smp_mb__before_atomic_dec() smp_mb()
11366 #define smp_mb__after_atomic_dec() smp_mb()
11367 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11368 index a9a5299..0fce79e 100644
11369 --- a/arch/tile/include/asm/cache.h
11370 +++ b/arch/tile/include/asm/cache.h
11371 @@ -15,11 +15,12 @@
11372 #ifndef _ASM_TILE_CACHE_H
11373 #define _ASM_TILE_CACHE_H
11374
11375 +#include <linux/const.h>
11376 #include <arch/chip.h>
11377
11378 /* bytes per L1 data cache line */
11379 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11380 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11381 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11382
11383 /* bytes per L2 cache line */
11384 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11385 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11386 index e4d44bd..99927a3 100644
11387 --- a/arch/tile/include/asm/uaccess.h
11388 +++ b/arch/tile/include/asm/uaccess.h
11389 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11390 const void __user *from,
11391 unsigned long n)
11392 {
11393 - int sz = __compiletime_object_size(to);
11394 + size_t sz = __compiletime_object_size(to);
11395
11396 - if (likely(sz == -1 || sz >= n))
11397 + if (likely(sz == (size_t)-1 || sz >= n))
11398 n = _copy_from_user(to, from, n);
11399 else
11400 copy_from_user_overflow();
11401 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11402 index 650ccff..45fe2d6 100644
11403 --- a/arch/tile/mm/hugetlbpage.c
11404 +++ b/arch/tile/mm/hugetlbpage.c
11405 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11406 info.high_limit = TASK_SIZE;
11407 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11408 info.align_offset = 0;
11409 + info.threadstack_offset = 0;
11410 return vm_unmapped_area(&info);
11411 }
11412
11413 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11414 info.high_limit = current->mm->mmap_base;
11415 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11416 info.align_offset = 0;
11417 + info.threadstack_offset = 0;
11418 addr = vm_unmapped_area(&info);
11419
11420 /*
11421 diff --git a/arch/um/Makefile b/arch/um/Makefile
11422 index 133f7de..1d6f2f1 100644
11423 --- a/arch/um/Makefile
11424 +++ b/arch/um/Makefile
11425 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11426 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11427 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11428
11429 +ifdef CONSTIFY_PLUGIN
11430 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11431 +endif
11432 +
11433 #This will adjust *FLAGS accordingly to the platform.
11434 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11435
11436 diff --git a/arch/um/defconfig b/arch/um/defconfig
11437 index 08107a7..ab22afe 100644
11438 --- a/arch/um/defconfig
11439 +++ b/arch/um/defconfig
11440 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11441 CONFIG_X86_L1_CACHE_SHIFT=5
11442 CONFIG_X86_XADD=y
11443 CONFIG_X86_PPRO_FENCE=y
11444 -CONFIG_X86_WP_WORKS_OK=y
11445 CONFIG_X86_INVLPG=y
11446 CONFIG_X86_BSWAP=y
11447 CONFIG_X86_POPAD_OK=y
11448 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11449 index 19e1bdd..3665b77 100644
11450 --- a/arch/um/include/asm/cache.h
11451 +++ b/arch/um/include/asm/cache.h
11452 @@ -1,6 +1,7 @@
11453 #ifndef __UM_CACHE_H
11454 #define __UM_CACHE_H
11455
11456 +#include <linux/const.h>
11457
11458 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11459 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11460 @@ -12,6 +13,6 @@
11461 # define L1_CACHE_SHIFT 5
11462 #endif
11463
11464 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11465 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11466
11467 #endif
11468 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11469 index 2e0a6b1..a64d0f5 100644
11470 --- a/arch/um/include/asm/kmap_types.h
11471 +++ b/arch/um/include/asm/kmap_types.h
11472 @@ -8,6 +8,6 @@
11473
11474 /* No more #include "asm/arch/kmap_types.h" ! */
11475
11476 -#define KM_TYPE_NR 14
11477 +#define KM_TYPE_NR 15
11478
11479 #endif
11480 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11481 index 5ff53d9..5850cdf 100644
11482 --- a/arch/um/include/asm/page.h
11483 +++ b/arch/um/include/asm/page.h
11484 @@ -14,6 +14,9 @@
11485 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11486 #define PAGE_MASK (~(PAGE_SIZE-1))
11487
11488 +#define ktla_ktva(addr) (addr)
11489 +#define ktva_ktla(addr) (addr)
11490 +
11491 #ifndef __ASSEMBLY__
11492
11493 struct page;
11494 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11495 index 0032f92..cd151e0 100644
11496 --- a/arch/um/include/asm/pgtable-3level.h
11497 +++ b/arch/um/include/asm/pgtable-3level.h
11498 @@ -58,6 +58,7 @@
11499 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11500 #define pud_populate(mm, pud, pmd) \
11501 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11502 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11503
11504 #ifdef CONFIG_64BIT
11505 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11506 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11507 index bbcef52..6a2a483 100644
11508 --- a/arch/um/kernel/process.c
11509 +++ b/arch/um/kernel/process.c
11510 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11511 return 2;
11512 }
11513
11514 -/*
11515 - * Only x86 and x86_64 have an arch_align_stack().
11516 - * All other arches have "#define arch_align_stack(x) (x)"
11517 - * in their asm/system.h
11518 - * As this is included in UML from asm-um/system-generic.h,
11519 - * we can use it to behave as the subarch does.
11520 - */
11521 -#ifndef arch_align_stack
11522 -unsigned long arch_align_stack(unsigned long sp)
11523 -{
11524 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11525 - sp -= get_random_int() % 8192;
11526 - return sp & ~0xf;
11527 -}
11528 -#endif
11529 -
11530 unsigned long get_wchan(struct task_struct *p)
11531 {
11532 unsigned long stack_page, sp, ip;
11533 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11534 index ad8f795..2c7eec6 100644
11535 --- a/arch/unicore32/include/asm/cache.h
11536 +++ b/arch/unicore32/include/asm/cache.h
11537 @@ -12,8 +12,10 @@
11538 #ifndef __UNICORE_CACHE_H__
11539 #define __UNICORE_CACHE_H__
11540
11541 -#define L1_CACHE_SHIFT (5)
11542 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11543 +#include <linux/const.h>
11544 +
11545 +#define L1_CACHE_SHIFT 5
11546 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11547
11548 /*
11549 * Memory returned by kmalloc() may be used for DMA, so we must make
11550 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11551 index b32ebf9..5704f98 100644
11552 --- a/arch/x86/Kconfig
11553 +++ b/arch/x86/Kconfig
11554 @@ -248,7 +248,7 @@ config X86_HT
11555
11556 config X86_32_LAZY_GS
11557 def_bool y
11558 - depends on X86_32 && !CC_STACKPROTECTOR
11559 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11560
11561 config ARCH_HWEIGHT_CFLAGS
11562 string
11563 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11564
11565 config X86_MSR
11566 tristate "/dev/cpu/*/msr - Model-specific register support"
11567 + depends on !GRKERNSEC_KMEM
11568 ---help---
11569 This device gives privileged processes access to the x86
11570 Model-Specific Registers (MSRs). It is a character device with
11571 @@ -1111,7 +1112,7 @@ choice
11572
11573 config NOHIGHMEM
11574 bool "off"
11575 - depends on !X86_NUMAQ
11576 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11577 ---help---
11578 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11579 However, the address space of 32-bit x86 processors is only 4
11580 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11581
11582 config HIGHMEM4G
11583 bool "4GB"
11584 - depends on !X86_NUMAQ
11585 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11586 ---help---
11587 Select this if you have a 32-bit processor and between 1 and 4
11588 gigabytes of physical RAM.
11589 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11590 hex
11591 default 0xB0000000 if VMSPLIT_3G_OPT
11592 default 0x80000000 if VMSPLIT_2G
11593 - default 0x78000000 if VMSPLIT_2G_OPT
11594 + default 0x70000000 if VMSPLIT_2G_OPT
11595 default 0x40000000 if VMSPLIT_1G
11596 default 0xC0000000
11597 depends on X86_32
11598 @@ -1599,6 +1600,7 @@ config SECCOMP
11599
11600 config CC_STACKPROTECTOR
11601 bool "Enable -fstack-protector buffer overflow detection"
11602 + depends on X86_64 || !PAX_MEMORY_UDEREF
11603 ---help---
11604 This option turns on the -fstack-protector GCC feature. This
11605 feature puts, at the beginning of functions, a canary value on
11606 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11607 config PHYSICAL_ALIGN
11608 hex "Alignment value to which kernel should be aligned" if X86_32
11609 default "0x1000000"
11610 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11611 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11612 range 0x2000 0x1000000
11613 ---help---
11614 This value puts the alignment restrictions on physical address
11615 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11616 If unsure, say N.
11617
11618 config COMPAT_VDSO
11619 - def_bool y
11620 + def_bool n
11621 prompt "Compat VDSO support"
11622 depends on X86_32 || IA32_EMULATION
11623 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11624 ---help---
11625 Map the 32-bit VDSO to the predictable old-style address too.
11626
11627 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11628 index c026cca..14657ae 100644
11629 --- a/arch/x86/Kconfig.cpu
11630 +++ b/arch/x86/Kconfig.cpu
11631 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11632
11633 config X86_F00F_BUG
11634 def_bool y
11635 - depends on M586MMX || M586TSC || M586 || M486
11636 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11637
11638 config X86_INVD_BUG
11639 def_bool y
11640 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11641
11642 config X86_ALIGNMENT_16
11643 def_bool y
11644 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11645 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11646
11647 config X86_INTEL_USERCOPY
11648 def_bool y
11649 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11650 # generates cmov.
11651 config X86_CMOV
11652 def_bool y
11653 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11654 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11655
11656 config X86_MINIMUM_CPU_FAMILY
11657 int
11658 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11659 index 78d91af..8ceb94b 100644
11660 --- a/arch/x86/Kconfig.debug
11661 +++ b/arch/x86/Kconfig.debug
11662 @@ -74,7 +74,7 @@ config X86_PTDUMP
11663 config DEBUG_RODATA
11664 bool "Write protect kernel read-only data structures"
11665 default y
11666 - depends on DEBUG_KERNEL
11667 + depends on DEBUG_KERNEL && BROKEN
11668 ---help---
11669 Mark the kernel read-only data as write-protected in the pagetables,
11670 in order to catch accidental (and incorrect) writes to such const
11671 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11672
11673 config DEBUG_SET_MODULE_RONX
11674 bool "Set loadable kernel module data as NX and text as RO"
11675 - depends on MODULES
11676 + depends on MODULES && BROKEN
11677 ---help---
11678 This option helps catch unintended modifications to loadable
11679 kernel module's text and read-only data. It also prevents execution
11680 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11681 index 07639c6..6f2c901 100644
11682 --- a/arch/x86/Makefile
11683 +++ b/arch/x86/Makefile
11684 @@ -54,6 +54,7 @@ else
11685 UTS_MACHINE := x86_64
11686 CHECKFLAGS += -D__x86_64__ -m64
11687
11688 + biarch := $(call cc-option,-m64)
11689 KBUILD_AFLAGS += -m64
11690 KBUILD_CFLAGS += -m64
11691
11692 @@ -241,3 +242,12 @@ define archhelp
11693 echo ' FDINITRD=file initrd for the booted kernel'
11694 echo ' kvmconfig - Enable additional options for guest kernel support'
11695 endef
11696 +
11697 +define OLD_LD
11698 +
11699 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11700 +*** Please upgrade your binutils to 2.18 or newer
11701 +endef
11702 +
11703 +archprepare:
11704 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11705 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11706 index 379814b..add62ce 100644
11707 --- a/arch/x86/boot/Makefile
11708 +++ b/arch/x86/boot/Makefile
11709 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11710 $(call cc-option, -fno-stack-protector) \
11711 $(call cc-option, -mpreferred-stack-boundary=2)
11712 KBUILD_CFLAGS += $(call cc-option, -m32)
11713 +ifdef CONSTIFY_PLUGIN
11714 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11715 +endif
11716 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11717 GCOV_PROFILE := n
11718
11719 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11720 index 878e4b9..20537ab 100644
11721 --- a/arch/x86/boot/bitops.h
11722 +++ b/arch/x86/boot/bitops.h
11723 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11724 u8 v;
11725 const u32 *p = (const u32 *)addr;
11726
11727 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11728 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11729 return v;
11730 }
11731
11732 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11733
11734 static inline void set_bit(int nr, void *addr)
11735 {
11736 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11737 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11738 }
11739
11740 #endif /* BOOT_BITOPS_H */
11741 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11742 index 5b75319..331a4ca 100644
11743 --- a/arch/x86/boot/boot.h
11744 +++ b/arch/x86/boot/boot.h
11745 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11746 static inline u16 ds(void)
11747 {
11748 u16 seg;
11749 - asm("movw %%ds,%0" : "=rm" (seg));
11750 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11751 return seg;
11752 }
11753
11754 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11755 static inline int memcmp(const void *s1, const void *s2, size_t len)
11756 {
11757 u8 diff;
11758 - asm("repe; cmpsb; setnz %0"
11759 + asm volatile("repe; cmpsb; setnz %0"
11760 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11761 return diff;
11762 }
11763 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11764 index dcd90df..c830d7d 100644
11765 --- a/arch/x86/boot/compressed/Makefile
11766 +++ b/arch/x86/boot/compressed/Makefile
11767 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11768 KBUILD_CFLAGS += $(cflags-y)
11769 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11770 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11771 +ifdef CONSTIFY_PLUGIN
11772 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11773 +endif
11774
11775 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11776 GCOV_PROFILE := n
11777 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11778 index b7388a4..03844ec 100644
11779 --- a/arch/x86/boot/compressed/eboot.c
11780 +++ b/arch/x86/boot/compressed/eboot.c
11781 @@ -150,7 +150,6 @@ again:
11782 *addr = max_addr;
11783 }
11784
11785 -free_pool:
11786 efi_call_phys1(sys_table->boottime->free_pool, map);
11787
11788 fail:
11789 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11790 if (i == map_size / desc_size)
11791 status = EFI_NOT_FOUND;
11792
11793 -free_pool:
11794 efi_call_phys1(sys_table->boottime->free_pool, map);
11795 fail:
11796 return status;
11797 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11798 index a53440e..c3dbf1e 100644
11799 --- a/arch/x86/boot/compressed/efi_stub_32.S
11800 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11801 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11802 * parameter 2, ..., param n. To make things easy, we save the return
11803 * address of efi_call_phys in a global variable.
11804 */
11805 - popl %ecx
11806 - movl %ecx, saved_return_addr(%edx)
11807 - /* get the function pointer into ECX*/
11808 - popl %ecx
11809 - movl %ecx, efi_rt_function_ptr(%edx)
11810 + popl saved_return_addr(%edx)
11811 + popl efi_rt_function_ptr(%edx)
11812
11813 /*
11814 * 3. Call the physical function.
11815 */
11816 - call *%ecx
11817 + call *efi_rt_function_ptr(%edx)
11818
11819 /*
11820 * 4. Balance the stack. And because EAX contain the return value,
11821 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11822 1: popl %edx
11823 subl $1b, %edx
11824
11825 - movl efi_rt_function_ptr(%edx), %ecx
11826 - pushl %ecx
11827 + pushl efi_rt_function_ptr(%edx)
11828
11829 /*
11830 * 10. Push the saved return address onto the stack and return.
11831 */
11832 - movl saved_return_addr(%edx), %ecx
11833 - pushl %ecx
11834 - ret
11835 + jmpl *saved_return_addr(%edx)
11836 ENDPROC(efi_call_phys)
11837 .previous
11838
11839 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11840 index 1e3184f..0d11e2e 100644
11841 --- a/arch/x86/boot/compressed/head_32.S
11842 +++ b/arch/x86/boot/compressed/head_32.S
11843 @@ -118,7 +118,7 @@ preferred_addr:
11844 notl %eax
11845 andl %eax, %ebx
11846 #else
11847 - movl $LOAD_PHYSICAL_ADDR, %ebx
11848 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11849 #endif
11850
11851 /* Target address to relocate to for decompression */
11852 @@ -204,7 +204,7 @@ relocated:
11853 * and where it was actually loaded.
11854 */
11855 movl %ebp, %ebx
11856 - subl $LOAD_PHYSICAL_ADDR, %ebx
11857 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11858 jz 2f /* Nothing to be done if loaded at compiled addr. */
11859 /*
11860 * Process relocations.
11861 @@ -212,8 +212,7 @@ relocated:
11862
11863 1: subl $4, %edi
11864 movl (%edi), %ecx
11865 - testl %ecx, %ecx
11866 - jz 2f
11867 + jecxz 2f
11868 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11869 jmp 1b
11870 2:
11871 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11872 index 06e71c2..88a98264 100644
11873 --- a/arch/x86/boot/compressed/head_64.S
11874 +++ b/arch/x86/boot/compressed/head_64.S
11875 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11876 notl %eax
11877 andl %eax, %ebx
11878 #else
11879 - movl $LOAD_PHYSICAL_ADDR, %ebx
11880 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11881 #endif
11882
11883 /* Target address to relocate to for decompression */
11884 @@ -270,7 +270,7 @@ preferred_addr:
11885 notq %rax
11886 andq %rax, %rbp
11887 #else
11888 - movq $LOAD_PHYSICAL_ADDR, %rbp
11889 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11890 #endif
11891
11892 /* Target address to relocate to for decompression */
11893 @@ -361,8 +361,8 @@ gdt:
11894 .long gdt
11895 .word 0
11896 .quad 0x0000000000000000 /* NULL descriptor */
11897 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11898 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11899 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11900 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11901 .quad 0x0080890000000000 /* TS descriptor */
11902 .quad 0x0000000000000000 /* TS continued */
11903 gdt_end:
11904 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11905 index 0319c88..7c1931f 100644
11906 --- a/arch/x86/boot/compressed/misc.c
11907 +++ b/arch/x86/boot/compressed/misc.c
11908 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11909 case PT_LOAD:
11910 #ifdef CONFIG_RELOCATABLE
11911 dest = output;
11912 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11913 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11914 #else
11915 dest = (void *)(phdr->p_paddr);
11916 #endif
11917 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11918 error("Destination address too large");
11919 #endif
11920 #ifndef CONFIG_RELOCATABLE
11921 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11922 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11923 error("Wrong destination address");
11924 #endif
11925
11926 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11927 index 4d3ff03..e4972ff 100644
11928 --- a/arch/x86/boot/cpucheck.c
11929 +++ b/arch/x86/boot/cpucheck.c
11930 @@ -74,7 +74,7 @@ static int has_fpu(void)
11931 u16 fcw = -1, fsw = -1;
11932 u32 cr0;
11933
11934 - asm("movl %%cr0,%0" : "=r" (cr0));
11935 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11936 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11937 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11938 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11939 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11940 {
11941 u32 f0, f1;
11942
11943 - asm("pushfl ; "
11944 + asm volatile("pushfl ; "
11945 "pushfl ; "
11946 "popl %0 ; "
11947 "movl %0,%1 ; "
11948 @@ -115,7 +115,7 @@ static void get_flags(void)
11949 set_bit(X86_FEATURE_FPU, cpu.flags);
11950
11951 if (has_eflag(X86_EFLAGS_ID)) {
11952 - asm("cpuid"
11953 + asm volatile("cpuid"
11954 : "=a" (max_intel_level),
11955 "=b" (cpu_vendor[0]),
11956 "=d" (cpu_vendor[1]),
11957 @@ -124,7 +124,7 @@ static void get_flags(void)
11958
11959 if (max_intel_level >= 0x00000001 &&
11960 max_intel_level <= 0x0000ffff) {
11961 - asm("cpuid"
11962 + asm volatile("cpuid"
11963 : "=a" (tfms),
11964 "=c" (cpu.flags[4]),
11965 "=d" (cpu.flags[0])
11966 @@ -136,7 +136,7 @@ static void get_flags(void)
11967 cpu.model += ((tfms >> 16) & 0xf) << 4;
11968 }
11969
11970 - asm("cpuid"
11971 + asm volatile("cpuid"
11972 : "=a" (max_amd_level)
11973 : "a" (0x80000000)
11974 : "ebx", "ecx", "edx");
11975 @@ -144,7 +144,7 @@ static void get_flags(void)
11976 if (max_amd_level >= 0x80000001 &&
11977 max_amd_level <= 0x8000ffff) {
11978 u32 eax = 0x80000001;
11979 - asm("cpuid"
11980 + asm volatile("cpuid"
11981 : "+a" (eax),
11982 "=c" (cpu.flags[6]),
11983 "=d" (cpu.flags[1])
11984 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11985 u32 ecx = MSR_K7_HWCR;
11986 u32 eax, edx;
11987
11988 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11990 eax &= ~(1 << 15);
11991 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11992 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11993
11994 get_flags(); /* Make sure it really did something */
11995 err = check_flags();
11996 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11997 u32 ecx = MSR_VIA_FCR;
11998 u32 eax, edx;
11999
12000 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12001 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12002 eax |= (1<<1)|(1<<7);
12003 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12004 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12005
12006 set_bit(X86_FEATURE_CX8, cpu.flags);
12007 err = check_flags();
12008 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12009 u32 eax, edx;
12010 u32 level = 1;
12011
12012 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12013 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12014 - asm("cpuid"
12015 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12016 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12017 + asm volatile("cpuid"
12018 : "+a" (level), "=d" (cpu.flags[0])
12019 : : "ecx", "ebx");
12020 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12021 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12022
12023 err = check_flags();
12024 }
12025 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12026 index 9ec06a1..2c25e79 100644
12027 --- a/arch/x86/boot/header.S
12028 +++ b/arch/x86/boot/header.S
12029 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12030 # single linked list of
12031 # struct setup_data
12032
12033 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12034 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12035
12036 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12037 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12038 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12039 +#else
12040 #define VO_INIT_SIZE (VO__end - VO__text)
12041 +#endif
12042 #if ZO_INIT_SIZE > VO_INIT_SIZE
12043 #define INIT_SIZE ZO_INIT_SIZE
12044 #else
12045 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12046 index db75d07..8e6d0af 100644
12047 --- a/arch/x86/boot/memory.c
12048 +++ b/arch/x86/boot/memory.c
12049 @@ -19,7 +19,7 @@
12050
12051 static int detect_memory_e820(void)
12052 {
12053 - int count = 0;
12054 + unsigned int count = 0;
12055 struct biosregs ireg, oreg;
12056 struct e820entry *desc = boot_params.e820_map;
12057 static struct e820entry buf; /* static so it is zeroed */
12058 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12059 index 11e8c6e..fdbb1ed 100644
12060 --- a/arch/x86/boot/video-vesa.c
12061 +++ b/arch/x86/boot/video-vesa.c
12062 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12063
12064 boot_params.screen_info.vesapm_seg = oreg.es;
12065 boot_params.screen_info.vesapm_off = oreg.di;
12066 + boot_params.screen_info.vesapm_size = oreg.cx;
12067 }
12068
12069 /*
12070 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12071 index 43eda28..5ab5fdb 100644
12072 --- a/arch/x86/boot/video.c
12073 +++ b/arch/x86/boot/video.c
12074 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12075 static unsigned int get_entry(void)
12076 {
12077 char entry_buf[4];
12078 - int i, len = 0;
12079 + unsigned int i, len = 0;
12080 int key;
12081 unsigned int v;
12082
12083 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12084 index 9105655..5e37f27 100644
12085 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12086 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12087 @@ -8,6 +8,8 @@
12088 * including this sentence is retained in full.
12089 */
12090
12091 +#include <asm/alternative-asm.h>
12092 +
12093 .extern crypto_ft_tab
12094 .extern crypto_it_tab
12095 .extern crypto_fl_tab
12096 @@ -70,6 +72,8 @@
12097 je B192; \
12098 leaq 32(r9),r9;
12099
12100 +#define ret pax_force_retaddr 0, 1; ret
12101 +
12102 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12103 movq r1,r2; \
12104 movq r3,r4; \
12105 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12106 index 477e9d7..3ab339f 100644
12107 --- a/arch/x86/crypto/aesni-intel_asm.S
12108 +++ b/arch/x86/crypto/aesni-intel_asm.S
12109 @@ -31,6 +31,7 @@
12110
12111 #include <linux/linkage.h>
12112 #include <asm/inst.h>
12113 +#include <asm/alternative-asm.h>
12114
12115 #ifdef __x86_64__
12116 .data
12117 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12118 pop %r14
12119 pop %r13
12120 pop %r12
12121 + pax_force_retaddr 0, 1
12122 ret
12123 ENDPROC(aesni_gcm_dec)
12124
12125 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12126 pop %r14
12127 pop %r13
12128 pop %r12
12129 + pax_force_retaddr 0, 1
12130 ret
12131 ENDPROC(aesni_gcm_enc)
12132
12133 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12134 pxor %xmm1, %xmm0
12135 movaps %xmm0, (TKEYP)
12136 add $0x10, TKEYP
12137 + pax_force_retaddr_bts
12138 ret
12139 ENDPROC(_key_expansion_128)
12140 ENDPROC(_key_expansion_256a)
12141 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12142 shufps $0b01001110, %xmm2, %xmm1
12143 movaps %xmm1, 0x10(TKEYP)
12144 add $0x20, TKEYP
12145 + pax_force_retaddr_bts
12146 ret
12147 ENDPROC(_key_expansion_192a)
12148
12149 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12150
12151 movaps %xmm0, (TKEYP)
12152 add $0x10, TKEYP
12153 + pax_force_retaddr_bts
12154 ret
12155 ENDPROC(_key_expansion_192b)
12156
12157 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12158 pxor %xmm1, %xmm2
12159 movaps %xmm2, (TKEYP)
12160 add $0x10, TKEYP
12161 + pax_force_retaddr_bts
12162 ret
12163 ENDPROC(_key_expansion_256b)
12164
12165 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12166 #ifndef __x86_64__
12167 popl KEYP
12168 #endif
12169 + pax_force_retaddr 0, 1
12170 ret
12171 ENDPROC(aesni_set_key)
12172
12173 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12174 popl KLEN
12175 popl KEYP
12176 #endif
12177 + pax_force_retaddr 0, 1
12178 ret
12179 ENDPROC(aesni_enc)
12180
12181 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12182 AESENC KEY STATE
12183 movaps 0x70(TKEYP), KEY
12184 AESENCLAST KEY STATE
12185 + pax_force_retaddr_bts
12186 ret
12187 ENDPROC(_aesni_enc1)
12188
12189 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12190 AESENCLAST KEY STATE2
12191 AESENCLAST KEY STATE3
12192 AESENCLAST KEY STATE4
12193 + pax_force_retaddr_bts
12194 ret
12195 ENDPROC(_aesni_enc4)
12196
12197 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12198 popl KLEN
12199 popl KEYP
12200 #endif
12201 + pax_force_retaddr 0, 1
12202 ret
12203 ENDPROC(aesni_dec)
12204
12205 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12206 AESDEC KEY STATE
12207 movaps 0x70(TKEYP), KEY
12208 AESDECLAST KEY STATE
12209 + pax_force_retaddr_bts
12210 ret
12211 ENDPROC(_aesni_dec1)
12212
12213 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12214 AESDECLAST KEY STATE2
12215 AESDECLAST KEY STATE3
12216 AESDECLAST KEY STATE4
12217 + pax_force_retaddr_bts
12218 ret
12219 ENDPROC(_aesni_dec4)
12220
12221 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12222 popl KEYP
12223 popl LEN
12224 #endif
12225 + pax_force_retaddr 0, 1
12226 ret
12227 ENDPROC(aesni_ecb_enc)
12228
12229 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12230 popl KEYP
12231 popl LEN
12232 #endif
12233 + pax_force_retaddr 0, 1
12234 ret
12235 ENDPROC(aesni_ecb_dec)
12236
12237 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12238 popl LEN
12239 popl IVP
12240 #endif
12241 + pax_force_retaddr 0, 1
12242 ret
12243 ENDPROC(aesni_cbc_enc)
12244
12245 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12246 popl LEN
12247 popl IVP
12248 #endif
12249 + pax_force_retaddr 0, 1
12250 ret
12251 ENDPROC(aesni_cbc_dec)
12252
12253 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12254 mov $1, TCTR_LOW
12255 MOVQ_R64_XMM TCTR_LOW INC
12256 MOVQ_R64_XMM CTR TCTR_LOW
12257 + pax_force_retaddr_bts
12258 ret
12259 ENDPROC(_aesni_inc_init)
12260
12261 @@ -2579,6 +2598,7 @@ _aesni_inc:
12262 .Linc_low:
12263 movaps CTR, IV
12264 PSHUFB_XMM BSWAP_MASK IV
12265 + pax_force_retaddr_bts
12266 ret
12267 ENDPROC(_aesni_inc)
12268
12269 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12270 .Lctr_enc_ret:
12271 movups IV, (IVP)
12272 .Lctr_enc_just_ret:
12273 + pax_force_retaddr 0, 1
12274 ret
12275 ENDPROC(aesni_ctr_enc)
12276
12277 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12278 pxor INC, STATE4
12279 movdqu STATE4, 0x70(OUTP)
12280
12281 + pax_force_retaddr 0, 1
12282 ret
12283 ENDPROC(aesni_xts_crypt8)
12284
12285 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12286 index 246c670..4d1ed00 100644
12287 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12288 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12289 @@ -21,6 +21,7 @@
12290 */
12291
12292 #include <linux/linkage.h>
12293 +#include <asm/alternative-asm.h>
12294
12295 .file "blowfish-x86_64-asm.S"
12296 .text
12297 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12298 jnz .L__enc_xor;
12299
12300 write_block();
12301 + pax_force_retaddr 0, 1
12302 ret;
12303 .L__enc_xor:
12304 xor_block();
12305 + pax_force_retaddr 0, 1
12306 ret;
12307 ENDPROC(__blowfish_enc_blk)
12308
12309 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12310
12311 movq %r11, %rbp;
12312
12313 + pax_force_retaddr 0, 1
12314 ret;
12315 ENDPROC(blowfish_dec_blk)
12316
12317 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12318
12319 popq %rbx;
12320 popq %rbp;
12321 + pax_force_retaddr 0, 1
12322 ret;
12323
12324 .L__enc_xor4:
12325 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12326
12327 popq %rbx;
12328 popq %rbp;
12329 + pax_force_retaddr 0, 1
12330 ret;
12331 ENDPROC(__blowfish_enc_blk_4way)
12332
12333 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12334 popq %rbx;
12335 popq %rbp;
12336
12337 + pax_force_retaddr 0, 1
12338 ret;
12339 ENDPROC(blowfish_dec_blk_4way)
12340 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12341 index ce71f92..2dd5b1e 100644
12342 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12343 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12344 @@ -16,6 +16,7 @@
12345 */
12346
12347 #include <linux/linkage.h>
12348 +#include <asm/alternative-asm.h>
12349
12350 #define CAMELLIA_TABLE_BYTE_LEN 272
12351
12352 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12353 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12354 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12355 %rcx, (%r9));
12356 + pax_force_retaddr_bts
12357 ret;
12358 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12359
12360 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12361 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12362 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12363 %rax, (%r9));
12364 + pax_force_retaddr_bts
12365 ret;
12366 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12367
12368 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12369 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12370 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12371
12372 + pax_force_retaddr_bts
12373 ret;
12374
12375 .align 8
12376 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12377 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12378 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12379
12380 + pax_force_retaddr_bts
12381 ret;
12382
12383 .align 8
12384 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12386 %xmm8, %rsi);
12387
12388 + pax_force_retaddr 0, 1
12389 ret;
12390 ENDPROC(camellia_ecb_enc_16way)
12391
12392 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12394 %xmm8, %rsi);
12395
12396 + pax_force_retaddr 0, 1
12397 ret;
12398 ENDPROC(camellia_ecb_dec_16way)
12399
12400 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12401 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12402 %xmm8, %rsi);
12403
12404 + pax_force_retaddr 0, 1
12405 ret;
12406 ENDPROC(camellia_cbc_dec_16way)
12407
12408 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12409 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12410 %xmm8, %rsi);
12411
12412 + pax_force_retaddr 0, 1
12413 ret;
12414 ENDPROC(camellia_ctr_16way)
12415
12416 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12417 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12418 %xmm8, %rsi);
12419
12420 + pax_force_retaddr 0, 1
12421 ret;
12422 ENDPROC(camellia_xts_crypt_16way)
12423
12424 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12425 index 0e0b886..8fc756a 100644
12426 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12427 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12428 @@ -11,6 +11,7 @@
12429 */
12430
12431 #include <linux/linkage.h>
12432 +#include <asm/alternative-asm.h>
12433
12434 #define CAMELLIA_TABLE_BYTE_LEN 272
12435
12436 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12437 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12438 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12439 %rcx, (%r9));
12440 + pax_force_retaddr_bts
12441 ret;
12442 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12443
12444 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12445 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12446 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12447 %rax, (%r9));
12448 + pax_force_retaddr_bts
12449 ret;
12450 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12451
12452 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12453 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12454 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12455
12456 + pax_force_retaddr_bts
12457 ret;
12458
12459 .align 8
12460 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12461 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12462 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12463
12464 + pax_force_retaddr_bts
12465 ret;
12466
12467 .align 8
12468 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12469
12470 vzeroupper;
12471
12472 + pax_force_retaddr 0, 1
12473 ret;
12474 ENDPROC(camellia_ecb_enc_32way)
12475
12476 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12477
12478 vzeroupper;
12479
12480 + pax_force_retaddr 0, 1
12481 ret;
12482 ENDPROC(camellia_ecb_dec_32way)
12483
12484 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12485
12486 vzeroupper;
12487
12488 + pax_force_retaddr 0, 1
12489 ret;
12490 ENDPROC(camellia_cbc_dec_32way)
12491
12492 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12493
12494 vzeroupper;
12495
12496 + pax_force_retaddr 0, 1
12497 ret;
12498 ENDPROC(camellia_ctr_32way)
12499
12500 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12501
12502 vzeroupper;
12503
12504 + pax_force_retaddr 0, 1
12505 ret;
12506 ENDPROC(camellia_xts_crypt_32way)
12507
12508 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12509 index 310319c..ce174a4 100644
12510 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12511 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12512 @@ -21,6 +21,7 @@
12513 */
12514
12515 #include <linux/linkage.h>
12516 +#include <asm/alternative-asm.h>
12517
12518 .file "camellia-x86_64-asm_64.S"
12519 .text
12520 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12521 enc_outunpack(mov, RT1);
12522
12523 movq RRBP, %rbp;
12524 + pax_force_retaddr 0, 1
12525 ret;
12526
12527 .L__enc_xor:
12528 enc_outunpack(xor, RT1);
12529
12530 movq RRBP, %rbp;
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(__camellia_enc_blk)
12534
12535 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12536 dec_outunpack();
12537
12538 movq RRBP, %rbp;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541 ENDPROC(camellia_dec_blk)
12542
12543 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12544
12545 movq RRBP, %rbp;
12546 popq %rbx;
12547 + pax_force_retaddr 0, 1
12548 ret;
12549
12550 .L__enc2_xor:
12551 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12552
12553 movq RRBP, %rbp;
12554 popq %rbx;
12555 + pax_force_retaddr 0, 1
12556 ret;
12557 ENDPROC(__camellia_enc_blk_2way)
12558
12559 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12560
12561 movq RRBP, %rbp;
12562 movq RXOR, %rbx;
12563 + pax_force_retaddr 0, 1
12564 ret;
12565 ENDPROC(camellia_dec_blk_2way)
12566 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12567 index c35fd5d..c1ee236 100644
12568 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12569 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12570 @@ -24,6 +24,7 @@
12571 */
12572
12573 #include <linux/linkage.h>
12574 +#include <asm/alternative-asm.h>
12575
12576 .file "cast5-avx-x86_64-asm_64.S"
12577
12578 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12579 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12580 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12581
12582 + pax_force_retaddr 0, 1
12583 ret;
12584 ENDPROC(__cast5_enc_blk16)
12585
12586 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12587 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12588 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12589
12590 + pax_force_retaddr 0, 1
12591 ret;
12592
12593 .L__skip_dec:
12594 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12595 vmovdqu RR4, (6*4*4)(%r11);
12596 vmovdqu RL4, (7*4*4)(%r11);
12597
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(cast5_ecb_enc_16way)
12601
12602 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12603 vmovdqu RR4, (6*4*4)(%r11);
12604 vmovdqu RL4, (7*4*4)(%r11);
12605
12606 + pax_force_retaddr
12607 ret;
12608 ENDPROC(cast5_ecb_dec_16way)
12609
12610 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12611
12612 popq %r12;
12613
12614 + pax_force_retaddr
12615 ret;
12616 ENDPROC(cast5_cbc_dec_16way)
12617
12618 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12619
12620 popq %r12;
12621
12622 + pax_force_retaddr
12623 ret;
12624 ENDPROC(cast5_ctr_16way)
12625 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12626 index e3531f8..18ded3a 100644
12627 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12628 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12629 @@ -24,6 +24,7 @@
12630 */
12631
12632 #include <linux/linkage.h>
12633 +#include <asm/alternative-asm.h>
12634 #include "glue_helper-asm-avx.S"
12635
12636 .file "cast6-avx-x86_64-asm_64.S"
12637 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12638 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12639 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12640
12641 + pax_force_retaddr 0, 1
12642 ret;
12643 ENDPROC(__cast6_enc_blk8)
12644
12645 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12646 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12647 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12648
12649 + pax_force_retaddr 0, 1
12650 ret;
12651 ENDPROC(__cast6_dec_blk8)
12652
12653 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12654
12655 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12656
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(cast6_ecb_enc_8way)
12660
12661 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12662
12663 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12664
12665 + pax_force_retaddr
12666 ret;
12667 ENDPROC(cast6_ecb_dec_8way)
12668
12669 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12670
12671 popq %r12;
12672
12673 + pax_force_retaddr
12674 ret;
12675 ENDPROC(cast6_cbc_dec_8way)
12676
12677 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12678
12679 popq %r12;
12680
12681 + pax_force_retaddr
12682 ret;
12683 ENDPROC(cast6_ctr_8way)
12684
12685 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12686 /* dst <= regs xor IVs(in dst) */
12687 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12688
12689 + pax_force_retaddr
12690 ret;
12691 ENDPROC(cast6_xts_enc_8way)
12692
12693 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12694 /* dst <= regs xor IVs(in dst) */
12695 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12696
12697 + pax_force_retaddr
12698 ret;
12699 ENDPROC(cast6_xts_dec_8way)
12700 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12701 index dbc4339..3d868c5 100644
12702 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12703 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12704 @@ -45,6 +45,7 @@
12705
12706 #include <asm/inst.h>
12707 #include <linux/linkage.h>
12708 +#include <asm/alternative-asm.h>
12709
12710 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12711
12712 @@ -312,6 +313,7 @@ do_return:
12713 popq %rsi
12714 popq %rdi
12715 popq %rbx
12716 + pax_force_retaddr 0, 1
12717 ret
12718
12719 ################################################################
12720 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12721 index 586f41a..d02851e 100644
12722 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12723 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12724 @@ -18,6 +18,7 @@
12725
12726 #include <linux/linkage.h>
12727 #include <asm/inst.h>
12728 +#include <asm/alternative-asm.h>
12729
12730 .data
12731
12732 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12733 psrlq $1, T2
12734 pxor T2, T1
12735 pxor T1, DATA
12736 + pax_force_retaddr
12737 ret
12738 ENDPROC(__clmul_gf128mul_ble)
12739
12740 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12741 call __clmul_gf128mul_ble
12742 PSHUFB_XMM BSWAP DATA
12743 movups DATA, (%rdi)
12744 + pax_force_retaddr
12745 ret
12746 ENDPROC(clmul_ghash_mul)
12747
12748 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12749 PSHUFB_XMM BSWAP DATA
12750 movups DATA, (%rdi)
12751 .Lupdate_just_ret:
12752 + pax_force_retaddr
12753 ret
12754 ENDPROC(clmul_ghash_update)
12755
12756 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12757 pand .Lpoly, %xmm1
12758 pxor %xmm1, %xmm0
12759 movups %xmm0, (%rdi)
12760 + pax_force_retaddr
12761 ret
12762 ENDPROC(clmul_ghash_setkey)
12763 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12764 index 9279e0b..9270820 100644
12765 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12766 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12767 @@ -1,4 +1,5 @@
12768 #include <linux/linkage.h>
12769 +#include <asm/alternative-asm.h>
12770
12771 # enter salsa20_encrypt_bytes
12772 ENTRY(salsa20_encrypt_bytes)
12773 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12774 add %r11,%rsp
12775 mov %rdi,%rax
12776 mov %rsi,%rdx
12777 + pax_force_retaddr 0, 1
12778 ret
12779 # bytesatleast65:
12780 ._bytesatleast65:
12781 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12782 add %r11,%rsp
12783 mov %rdi,%rax
12784 mov %rsi,%rdx
12785 + pax_force_retaddr
12786 ret
12787 ENDPROC(salsa20_keysetup)
12788
12789 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12790 add %r11,%rsp
12791 mov %rdi,%rax
12792 mov %rsi,%rdx
12793 + pax_force_retaddr
12794 ret
12795 ENDPROC(salsa20_ivsetup)
12796 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12797 index 2f202f4..d9164d6 100644
12798 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12799 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12800 @@ -24,6 +24,7 @@
12801 */
12802
12803 #include <linux/linkage.h>
12804 +#include <asm/alternative-asm.h>
12805 #include "glue_helper-asm-avx.S"
12806
12807 .file "serpent-avx-x86_64-asm_64.S"
12808 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12809 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12810 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12811
12812 + pax_force_retaddr
12813 ret;
12814 ENDPROC(__serpent_enc_blk8_avx)
12815
12816 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12817 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12818 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12819
12820 + pax_force_retaddr
12821 ret;
12822 ENDPROC(__serpent_dec_blk8_avx)
12823
12824 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12825
12826 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12827
12828 + pax_force_retaddr
12829 ret;
12830 ENDPROC(serpent_ecb_enc_8way_avx)
12831
12832 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12833
12834 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12835
12836 + pax_force_retaddr
12837 ret;
12838 ENDPROC(serpent_ecb_dec_8way_avx)
12839
12840 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12841
12842 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12843
12844 + pax_force_retaddr
12845 ret;
12846 ENDPROC(serpent_cbc_dec_8way_avx)
12847
12848 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12849
12850 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12851
12852 + pax_force_retaddr
12853 ret;
12854 ENDPROC(serpent_ctr_8way_avx)
12855
12856 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12857 /* dst <= regs xor IVs(in dst) */
12858 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12859
12860 + pax_force_retaddr
12861 ret;
12862 ENDPROC(serpent_xts_enc_8way_avx)
12863
12864 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12865 /* dst <= regs xor IVs(in dst) */
12866 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12867
12868 + pax_force_retaddr
12869 ret;
12870 ENDPROC(serpent_xts_dec_8way_avx)
12871 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12872 index b222085..abd483c 100644
12873 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12874 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12875 @@ -15,6 +15,7 @@
12876 */
12877
12878 #include <linux/linkage.h>
12879 +#include <asm/alternative-asm.h>
12880 #include "glue_helper-asm-avx2.S"
12881
12882 .file "serpent-avx2-asm_64.S"
12883 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12884 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12885 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12886
12887 + pax_force_retaddr
12888 ret;
12889 ENDPROC(__serpent_enc_blk16)
12890
12891 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12892 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12893 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12894
12895 + pax_force_retaddr
12896 ret;
12897 ENDPROC(__serpent_dec_blk16)
12898
12899 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12900
12901 vzeroupper;
12902
12903 + pax_force_retaddr
12904 ret;
12905 ENDPROC(serpent_ecb_enc_16way)
12906
12907 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12908
12909 vzeroupper;
12910
12911 + pax_force_retaddr
12912 ret;
12913 ENDPROC(serpent_ecb_dec_16way)
12914
12915 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12916
12917 vzeroupper;
12918
12919 + pax_force_retaddr
12920 ret;
12921 ENDPROC(serpent_cbc_dec_16way)
12922
12923 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12924
12925 vzeroupper;
12926
12927 + pax_force_retaddr
12928 ret;
12929 ENDPROC(serpent_ctr_16way)
12930
12931 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12932
12933 vzeroupper;
12934
12935 + pax_force_retaddr
12936 ret;
12937 ENDPROC(serpent_xts_enc_16way)
12938
12939 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12940
12941 vzeroupper;
12942
12943 + pax_force_retaddr
12944 ret;
12945 ENDPROC(serpent_xts_dec_16way)
12946 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12947 index acc066c..1559cc4 100644
12948 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12949 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12950 @@ -25,6 +25,7 @@
12951 */
12952
12953 #include <linux/linkage.h>
12954 +#include <asm/alternative-asm.h>
12955
12956 .file "serpent-sse2-x86_64-asm_64.S"
12957 .text
12958 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12959 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12960 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12961
12962 + pax_force_retaddr
12963 ret;
12964
12965 .L__enc_xor8:
12966 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12967 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12968
12969 + pax_force_retaddr
12970 ret;
12971 ENDPROC(__serpent_enc_blk_8way)
12972
12973 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12974 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12975 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12976
12977 + pax_force_retaddr
12978 ret;
12979 ENDPROC(serpent_dec_blk_8way)
12980 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12981 index a410950..3356d42 100644
12982 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12983 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12984 @@ -29,6 +29,7 @@
12985 */
12986
12987 #include <linux/linkage.h>
12988 +#include <asm/alternative-asm.h>
12989
12990 #define CTX %rdi // arg1
12991 #define BUF %rsi // arg2
12992 @@ -104,6 +105,7 @@
12993 pop %r12
12994 pop %rbp
12995 pop %rbx
12996 + pax_force_retaddr 0, 1
12997 ret
12998
12999 ENDPROC(\name)
13000 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13001 index 642f156..4ab07b9 100644
13002 --- a/arch/x86/crypto/sha256-avx-asm.S
13003 +++ b/arch/x86/crypto/sha256-avx-asm.S
13004 @@ -49,6 +49,7 @@
13005
13006 #ifdef CONFIG_AS_AVX
13007 #include <linux/linkage.h>
13008 +#include <asm/alternative-asm.h>
13009
13010 ## assume buffers not aligned
13011 #define VMOVDQ vmovdqu
13012 @@ -460,6 +461,7 @@ done_hash:
13013 popq %r13
13014 popq %rbp
13015 popq %rbx
13016 + pax_force_retaddr 0, 1
13017 ret
13018 ENDPROC(sha256_transform_avx)
13019
13020 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13021 index 9e86944..2e7f95a 100644
13022 --- a/arch/x86/crypto/sha256-avx2-asm.S
13023 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13024 @@ -50,6 +50,7 @@
13025
13026 #ifdef CONFIG_AS_AVX2
13027 #include <linux/linkage.h>
13028 +#include <asm/alternative-asm.h>
13029
13030 ## assume buffers not aligned
13031 #define VMOVDQ vmovdqu
13032 @@ -720,6 +721,7 @@ done_hash:
13033 popq %r12
13034 popq %rbp
13035 popq %rbx
13036 + pax_force_retaddr 0, 1
13037 ret
13038 ENDPROC(sha256_transform_rorx)
13039
13040 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13041 index f833b74..c36ed14 100644
13042 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13043 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13044 @@ -47,6 +47,7 @@
13045 ########################################################################
13046
13047 #include <linux/linkage.h>
13048 +#include <asm/alternative-asm.h>
13049
13050 ## assume buffers not aligned
13051 #define MOVDQ movdqu
13052 @@ -471,6 +472,7 @@ done_hash:
13053 popq %rbp
13054 popq %rbx
13055
13056 + pax_force_retaddr 0, 1
13057 ret
13058 ENDPROC(sha256_transform_ssse3)
13059
13060 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13061 index 974dde9..4533d34 100644
13062 --- a/arch/x86/crypto/sha512-avx-asm.S
13063 +++ b/arch/x86/crypto/sha512-avx-asm.S
13064 @@ -49,6 +49,7 @@
13065
13066 #ifdef CONFIG_AS_AVX
13067 #include <linux/linkage.h>
13068 +#include <asm/alternative-asm.h>
13069
13070 .text
13071
13072 @@ -364,6 +365,7 @@ updateblock:
13073 mov frame_RSPSAVE(%rsp), %rsp
13074
13075 nowork:
13076 + pax_force_retaddr 0, 1
13077 ret
13078 ENDPROC(sha512_transform_avx)
13079
13080 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13081 index 568b961..061ef1d 100644
13082 --- a/arch/x86/crypto/sha512-avx2-asm.S
13083 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13084 @@ -51,6 +51,7 @@
13085
13086 #ifdef CONFIG_AS_AVX2
13087 #include <linux/linkage.h>
13088 +#include <asm/alternative-asm.h>
13089
13090 .text
13091
13092 @@ -678,6 +679,7 @@ done_hash:
13093
13094 # Restore Stack Pointer
13095 mov frame_RSPSAVE(%rsp), %rsp
13096 + pax_force_retaddr 0, 1
13097 ret
13098 ENDPROC(sha512_transform_rorx)
13099
13100 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13101 index fb56855..e23914f 100644
13102 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13103 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13104 @@ -48,6 +48,7 @@
13105 ########################################################################
13106
13107 #include <linux/linkage.h>
13108 +#include <asm/alternative-asm.h>
13109
13110 .text
13111
13112 @@ -363,6 +364,7 @@ updateblock:
13113 mov frame_RSPSAVE(%rsp), %rsp
13114
13115 nowork:
13116 + pax_force_retaddr 0, 1
13117 ret
13118 ENDPROC(sha512_transform_ssse3)
13119
13120 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13121 index 0505813..63b1d00 100644
13122 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13123 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13124 @@ -24,6 +24,7 @@
13125 */
13126
13127 #include <linux/linkage.h>
13128 +#include <asm/alternative-asm.h>
13129 #include "glue_helper-asm-avx.S"
13130
13131 .file "twofish-avx-x86_64-asm_64.S"
13132 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13133 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13134 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13135
13136 + pax_force_retaddr 0, 1
13137 ret;
13138 ENDPROC(__twofish_enc_blk8)
13139
13140 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13141 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13142 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13143
13144 + pax_force_retaddr 0, 1
13145 ret;
13146 ENDPROC(__twofish_dec_blk8)
13147
13148 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13149
13150 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13151
13152 + pax_force_retaddr 0, 1
13153 ret;
13154 ENDPROC(twofish_ecb_enc_8way)
13155
13156 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13157
13158 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13159
13160 + pax_force_retaddr 0, 1
13161 ret;
13162 ENDPROC(twofish_ecb_dec_8way)
13163
13164 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13165
13166 popq %r12;
13167
13168 + pax_force_retaddr 0, 1
13169 ret;
13170 ENDPROC(twofish_cbc_dec_8way)
13171
13172 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13173
13174 popq %r12;
13175
13176 + pax_force_retaddr 0, 1
13177 ret;
13178 ENDPROC(twofish_ctr_8way)
13179
13180 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13181 /* dst <= regs xor IVs(in dst) */
13182 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13183
13184 + pax_force_retaddr 0, 1
13185 ret;
13186 ENDPROC(twofish_xts_enc_8way)
13187
13188 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13189 /* dst <= regs xor IVs(in dst) */
13190 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13191
13192 + pax_force_retaddr 0, 1
13193 ret;
13194 ENDPROC(twofish_xts_dec_8way)
13195 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13196 index 1c3b7ce..b365c5e 100644
13197 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13198 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13199 @@ -21,6 +21,7 @@
13200 */
13201
13202 #include <linux/linkage.h>
13203 +#include <asm/alternative-asm.h>
13204
13205 .file "twofish-x86_64-asm-3way.S"
13206 .text
13207 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13208 popq %r13;
13209 popq %r14;
13210 popq %r15;
13211 + pax_force_retaddr 0, 1
13212 ret;
13213
13214 .L__enc_xor3:
13215 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13216 popq %r13;
13217 popq %r14;
13218 popq %r15;
13219 + pax_force_retaddr 0, 1
13220 ret;
13221 ENDPROC(__twofish_enc_blk_3way)
13222
13223 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13224 popq %r13;
13225 popq %r14;
13226 popq %r15;
13227 + pax_force_retaddr 0, 1
13228 ret;
13229 ENDPROC(twofish_dec_blk_3way)
13230 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13231 index a039d21..29e7615 100644
13232 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13233 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13234 @@ -22,6 +22,7 @@
13235
13236 #include <linux/linkage.h>
13237 #include <asm/asm-offsets.h>
13238 +#include <asm/alternative-asm.h>
13239
13240 #define a_offset 0
13241 #define b_offset 4
13242 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13243
13244 popq R1
13245 movq $1,%rax
13246 + pax_force_retaddr 0, 1
13247 ret
13248 ENDPROC(twofish_enc_blk)
13249
13250 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13251
13252 popq R1
13253 movq $1,%rax
13254 + pax_force_retaddr 0, 1
13255 ret
13256 ENDPROC(twofish_dec_blk)
13257 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13258 index bae3aba..c1788c1 100644
13259 --- a/arch/x86/ia32/ia32_aout.c
13260 +++ b/arch/x86/ia32/ia32_aout.c
13261 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13262 unsigned long dump_start, dump_size;
13263 struct user32 dump;
13264
13265 + memset(&dump, 0, sizeof(dump));
13266 +
13267 fs = get_fs();
13268 set_fs(KERNEL_DS);
13269 has_dumped = 1;
13270 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13271 index 665a730..8e7a67a 100644
13272 --- a/arch/x86/ia32/ia32_signal.c
13273 +++ b/arch/x86/ia32/ia32_signal.c
13274 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13275 sp -= frame_size;
13276 /* Align the stack pointer according to the i386 ABI,
13277 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13278 - sp = ((sp + 4) & -16ul) - 4;
13279 + sp = ((sp - 12) & -16ul) - 4;
13280 return (void __user *) sp;
13281 }
13282
13283 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13284 * These are actually not used anymore, but left because some
13285 * gdb versions depend on them as a marker.
13286 */
13287 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13288 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13289 } put_user_catch(err);
13290
13291 if (err)
13292 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13293 0xb8,
13294 __NR_ia32_rt_sigreturn,
13295 0x80cd,
13296 - 0,
13297 + 0
13298 };
13299
13300 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13301 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13302
13303 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13304 restorer = ksig->ka.sa.sa_restorer;
13305 + else if (current->mm->context.vdso)
13306 + /* Return stub is in 32bit vsyscall page */
13307 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13308 else
13309 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13310 - rt_sigreturn);
13311 + restorer = &frame->retcode;
13312 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13313
13314 /*
13315 * Not actually used anymore, but left because some gdb
13316 * versions need it.
13317 */
13318 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13319 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13320 } put_user_catch(err);
13321
13322 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13323 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13324 index 474dc1b..9297c58 100644
13325 --- a/arch/x86/ia32/ia32entry.S
13326 +++ b/arch/x86/ia32/ia32entry.S
13327 @@ -15,8 +15,10 @@
13328 #include <asm/irqflags.h>
13329 #include <asm/asm.h>
13330 #include <asm/smap.h>
13331 +#include <asm/pgtable.h>
13332 #include <linux/linkage.h>
13333 #include <linux/err.h>
13334 +#include <asm/alternative-asm.h>
13335
13336 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13337 #include <linux/elf-em.h>
13338 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13339 ENDPROC(native_irq_enable_sysexit)
13340 #endif
13341
13342 + .macro pax_enter_kernel_user
13343 + pax_set_fptr_mask
13344 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13345 + call pax_enter_kernel_user
13346 +#endif
13347 + .endm
13348 +
13349 + .macro pax_exit_kernel_user
13350 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13351 + call pax_exit_kernel_user
13352 +#endif
13353 +#ifdef CONFIG_PAX_RANDKSTACK
13354 + pushq %rax
13355 + pushq %r11
13356 + call pax_randomize_kstack
13357 + popq %r11
13358 + popq %rax
13359 +#endif
13360 + .endm
13361 +
13362 + .macro pax_erase_kstack
13363 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13364 + call pax_erase_kstack
13365 +#endif
13366 + .endm
13367 +
13368 /*
13369 * 32bit SYSENTER instruction entry.
13370 *
13371 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13372 CFI_REGISTER rsp,rbp
13373 SWAPGS_UNSAFE_STACK
13374 movq PER_CPU_VAR(kernel_stack), %rsp
13375 - addq $(KERNEL_STACK_OFFSET),%rsp
13376 - /*
13377 - * No need to follow this irqs on/off section: the syscall
13378 - * disabled irqs, here we enable it straight after entry:
13379 - */
13380 - ENABLE_INTERRUPTS(CLBR_NONE)
13381 movl %ebp,%ebp /* zero extension */
13382 pushq_cfi $__USER32_DS
13383 /*CFI_REL_OFFSET ss,0*/
13384 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13385 CFI_REL_OFFSET rsp,0
13386 pushfq_cfi
13387 /*CFI_REL_OFFSET rflags,0*/
13388 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13389 - CFI_REGISTER rip,r10
13390 + orl $X86_EFLAGS_IF,(%rsp)
13391 + GET_THREAD_INFO(%r11)
13392 + movl TI_sysenter_return(%r11), %r11d
13393 + CFI_REGISTER rip,r11
13394 pushq_cfi $__USER32_CS
13395 /*CFI_REL_OFFSET cs,0*/
13396 movl %eax, %eax
13397 - pushq_cfi %r10
13398 + pushq_cfi %r11
13399 CFI_REL_OFFSET rip,0
13400 pushq_cfi %rax
13401 cld
13402 SAVE_ARGS 0,1,0
13403 + pax_enter_kernel_user
13404 +
13405 +#ifdef CONFIG_PAX_RANDKSTACK
13406 + pax_erase_kstack
13407 +#endif
13408 +
13409 + /*
13410 + * No need to follow this irqs on/off section: the syscall
13411 + * disabled irqs, here we enable it straight after entry:
13412 + */
13413 + ENABLE_INTERRUPTS(CLBR_NONE)
13414 /* no need to do an access_ok check here because rbp has been
13415 32bit zero extended */
13416 +
13417 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13418 + addq pax_user_shadow_base,%rbp
13419 + ASM_PAX_OPEN_USERLAND
13420 +#endif
13421 +
13422 ASM_STAC
13423 1: movl (%rbp),%ebp
13424 _ASM_EXTABLE(1b,ia32_badarg)
13425 ASM_CLAC
13426 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13427 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13428 +
13429 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13430 + ASM_PAX_CLOSE_USERLAND
13431 +#endif
13432 +
13433 + GET_THREAD_INFO(%r11)
13434 + orl $TS_COMPAT,TI_status(%r11)
13435 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13436 CFI_REMEMBER_STATE
13437 jnz sysenter_tracesys
13438 cmpq $(IA32_NR_syscalls-1),%rax
13439 @@ -162,12 +209,15 @@ sysenter_do_call:
13440 sysenter_dispatch:
13441 call *ia32_sys_call_table(,%rax,8)
13442 movq %rax,RAX-ARGOFFSET(%rsp)
13443 + GET_THREAD_INFO(%r11)
13444 DISABLE_INTERRUPTS(CLBR_NONE)
13445 TRACE_IRQS_OFF
13446 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13447 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13448 jnz sysexit_audit
13449 sysexit_from_sys_call:
13450 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13451 + pax_exit_kernel_user
13452 + pax_erase_kstack
13453 + andl $~TS_COMPAT,TI_status(%r11)
13454 /* clear IF, that popfq doesn't enable interrupts early */
13455 andl $~0x200,EFLAGS-R11(%rsp)
13456 movl RIP-R11(%rsp),%edx /* User %eip */
13457 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13458 movl %eax,%esi /* 2nd arg: syscall number */
13459 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13460 call __audit_syscall_entry
13461 +
13462 + pax_erase_kstack
13463 +
13464 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13465 cmpq $(IA32_NR_syscalls-1),%rax
13466 ja ia32_badsys
13467 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13468 .endm
13469
13470 .macro auditsys_exit exit
13471 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13472 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13473 jnz ia32_ret_from_sys_call
13474 TRACE_IRQS_ON
13475 ENABLE_INTERRUPTS(CLBR_NONE)
13476 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13477 1: setbe %al /* 1 if error, 0 if not */
13478 movzbl %al,%edi /* zero-extend that into %edi */
13479 call __audit_syscall_exit
13480 + GET_THREAD_INFO(%r11)
13481 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13482 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13483 DISABLE_INTERRUPTS(CLBR_NONE)
13484 TRACE_IRQS_OFF
13485 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13486 + testl %edi,TI_flags(%r11)
13487 jz \exit
13488 CLEAR_RREGS -ARGOFFSET
13489 jmp int_with_check
13490 @@ -237,7 +291,7 @@ sysexit_audit:
13491
13492 sysenter_tracesys:
13493 #ifdef CONFIG_AUDITSYSCALL
13494 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13495 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13496 jz sysenter_auditsys
13497 #endif
13498 SAVE_REST
13499 @@ -249,6 +303,9 @@ sysenter_tracesys:
13500 RESTORE_REST
13501 cmpq $(IA32_NR_syscalls-1),%rax
13502 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13503 +
13504 + pax_erase_kstack
13505 +
13506 jmp sysenter_do_call
13507 CFI_ENDPROC
13508 ENDPROC(ia32_sysenter_target)
13509 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13510 ENTRY(ia32_cstar_target)
13511 CFI_STARTPROC32 simple
13512 CFI_SIGNAL_FRAME
13513 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13514 + CFI_DEF_CFA rsp,0
13515 CFI_REGISTER rip,rcx
13516 /*CFI_REGISTER rflags,r11*/
13517 SWAPGS_UNSAFE_STACK
13518 movl %esp,%r8d
13519 CFI_REGISTER rsp,r8
13520 movq PER_CPU_VAR(kernel_stack),%rsp
13521 + SAVE_ARGS 8*6,0,0
13522 + pax_enter_kernel_user
13523 +
13524 +#ifdef CONFIG_PAX_RANDKSTACK
13525 + pax_erase_kstack
13526 +#endif
13527 +
13528 /*
13529 * No need to follow this irqs on/off section: the syscall
13530 * disabled irqs and here we enable it straight after entry:
13531 */
13532 ENABLE_INTERRUPTS(CLBR_NONE)
13533 - SAVE_ARGS 8,0,0
13534 movl %eax,%eax /* zero extension */
13535 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13536 movq %rcx,RIP-ARGOFFSET(%rsp)
13537 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13538 /* no need to do an access_ok check here because r8 has been
13539 32bit zero extended */
13540 /* hardware stack frame is complete now */
13541 +
13542 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13543 + ASM_PAX_OPEN_USERLAND
13544 + movq pax_user_shadow_base,%r8
13545 + addq RSP-ARGOFFSET(%rsp),%r8
13546 +#endif
13547 +
13548 ASM_STAC
13549 1: movl (%r8),%r9d
13550 _ASM_EXTABLE(1b,ia32_badarg)
13551 ASM_CLAC
13552 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13554 +
13555 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13556 + ASM_PAX_CLOSE_USERLAND
13557 +#endif
13558 +
13559 + GET_THREAD_INFO(%r11)
13560 + orl $TS_COMPAT,TI_status(%r11)
13561 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13562 CFI_REMEMBER_STATE
13563 jnz cstar_tracesys
13564 cmpq $IA32_NR_syscalls-1,%rax
13565 @@ -319,12 +395,15 @@ cstar_do_call:
13566 cstar_dispatch:
13567 call *ia32_sys_call_table(,%rax,8)
13568 movq %rax,RAX-ARGOFFSET(%rsp)
13569 + GET_THREAD_INFO(%r11)
13570 DISABLE_INTERRUPTS(CLBR_NONE)
13571 TRACE_IRQS_OFF
13572 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13573 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13574 jnz sysretl_audit
13575 sysretl_from_sys_call:
13576 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13577 + pax_exit_kernel_user
13578 + pax_erase_kstack
13579 + andl $~TS_COMPAT,TI_status(%r11)
13580 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13581 movl RIP-ARGOFFSET(%rsp),%ecx
13582 CFI_REGISTER rip,rcx
13583 @@ -352,7 +431,7 @@ sysretl_audit:
13584
13585 cstar_tracesys:
13586 #ifdef CONFIG_AUDITSYSCALL
13587 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13588 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13589 jz cstar_auditsys
13590 #endif
13591 xchgl %r9d,%ebp
13592 @@ -366,11 +445,19 @@ cstar_tracesys:
13593 xchgl %ebp,%r9d
13594 cmpq $(IA32_NR_syscalls-1),%rax
13595 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13596 +
13597 + pax_erase_kstack
13598 +
13599 jmp cstar_do_call
13600 END(ia32_cstar_target)
13601
13602 ia32_badarg:
13603 ASM_CLAC
13604 +
13605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13606 + ASM_PAX_CLOSE_USERLAND
13607 +#endif
13608 +
13609 movq $-EFAULT,%rax
13610 jmp ia32_sysret
13611 CFI_ENDPROC
13612 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13613 CFI_REL_OFFSET rip,RIP-RIP
13614 PARAVIRT_ADJUST_EXCEPTION_FRAME
13615 SWAPGS
13616 - /*
13617 - * No need to follow this irqs on/off section: the syscall
13618 - * disabled irqs and here we enable it straight after entry:
13619 - */
13620 - ENABLE_INTERRUPTS(CLBR_NONE)
13621 movl %eax,%eax
13622 pushq_cfi %rax
13623 cld
13624 /* note the registers are not zero extended to the sf.
13625 this could be a problem. */
13626 SAVE_ARGS 0,1,0
13627 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13628 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13629 + pax_enter_kernel_user
13630 +
13631 +#ifdef CONFIG_PAX_RANDKSTACK
13632 + pax_erase_kstack
13633 +#endif
13634 +
13635 + /*
13636 + * No need to follow this irqs on/off section: the syscall
13637 + * disabled irqs and here we enable it straight after entry:
13638 + */
13639 + ENABLE_INTERRUPTS(CLBR_NONE)
13640 + GET_THREAD_INFO(%r11)
13641 + orl $TS_COMPAT,TI_status(%r11)
13642 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13643 jnz ia32_tracesys
13644 cmpq $(IA32_NR_syscalls-1),%rax
13645 ja ia32_badsys
13646 @@ -442,6 +536,9 @@ ia32_tracesys:
13647 RESTORE_REST
13648 cmpq $(IA32_NR_syscalls-1),%rax
13649 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13650 +
13651 + pax_erase_kstack
13652 +
13653 jmp ia32_do_call
13654 END(ia32_syscall)
13655
13656 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13657 index 8e0ceec..af13504 100644
13658 --- a/arch/x86/ia32/sys_ia32.c
13659 +++ b/arch/x86/ia32/sys_ia32.c
13660 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13661 */
13662 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13663 {
13664 - typeof(ubuf->st_uid) uid = 0;
13665 - typeof(ubuf->st_gid) gid = 0;
13666 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13667 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13668 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13669 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13670 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13671 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13672 index 372231c..a5aa1a1 100644
13673 --- a/arch/x86/include/asm/alternative-asm.h
13674 +++ b/arch/x86/include/asm/alternative-asm.h
13675 @@ -18,6 +18,45 @@
13676 .endm
13677 #endif
13678
13679 +#ifdef KERNEXEC_PLUGIN
13680 + .macro pax_force_retaddr_bts rip=0
13681 + btsq $63,\rip(%rsp)
13682 + .endm
13683 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13684 + .macro pax_force_retaddr rip=0, reload=0
13685 + btsq $63,\rip(%rsp)
13686 + .endm
13687 + .macro pax_force_fptr ptr
13688 + btsq $63,\ptr
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + .endm
13692 +#endif
13693 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13694 + .macro pax_force_retaddr rip=0, reload=0
13695 + .if \reload
13696 + pax_set_fptr_mask
13697 + .endif
13698 + orq %r10,\rip(%rsp)
13699 + .endm
13700 + .macro pax_force_fptr ptr
13701 + orq %r10,\ptr
13702 + .endm
13703 + .macro pax_set_fptr_mask
13704 + movabs $0x8000000000000000,%r10
13705 + .endm
13706 +#endif
13707 +#else
13708 + .macro pax_force_retaddr rip=0, reload=0
13709 + .endm
13710 + .macro pax_force_fptr ptr
13711 + .endm
13712 + .macro pax_force_retaddr_bts rip=0
13713 + .endm
13714 + .macro pax_set_fptr_mask
13715 + .endm
13716 +#endif
13717 +
13718 .macro altinstruction_entry orig alt feature orig_len alt_len
13719 .long \orig - .
13720 .long \alt - .
13721 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13722 index 58ed6d9..f1cbe58 100644
13723 --- a/arch/x86/include/asm/alternative.h
13724 +++ b/arch/x86/include/asm/alternative.h
13725 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13726 ".pushsection .discard,\"aw\",@progbits\n" \
13727 DISCARD_ENTRY(1) \
13728 ".popsection\n" \
13729 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13730 + ".pushsection .altinstr_replacement, \"a\"\n" \
13731 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13732 ".popsection"
13733
13734 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13735 DISCARD_ENTRY(1) \
13736 DISCARD_ENTRY(2) \
13737 ".popsection\n" \
13738 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13739 + ".pushsection .altinstr_replacement, \"a\"\n" \
13740 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13741 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13742 ".popsection"
13743 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13744 index f8119b5..7209d5b 100644
13745 --- a/arch/x86/include/asm/apic.h
13746 +++ b/arch/x86/include/asm/apic.h
13747 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13748
13749 #ifdef CONFIG_X86_LOCAL_APIC
13750
13751 -extern unsigned int apic_verbosity;
13752 +extern int apic_verbosity;
13753 extern int local_apic_timer_c2_ok;
13754
13755 extern int disable_apic;
13756 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13757 index 20370c6..a2eb9b0 100644
13758 --- a/arch/x86/include/asm/apm.h
13759 +++ b/arch/x86/include/asm/apm.h
13760 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13761 __asm__ __volatile__(APM_DO_ZERO_SEGS
13762 "pushl %%edi\n\t"
13763 "pushl %%ebp\n\t"
13764 - "lcall *%%cs:apm_bios_entry\n\t"
13765 + "lcall *%%ss:apm_bios_entry\n\t"
13766 "setc %%al\n\t"
13767 "popl %%ebp\n\t"
13768 "popl %%edi\n\t"
13769 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13770 __asm__ __volatile__(APM_DO_ZERO_SEGS
13771 "pushl %%edi\n\t"
13772 "pushl %%ebp\n\t"
13773 - "lcall *%%cs:apm_bios_entry\n\t"
13774 + "lcall *%%ss:apm_bios_entry\n\t"
13775 "setc %%bl\n\t"
13776 "popl %%ebp\n\t"
13777 "popl %%edi\n\t"
13778 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13779 index 722aa3b..3a0bb27 100644
13780 --- a/arch/x86/include/asm/atomic.h
13781 +++ b/arch/x86/include/asm/atomic.h
13782 @@ -22,7 +22,18 @@
13783 */
13784 static inline int atomic_read(const atomic_t *v)
13785 {
13786 - return (*(volatile int *)&(v)->counter);
13787 + return (*(volatile const int *)&(v)->counter);
13788 +}
13789 +
13790 +/**
13791 + * atomic_read_unchecked - read atomic variable
13792 + * @v: pointer of type atomic_unchecked_t
13793 + *
13794 + * Atomically reads the value of @v.
13795 + */
13796 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13797 +{
13798 + return (*(volatile const int *)&(v)->counter);
13799 }
13800
13801 /**
13802 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13803 }
13804
13805 /**
13806 + * atomic_set_unchecked - set atomic variable
13807 + * @v: pointer of type atomic_unchecked_t
13808 + * @i: required value
13809 + *
13810 + * Atomically sets the value of @v to @i.
13811 + */
13812 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13813 +{
13814 + v->counter = i;
13815 +}
13816 +
13817 +/**
13818 * atomic_add - add integer to atomic variable
13819 * @i: integer value to add
13820 * @v: pointer of type atomic_t
13821 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13822 */
13823 static inline void atomic_add(int i, atomic_t *v)
13824 {
13825 - asm volatile(LOCK_PREFIX "addl %1,%0"
13826 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13827 +
13828 +#ifdef CONFIG_PAX_REFCOUNT
13829 + "jno 0f\n"
13830 + LOCK_PREFIX "subl %1,%0\n"
13831 + "int $4\n0:\n"
13832 + _ASM_EXTABLE(0b, 0b)
13833 +#endif
13834 +
13835 + : "+m" (v->counter)
13836 + : "ir" (i));
13837 +}
13838 +
13839 +/**
13840 + * atomic_add_unchecked - add integer to atomic variable
13841 + * @i: integer value to add
13842 + * @v: pointer of type atomic_unchecked_t
13843 + *
13844 + * Atomically adds @i to @v.
13845 + */
13846 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13847 +{
13848 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13849 : "+m" (v->counter)
13850 : "ir" (i));
13851 }
13852 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13853 */
13854 static inline void atomic_sub(int i, atomic_t *v)
13855 {
13856 - asm volatile(LOCK_PREFIX "subl %1,%0"
13857 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13858 +
13859 +#ifdef CONFIG_PAX_REFCOUNT
13860 + "jno 0f\n"
13861 + LOCK_PREFIX "addl %1,%0\n"
13862 + "int $4\n0:\n"
13863 + _ASM_EXTABLE(0b, 0b)
13864 +#endif
13865 +
13866 + : "+m" (v->counter)
13867 + : "ir" (i));
13868 +}
13869 +
13870 +/**
13871 + * atomic_sub_unchecked - subtract integer from atomic variable
13872 + * @i: integer value to subtract
13873 + * @v: pointer of type atomic_unchecked_t
13874 + *
13875 + * Atomically subtracts @i from @v.
13876 + */
13877 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13878 +{
13879 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13880 : "+m" (v->counter)
13881 : "ir" (i));
13882 }
13883 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13884 {
13885 unsigned char c;
13886
13887 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13888 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13889 +
13890 +#ifdef CONFIG_PAX_REFCOUNT
13891 + "jno 0f\n"
13892 + LOCK_PREFIX "addl %2,%0\n"
13893 + "int $4\n0:\n"
13894 + _ASM_EXTABLE(0b, 0b)
13895 +#endif
13896 +
13897 + "sete %1\n"
13898 : "+m" (v->counter), "=qm" (c)
13899 : "ir" (i) : "memory");
13900 return c;
13901 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13902 */
13903 static inline void atomic_inc(atomic_t *v)
13904 {
13905 - asm volatile(LOCK_PREFIX "incl %0"
13906 + asm volatile(LOCK_PREFIX "incl %0\n"
13907 +
13908 +#ifdef CONFIG_PAX_REFCOUNT
13909 + "jno 0f\n"
13910 + LOCK_PREFIX "decl %0\n"
13911 + "int $4\n0:\n"
13912 + _ASM_EXTABLE(0b, 0b)
13913 +#endif
13914 +
13915 + : "+m" (v->counter));
13916 +}
13917 +
13918 +/**
13919 + * atomic_inc_unchecked - increment atomic variable
13920 + * @v: pointer of type atomic_unchecked_t
13921 + *
13922 + * Atomically increments @v by 1.
13923 + */
13924 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13925 +{
13926 + asm volatile(LOCK_PREFIX "incl %0\n"
13927 : "+m" (v->counter));
13928 }
13929
13930 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13931 */
13932 static inline void atomic_dec(atomic_t *v)
13933 {
13934 - asm volatile(LOCK_PREFIX "decl %0"
13935 + asm volatile(LOCK_PREFIX "decl %0\n"
13936 +
13937 +#ifdef CONFIG_PAX_REFCOUNT
13938 + "jno 0f\n"
13939 + LOCK_PREFIX "incl %0\n"
13940 + "int $4\n0:\n"
13941 + _ASM_EXTABLE(0b, 0b)
13942 +#endif
13943 +
13944 + : "+m" (v->counter));
13945 +}
13946 +
13947 +/**
13948 + * atomic_dec_unchecked - decrement atomic variable
13949 + * @v: pointer of type atomic_unchecked_t
13950 + *
13951 + * Atomically decrements @v by 1.
13952 + */
13953 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13954 +{
13955 + asm volatile(LOCK_PREFIX "decl %0\n"
13956 : "+m" (v->counter));
13957 }
13958
13959 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13960 {
13961 unsigned char c;
13962
13963 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13964 + asm volatile(LOCK_PREFIX "decl %0\n"
13965 +
13966 +#ifdef CONFIG_PAX_REFCOUNT
13967 + "jno 0f\n"
13968 + LOCK_PREFIX "incl %0\n"
13969 + "int $4\n0:\n"
13970 + _ASM_EXTABLE(0b, 0b)
13971 +#endif
13972 +
13973 + "sete %1\n"
13974 : "+m" (v->counter), "=qm" (c)
13975 : : "memory");
13976 return c != 0;
13977 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13978 {
13979 unsigned char c;
13980
13981 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13982 + asm volatile(LOCK_PREFIX "incl %0\n"
13983 +
13984 +#ifdef CONFIG_PAX_REFCOUNT
13985 + "jno 0f\n"
13986 + LOCK_PREFIX "decl %0\n"
13987 + "int $4\n0:\n"
13988 + _ASM_EXTABLE(0b, 0b)
13989 +#endif
13990 +
13991 + "sete %1\n"
13992 + : "+m" (v->counter), "=qm" (c)
13993 + : : "memory");
13994 + return c != 0;
13995 +}
13996 +
13997 +/**
13998 + * atomic_inc_and_test_unchecked - increment and test
13999 + * @v: pointer of type atomic_unchecked_t
14000 + *
14001 + * Atomically increments @v by 1
14002 + * and returns true if the result is zero, or false for all
14003 + * other cases.
14004 + */
14005 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14006 +{
14007 + unsigned char c;
14008 +
14009 + asm volatile(LOCK_PREFIX "incl %0\n"
14010 + "sete %1\n"
14011 : "+m" (v->counter), "=qm" (c)
14012 : : "memory");
14013 return c != 0;
14014 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14015 {
14016 unsigned char c;
14017
14018 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14019 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14020 +
14021 +#ifdef CONFIG_PAX_REFCOUNT
14022 + "jno 0f\n"
14023 + LOCK_PREFIX "subl %2,%0\n"
14024 + "int $4\n0:\n"
14025 + _ASM_EXTABLE(0b, 0b)
14026 +#endif
14027 +
14028 + "sets %1\n"
14029 : "+m" (v->counter), "=qm" (c)
14030 : "ir" (i) : "memory");
14031 return c;
14032 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14033 */
14034 static inline int atomic_add_return(int i, atomic_t *v)
14035 {
14036 + return i + xadd_check_overflow(&v->counter, i);
14037 +}
14038 +
14039 +/**
14040 + * atomic_add_return_unchecked - add integer and return
14041 + * @i: integer value to add
14042 + * @v: pointer of type atomic_unchecked_t
14043 + *
14044 + * Atomically adds @i to @v and returns @i + @v
14045 + */
14046 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14047 +{
14048 return i + xadd(&v->counter, i);
14049 }
14050
14051 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14052 }
14053
14054 #define atomic_inc_return(v) (atomic_add_return(1, v))
14055 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14056 +{
14057 + return atomic_add_return_unchecked(1, v);
14058 +}
14059 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14060
14061 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14062 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14063 return cmpxchg(&v->counter, old, new);
14064 }
14065
14066 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14067 +{
14068 + return cmpxchg(&v->counter, old, new);
14069 +}
14070 +
14071 static inline int atomic_xchg(atomic_t *v, int new)
14072 {
14073 return xchg(&v->counter, new);
14074 }
14075
14076 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14077 +{
14078 + return xchg(&v->counter, new);
14079 +}
14080 +
14081 /**
14082 * __atomic_add_unless - add unless the number is already a given value
14083 * @v: pointer of type atomic_t
14084 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14085 */
14086 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14087 {
14088 - int c, old;
14089 + int c, old, new;
14090 c = atomic_read(v);
14091 for (;;) {
14092 - if (unlikely(c == (u)))
14093 + if (unlikely(c == u))
14094 break;
14095 - old = atomic_cmpxchg((v), c, c + (a));
14096 +
14097 + asm volatile("addl %2,%0\n"
14098 +
14099 +#ifdef CONFIG_PAX_REFCOUNT
14100 + "jno 0f\n"
14101 + "subl %2,%0\n"
14102 + "int $4\n0:\n"
14103 + _ASM_EXTABLE(0b, 0b)
14104 +#endif
14105 +
14106 + : "=r" (new)
14107 + : "0" (c), "ir" (a));
14108 +
14109 + old = atomic_cmpxchg(v, c, new);
14110 if (likely(old == c))
14111 break;
14112 c = old;
14113 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14114 }
14115
14116 /**
14117 + * atomic_inc_not_zero_hint - increment if not null
14118 + * @v: pointer of type atomic_t
14119 + * @hint: probable value of the atomic before the increment
14120 + *
14121 + * This version of atomic_inc_not_zero() gives a hint of probable
14122 + * value of the atomic. This helps processor to not read the memory
14123 + * before doing the atomic read/modify/write cycle, lowering
14124 + * number of bus transactions on some arches.
14125 + *
14126 + * Returns: 0 if increment was not done, 1 otherwise.
14127 + */
14128 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14129 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14130 +{
14131 + int val, c = hint, new;
14132 +
14133 + /* sanity test, should be removed by compiler if hint is a constant */
14134 + if (!hint)
14135 + return __atomic_add_unless(v, 1, 0);
14136 +
14137 + do {
14138 + asm volatile("incl %0\n"
14139 +
14140 +#ifdef CONFIG_PAX_REFCOUNT
14141 + "jno 0f\n"
14142 + "decl %0\n"
14143 + "int $4\n0:\n"
14144 + _ASM_EXTABLE(0b, 0b)
14145 +#endif
14146 +
14147 + : "=r" (new)
14148 + : "0" (c));
14149 +
14150 + val = atomic_cmpxchg(v, c, new);
14151 + if (val == c)
14152 + return 1;
14153 + c = val;
14154 + } while (c);
14155 +
14156 + return 0;
14157 +}
14158 +
14159 +/**
14160 * atomic_inc_short - increment of a short integer
14161 * @v: pointer to type int
14162 *
14163 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14164 #endif
14165
14166 /* These are x86-specific, used by some header files */
14167 -#define atomic_clear_mask(mask, addr) \
14168 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14169 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14170 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14171 +{
14172 + asm volatile(LOCK_PREFIX "andl %1,%0"
14173 + : "+m" (v->counter)
14174 + : "r" (~(mask))
14175 + : "memory");
14176 +}
14177
14178 -#define atomic_set_mask(mask, addr) \
14179 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14180 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14181 - : "memory")
14182 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14183 +{
14184 + asm volatile(LOCK_PREFIX "andl %1,%0"
14185 + : "+m" (v->counter)
14186 + : "r" (~(mask))
14187 + : "memory");
14188 +}
14189 +
14190 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14191 +{
14192 + asm volatile(LOCK_PREFIX "orl %1,%0"
14193 + : "+m" (v->counter)
14194 + : "r" (mask)
14195 + : "memory");
14196 +}
14197 +
14198 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14199 +{
14200 + asm volatile(LOCK_PREFIX "orl %1,%0"
14201 + : "+m" (v->counter)
14202 + : "r" (mask)
14203 + : "memory");
14204 +}
14205
14206 /* Atomic operations are already serializing on x86 */
14207 #define smp_mb__before_atomic_dec() barrier()
14208 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14209 index b154de7..aadebd8 100644
14210 --- a/arch/x86/include/asm/atomic64_32.h
14211 +++ b/arch/x86/include/asm/atomic64_32.h
14212 @@ -12,6 +12,14 @@ typedef struct {
14213 u64 __aligned(8) counter;
14214 } atomic64_t;
14215
14216 +#ifdef CONFIG_PAX_REFCOUNT
14217 +typedef struct {
14218 + u64 __aligned(8) counter;
14219 +} atomic64_unchecked_t;
14220 +#else
14221 +typedef atomic64_t atomic64_unchecked_t;
14222 +#endif
14223 +
14224 #define ATOMIC64_INIT(val) { (val) }
14225
14226 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14227 @@ -37,21 +45,31 @@ typedef struct {
14228 ATOMIC64_DECL_ONE(sym##_386)
14229
14230 ATOMIC64_DECL_ONE(add_386);
14231 +ATOMIC64_DECL_ONE(add_unchecked_386);
14232 ATOMIC64_DECL_ONE(sub_386);
14233 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14234 ATOMIC64_DECL_ONE(inc_386);
14235 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14236 ATOMIC64_DECL_ONE(dec_386);
14237 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14238 #endif
14239
14240 #define alternative_atomic64(f, out, in...) \
14241 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14242
14243 ATOMIC64_DECL(read);
14244 +ATOMIC64_DECL(read_unchecked);
14245 ATOMIC64_DECL(set);
14246 +ATOMIC64_DECL(set_unchecked);
14247 ATOMIC64_DECL(xchg);
14248 ATOMIC64_DECL(add_return);
14249 +ATOMIC64_DECL(add_return_unchecked);
14250 ATOMIC64_DECL(sub_return);
14251 +ATOMIC64_DECL(sub_return_unchecked);
14252 ATOMIC64_DECL(inc_return);
14253 +ATOMIC64_DECL(inc_return_unchecked);
14254 ATOMIC64_DECL(dec_return);
14255 +ATOMIC64_DECL(dec_return_unchecked);
14256 ATOMIC64_DECL(dec_if_positive);
14257 ATOMIC64_DECL(inc_not_zero);
14258 ATOMIC64_DECL(add_unless);
14259 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14260 }
14261
14262 /**
14263 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14264 + * @p: pointer to type atomic64_unchecked_t
14265 + * @o: expected value
14266 + * @n: new value
14267 + *
14268 + * Atomically sets @v to @n if it was equal to @o and returns
14269 + * the old value.
14270 + */
14271 +
14272 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14273 +{
14274 + return cmpxchg64(&v->counter, o, n);
14275 +}
14276 +
14277 +/**
14278 * atomic64_xchg - xchg atomic64 variable
14279 * @v: pointer to type atomic64_t
14280 * @n: value to assign
14281 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14282 }
14283
14284 /**
14285 + * atomic64_set_unchecked - set atomic64 variable
14286 + * @v: pointer to type atomic64_unchecked_t
14287 + * @n: value to assign
14288 + *
14289 + * Atomically sets the value of @v to @n.
14290 + */
14291 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14292 +{
14293 + unsigned high = (unsigned)(i >> 32);
14294 + unsigned low = (unsigned)i;
14295 + alternative_atomic64(set, /* no output */,
14296 + "S" (v), "b" (low), "c" (high)
14297 + : "eax", "edx", "memory");
14298 +}
14299 +
14300 +/**
14301 * atomic64_read - read atomic64 variable
14302 * @v: pointer to type atomic64_t
14303 *
14304 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14305 }
14306
14307 /**
14308 + * atomic64_read_unchecked - read atomic64 variable
14309 + * @v: pointer to type atomic64_unchecked_t
14310 + *
14311 + * Atomically reads the value of @v and returns it.
14312 + */
14313 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14314 +{
14315 + long long r;
14316 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14317 + return r;
14318 + }
14319 +
14320 +/**
14321 * atomic64_add_return - add and return
14322 * @i: integer value to add
14323 * @v: pointer to type atomic64_t
14324 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14325 return i;
14326 }
14327
14328 +/**
14329 + * atomic64_add_return_unchecked - add and return
14330 + * @i: integer value to add
14331 + * @v: pointer to type atomic64_unchecked_t
14332 + *
14333 + * Atomically adds @i to @v and returns @i + *@v
14334 + */
14335 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14336 +{
14337 + alternative_atomic64(add_return_unchecked,
14338 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14339 + ASM_NO_INPUT_CLOBBER("memory"));
14340 + return i;
14341 +}
14342 +
14343 /*
14344 * Other variants with different arithmetic operators:
14345 */
14346 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14347 return a;
14348 }
14349
14350 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14351 +{
14352 + long long a;
14353 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14354 + "S" (v) : "memory", "ecx");
14355 + return a;
14356 +}
14357 +
14358 static inline long long atomic64_dec_return(atomic64_t *v)
14359 {
14360 long long a;
14361 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14362 }
14363
14364 /**
14365 + * atomic64_add_unchecked - add integer to atomic64 variable
14366 + * @i: integer value to add
14367 + * @v: pointer to type atomic64_unchecked_t
14368 + *
14369 + * Atomically adds @i to @v.
14370 + */
14371 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14372 +{
14373 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14374 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14375 + ASM_NO_INPUT_CLOBBER("memory"));
14376 + return i;
14377 +}
14378 +
14379 +/**
14380 * atomic64_sub - subtract the atomic64 variable
14381 * @i: integer value to subtract
14382 * @v: pointer to type atomic64_t
14383 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14384 index 0e1cbfc..5623683 100644
14385 --- a/arch/x86/include/asm/atomic64_64.h
14386 +++ b/arch/x86/include/asm/atomic64_64.h
14387 @@ -18,7 +18,19 @@
14388 */
14389 static inline long atomic64_read(const atomic64_t *v)
14390 {
14391 - return (*(volatile long *)&(v)->counter);
14392 + return (*(volatile const long *)&(v)->counter);
14393 +}
14394 +
14395 +/**
14396 + * atomic64_read_unchecked - read atomic64 variable
14397 + * @v: pointer of type atomic64_unchecked_t
14398 + *
14399 + * Atomically reads the value of @v.
14400 + * Doesn't imply a read memory barrier.
14401 + */
14402 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14403 +{
14404 + return (*(volatile const long *)&(v)->counter);
14405 }
14406
14407 /**
14408 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14409 }
14410
14411 /**
14412 + * atomic64_set_unchecked - set atomic64 variable
14413 + * @v: pointer to type atomic64_unchecked_t
14414 + * @i: required value
14415 + *
14416 + * Atomically sets the value of @v to @i.
14417 + */
14418 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14419 +{
14420 + v->counter = i;
14421 +}
14422 +
14423 +/**
14424 * atomic64_add - add integer to atomic64 variable
14425 * @i: integer value to add
14426 * @v: pointer to type atomic64_t
14427 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14428 */
14429 static inline void atomic64_add(long i, atomic64_t *v)
14430 {
14431 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14432 +
14433 +#ifdef CONFIG_PAX_REFCOUNT
14434 + "jno 0f\n"
14435 + LOCK_PREFIX "subq %1,%0\n"
14436 + "int $4\n0:\n"
14437 + _ASM_EXTABLE(0b, 0b)
14438 +#endif
14439 +
14440 + : "=m" (v->counter)
14441 + : "er" (i), "m" (v->counter));
14442 +}
14443 +
14444 +/**
14445 + * atomic64_add_unchecked - add integer to atomic64 variable
14446 + * @i: integer value to add
14447 + * @v: pointer to type atomic64_unchecked_t
14448 + *
14449 + * Atomically adds @i to @v.
14450 + */
14451 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14452 +{
14453 asm volatile(LOCK_PREFIX "addq %1,%0"
14454 : "=m" (v->counter)
14455 : "er" (i), "m" (v->counter));
14456 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14457 */
14458 static inline void atomic64_sub(long i, atomic64_t *v)
14459 {
14460 - asm volatile(LOCK_PREFIX "subq %1,%0"
14461 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14462 +
14463 +#ifdef CONFIG_PAX_REFCOUNT
14464 + "jno 0f\n"
14465 + LOCK_PREFIX "addq %1,%0\n"
14466 + "int $4\n0:\n"
14467 + _ASM_EXTABLE(0b, 0b)
14468 +#endif
14469 +
14470 + : "=m" (v->counter)
14471 + : "er" (i), "m" (v->counter));
14472 +}
14473 +
14474 +/**
14475 + * atomic64_sub_unchecked - subtract the atomic64 variable
14476 + * @i: integer value to subtract
14477 + * @v: pointer to type atomic64_unchecked_t
14478 + *
14479 + * Atomically subtracts @i from @v.
14480 + */
14481 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14482 +{
14483 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14484 : "=m" (v->counter)
14485 : "er" (i), "m" (v->counter));
14486 }
14487 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14488 {
14489 unsigned char c;
14490
14491 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14492 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14493 +
14494 +#ifdef CONFIG_PAX_REFCOUNT
14495 + "jno 0f\n"
14496 + LOCK_PREFIX "addq %2,%0\n"
14497 + "int $4\n0:\n"
14498 + _ASM_EXTABLE(0b, 0b)
14499 +#endif
14500 +
14501 + "sete %1\n"
14502 : "=m" (v->counter), "=qm" (c)
14503 : "er" (i), "m" (v->counter) : "memory");
14504 return c;
14505 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14506 */
14507 static inline void atomic64_inc(atomic64_t *v)
14508 {
14509 + asm volatile(LOCK_PREFIX "incq %0\n"
14510 +
14511 +#ifdef CONFIG_PAX_REFCOUNT
14512 + "jno 0f\n"
14513 + LOCK_PREFIX "decq %0\n"
14514 + "int $4\n0:\n"
14515 + _ASM_EXTABLE(0b, 0b)
14516 +#endif
14517 +
14518 + : "=m" (v->counter)
14519 + : "m" (v->counter));
14520 +}
14521 +
14522 +/**
14523 + * atomic64_inc_unchecked - increment atomic64 variable
14524 + * @v: pointer to type atomic64_unchecked_t
14525 + *
14526 + * Atomically increments @v by 1.
14527 + */
14528 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14529 +{
14530 asm volatile(LOCK_PREFIX "incq %0"
14531 : "=m" (v->counter)
14532 : "m" (v->counter));
14533 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14534 */
14535 static inline void atomic64_dec(atomic64_t *v)
14536 {
14537 - asm volatile(LOCK_PREFIX "decq %0"
14538 + asm volatile(LOCK_PREFIX "decq %0\n"
14539 +
14540 +#ifdef CONFIG_PAX_REFCOUNT
14541 + "jno 0f\n"
14542 + LOCK_PREFIX "incq %0\n"
14543 + "int $4\n0:\n"
14544 + _ASM_EXTABLE(0b, 0b)
14545 +#endif
14546 +
14547 + : "=m" (v->counter)
14548 + : "m" (v->counter));
14549 +}
14550 +
14551 +/**
14552 + * atomic64_dec_unchecked - decrement atomic64 variable
14553 + * @v: pointer to type atomic64_t
14554 + *
14555 + * Atomically decrements @v by 1.
14556 + */
14557 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14558 +{
14559 + asm volatile(LOCK_PREFIX "decq %0\n"
14560 : "=m" (v->counter)
14561 : "m" (v->counter));
14562 }
14563 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14564 {
14565 unsigned char c;
14566
14567 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14568 + asm volatile(LOCK_PREFIX "decq %0\n"
14569 +
14570 +#ifdef CONFIG_PAX_REFCOUNT
14571 + "jno 0f\n"
14572 + LOCK_PREFIX "incq %0\n"
14573 + "int $4\n0:\n"
14574 + _ASM_EXTABLE(0b, 0b)
14575 +#endif
14576 +
14577 + "sete %1\n"
14578 : "=m" (v->counter), "=qm" (c)
14579 : "m" (v->counter) : "memory");
14580 return c != 0;
14581 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14582 {
14583 unsigned char c;
14584
14585 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14586 + asm volatile(LOCK_PREFIX "incq %0\n"
14587 +
14588 +#ifdef CONFIG_PAX_REFCOUNT
14589 + "jno 0f\n"
14590 + LOCK_PREFIX "decq %0\n"
14591 + "int $4\n0:\n"
14592 + _ASM_EXTABLE(0b, 0b)
14593 +#endif
14594 +
14595 + "sete %1\n"
14596 : "=m" (v->counter), "=qm" (c)
14597 : "m" (v->counter) : "memory");
14598 return c != 0;
14599 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14600 {
14601 unsigned char c;
14602
14603 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14604 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14605 +
14606 +#ifdef CONFIG_PAX_REFCOUNT
14607 + "jno 0f\n"
14608 + LOCK_PREFIX "subq %2,%0\n"
14609 + "int $4\n0:\n"
14610 + _ASM_EXTABLE(0b, 0b)
14611 +#endif
14612 +
14613 + "sets %1\n"
14614 : "=m" (v->counter), "=qm" (c)
14615 : "er" (i), "m" (v->counter) : "memory");
14616 return c;
14617 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14618 */
14619 static inline long atomic64_add_return(long i, atomic64_t *v)
14620 {
14621 + return i + xadd_check_overflow(&v->counter, i);
14622 +}
14623 +
14624 +/**
14625 + * atomic64_add_return_unchecked - add and return
14626 + * @i: integer value to add
14627 + * @v: pointer to type atomic64_unchecked_t
14628 + *
14629 + * Atomically adds @i to @v and returns @i + @v
14630 + */
14631 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14632 +{
14633 return i + xadd(&v->counter, i);
14634 }
14635
14636 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14637 }
14638
14639 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14640 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14641 +{
14642 + return atomic64_add_return_unchecked(1, v);
14643 +}
14644 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14645
14646 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14647 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14648 return cmpxchg(&v->counter, old, new);
14649 }
14650
14651 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14652 +{
14653 + return cmpxchg(&v->counter, old, new);
14654 +}
14655 +
14656 static inline long atomic64_xchg(atomic64_t *v, long new)
14657 {
14658 return xchg(&v->counter, new);
14659 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14660 */
14661 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14662 {
14663 - long c, old;
14664 + long c, old, new;
14665 c = atomic64_read(v);
14666 for (;;) {
14667 - if (unlikely(c == (u)))
14668 + if (unlikely(c == u))
14669 break;
14670 - old = atomic64_cmpxchg((v), c, c + (a));
14671 +
14672 + asm volatile("add %2,%0\n"
14673 +
14674 +#ifdef CONFIG_PAX_REFCOUNT
14675 + "jno 0f\n"
14676 + "sub %2,%0\n"
14677 + "int $4\n0:\n"
14678 + _ASM_EXTABLE(0b, 0b)
14679 +#endif
14680 +
14681 + : "=r" (new)
14682 + : "0" (c), "ir" (a));
14683 +
14684 + old = atomic64_cmpxchg(v, c, new);
14685 if (likely(old == c))
14686 break;
14687 c = old;
14688 }
14689 - return c != (u);
14690 + return c != u;
14691 }
14692
14693 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14694 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14695 index 6dfd019..28e188d 100644
14696 --- a/arch/x86/include/asm/bitops.h
14697 +++ b/arch/x86/include/asm/bitops.h
14698 @@ -40,7 +40,7 @@
14699 * a mask operation on a byte.
14700 */
14701 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14702 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14703 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14704 #define CONST_MASK(nr) (1 << ((nr) & 7))
14705
14706 /**
14707 @@ -486,7 +486,7 @@ static inline int fls(int x)
14708 * at position 64.
14709 */
14710 #ifdef CONFIG_X86_64
14711 -static __always_inline int fls64(__u64 x)
14712 +static __always_inline long fls64(__u64 x)
14713 {
14714 int bitpos = -1;
14715 /*
14716 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14717 index 4fa687a..60f2d39 100644
14718 --- a/arch/x86/include/asm/boot.h
14719 +++ b/arch/x86/include/asm/boot.h
14720 @@ -6,10 +6,15 @@
14721 #include <uapi/asm/boot.h>
14722
14723 /* Physical address where kernel should be loaded. */
14724 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14725 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14726 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14727 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14728
14729 +#ifndef __ASSEMBLY__
14730 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14731 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14732 +#endif
14733 +
14734 /* Minimum kernel alignment, as a power of two */
14735 #ifdef CONFIG_X86_64
14736 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14737 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14738 index 48f99f1..d78ebf9 100644
14739 --- a/arch/x86/include/asm/cache.h
14740 +++ b/arch/x86/include/asm/cache.h
14741 @@ -5,12 +5,13 @@
14742
14743 /* L1 cache line size */
14744 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14745 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14747
14748 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14749 +#define __read_only __attribute__((__section__(".data..read_only")))
14750
14751 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14752 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14753 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14754
14755 #ifdef CONFIG_X86_VSMP
14756 #ifdef CONFIG_SMP
14757 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14758 index 9863ee3..4a1f8e1 100644
14759 --- a/arch/x86/include/asm/cacheflush.h
14760 +++ b/arch/x86/include/asm/cacheflush.h
14761 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14762 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14763
14764 if (pg_flags == _PGMT_DEFAULT)
14765 - return -1;
14766 + return ~0UL;
14767 else if (pg_flags == _PGMT_WC)
14768 return _PAGE_CACHE_WC;
14769 else if (pg_flags == _PGMT_UC_MINUS)
14770 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14771 index f50de69..2b0a458 100644
14772 --- a/arch/x86/include/asm/checksum_32.h
14773 +++ b/arch/x86/include/asm/checksum_32.h
14774 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14775 int len, __wsum sum,
14776 int *src_err_ptr, int *dst_err_ptr);
14777
14778 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14779 + int len, __wsum sum,
14780 + int *src_err_ptr, int *dst_err_ptr);
14781 +
14782 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14783 + int len, __wsum sum,
14784 + int *src_err_ptr, int *dst_err_ptr);
14785 +
14786 /*
14787 * Note: when you get a NULL pointer exception here this means someone
14788 * passed in an incorrect kernel address to one of these functions.
14789 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14790
14791 might_sleep();
14792 stac();
14793 - ret = csum_partial_copy_generic((__force void *)src, dst,
14794 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14795 len, sum, err_ptr, NULL);
14796 clac();
14797
14798 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14799 might_sleep();
14800 if (access_ok(VERIFY_WRITE, dst, len)) {
14801 stac();
14802 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14803 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14804 len, sum, NULL, err_ptr);
14805 clac();
14806 return ret;
14807 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14808 index d47786a..ce1b05d 100644
14809 --- a/arch/x86/include/asm/cmpxchg.h
14810 +++ b/arch/x86/include/asm/cmpxchg.h
14811 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14812 __compiletime_error("Bad argument size for cmpxchg");
14813 extern void __xadd_wrong_size(void)
14814 __compiletime_error("Bad argument size for xadd");
14815 +extern void __xadd_check_overflow_wrong_size(void)
14816 + __compiletime_error("Bad argument size for xadd_check_overflow");
14817 extern void __add_wrong_size(void)
14818 __compiletime_error("Bad argument size for add");
14819 +extern void __add_check_overflow_wrong_size(void)
14820 + __compiletime_error("Bad argument size for add_check_overflow");
14821
14822 /*
14823 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14824 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14825 __ret; \
14826 })
14827
14828 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14829 + ({ \
14830 + __typeof__ (*(ptr)) __ret = (arg); \
14831 + switch (sizeof(*(ptr))) { \
14832 + case __X86_CASE_L: \
14833 + asm volatile (lock #op "l %0, %1\n" \
14834 + "jno 0f\n" \
14835 + "mov %0,%1\n" \
14836 + "int $4\n0:\n" \
14837 + _ASM_EXTABLE(0b, 0b) \
14838 + : "+r" (__ret), "+m" (*(ptr)) \
14839 + : : "memory", "cc"); \
14840 + break; \
14841 + case __X86_CASE_Q: \
14842 + asm volatile (lock #op "q %q0, %1\n" \
14843 + "jno 0f\n" \
14844 + "mov %0,%1\n" \
14845 + "int $4\n0:\n" \
14846 + _ASM_EXTABLE(0b, 0b) \
14847 + : "+r" (__ret), "+m" (*(ptr)) \
14848 + : : "memory", "cc"); \
14849 + break; \
14850 + default: \
14851 + __ ## op ## _check_overflow_wrong_size(); \
14852 + } \
14853 + __ret; \
14854 + })
14855 +
14856 /*
14857 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14858 * Since this is generally used to protect other memory information, we
14859 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14860 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14861 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14862
14863 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14864 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14865 +
14866 #define __add(ptr, inc, lock) \
14867 ({ \
14868 __typeof__ (*(ptr)) __ret = (inc); \
14869 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14870 index 59c6c40..5e0b22c 100644
14871 --- a/arch/x86/include/asm/compat.h
14872 +++ b/arch/x86/include/asm/compat.h
14873 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14874 typedef u32 compat_uint_t;
14875 typedef u32 compat_ulong_t;
14876 typedef u64 __attribute__((aligned(4))) compat_u64;
14877 -typedef u32 compat_uptr_t;
14878 +typedef u32 __user compat_uptr_t;
14879
14880 struct compat_timespec {
14881 compat_time_t tv_sec;
14882 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14883 index 7290585..717e89e 100644
14884 --- a/arch/x86/include/asm/cpufeature.h
14885 +++ b/arch/x86/include/asm/cpufeature.h
14886 @@ -203,7 +203,7 @@
14887 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14888 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14889 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14890 -
14891 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14892
14893 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14894 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14895 @@ -211,7 +211,7 @@
14896 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14897 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14898 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14899 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14900 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14901 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14902 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14903 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14904 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14905 #undef cpu_has_centaur_mcr
14906 #define cpu_has_centaur_mcr 0
14907
14908 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14909 #endif /* CONFIG_X86_64 */
14910
14911 #if __GNUC__ >= 4
14912 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14913
14914 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14915 t_warn:
14916 - warn_pre_alternatives();
14917 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14918 + warn_pre_alternatives();
14919 return false;
14920 #endif
14921 #else /* GCC_VERSION >= 40500 */
14922 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14923 ".section .discard,\"aw\",@progbits\n"
14924 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14925 ".previous\n"
14926 - ".section .altinstr_replacement,\"ax\"\n"
14927 + ".section .altinstr_replacement,\"a\"\n"
14928 "3: movb $1,%0\n"
14929 "4:\n"
14930 ".previous\n"
14931 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14932 " .byte 2b - 1b\n" /* src len */
14933 " .byte 4f - 3f\n" /* repl len */
14934 ".previous\n"
14935 - ".section .altinstr_replacement,\"ax\"\n"
14936 + ".section .altinstr_replacement,\"a\"\n"
14937 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14938 "4:\n"
14939 ".previous\n"
14940 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14941 ".section .discard,\"aw\",@progbits\n"
14942 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14943 ".previous\n"
14944 - ".section .altinstr_replacement,\"ax\"\n"
14945 + ".section .altinstr_replacement,\"a\"\n"
14946 "3: movb $0,%0\n"
14947 "4:\n"
14948 ".previous\n"
14949 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14950 ".section .discard,\"aw\",@progbits\n"
14951 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14952 ".previous\n"
14953 - ".section .altinstr_replacement,\"ax\"\n"
14954 + ".section .altinstr_replacement,\"a\"\n"
14955 "5: movb $1,%0\n"
14956 "6:\n"
14957 ".previous\n"
14958 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14959 index b90e5df..b462c91 100644
14960 --- a/arch/x86/include/asm/desc.h
14961 +++ b/arch/x86/include/asm/desc.h
14962 @@ -4,6 +4,7 @@
14963 #include <asm/desc_defs.h>
14964 #include <asm/ldt.h>
14965 #include <asm/mmu.h>
14966 +#include <asm/pgtable.h>
14967
14968 #include <linux/smp.h>
14969 #include <linux/percpu.h>
14970 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14971
14972 desc->type = (info->read_exec_only ^ 1) << 1;
14973 desc->type |= info->contents << 2;
14974 + desc->type |= info->seg_not_present ^ 1;
14975
14976 desc->s = 1;
14977 desc->dpl = 0x3;
14978 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14979 }
14980
14981 extern struct desc_ptr idt_descr;
14982 -extern gate_desc idt_table[];
14983 -extern struct desc_ptr debug_idt_descr;
14984 -extern gate_desc debug_idt_table[];
14985 -
14986 -struct gdt_page {
14987 - struct desc_struct gdt[GDT_ENTRIES];
14988 -} __attribute__((aligned(PAGE_SIZE)));
14989 -
14990 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14991 +extern gate_desc idt_table[IDT_ENTRIES];
14992 +extern const struct desc_ptr debug_idt_descr;
14993 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14994
14995 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14996 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14997 {
14998 - return per_cpu(gdt_page, cpu).gdt;
14999 + return cpu_gdt_table[cpu];
15000 }
15001
15002 #ifdef CONFIG_X86_64
15003 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15004 unsigned long base, unsigned dpl, unsigned flags,
15005 unsigned short seg)
15006 {
15007 - gate->a = (seg << 16) | (base & 0xffff);
15008 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15009 + gate->gate.offset_low = base;
15010 + gate->gate.seg = seg;
15011 + gate->gate.reserved = 0;
15012 + gate->gate.type = type;
15013 + gate->gate.s = 0;
15014 + gate->gate.dpl = dpl;
15015 + gate->gate.p = 1;
15016 + gate->gate.offset_high = base >> 16;
15017 }
15018
15019 #endif
15020 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15021
15022 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15023 {
15024 + pax_open_kernel();
15025 memcpy(&idt[entry], gate, sizeof(*gate));
15026 + pax_close_kernel();
15027 }
15028
15029 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15030 {
15031 + pax_open_kernel();
15032 memcpy(&ldt[entry], desc, 8);
15033 + pax_close_kernel();
15034 }
15035
15036 static inline void
15037 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15038 default: size = sizeof(*gdt); break;
15039 }
15040
15041 + pax_open_kernel();
15042 memcpy(&gdt[entry], desc, size);
15043 + pax_close_kernel();
15044 }
15045
15046 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15047 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15048
15049 static inline void native_load_tr_desc(void)
15050 {
15051 + pax_open_kernel();
15052 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15053 + pax_close_kernel();
15054 }
15055
15056 static inline void native_load_gdt(const struct desc_ptr *dtr)
15057 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15058 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15059 unsigned int i;
15060
15061 + pax_open_kernel();
15062 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15063 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15064 + pax_close_kernel();
15065 }
15066
15067 #define _LDT_empty(info) \
15068 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15069 preempt_enable();
15070 }
15071
15072 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15073 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15074 {
15075 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15076 }
15077 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15078 }
15079
15080 #ifdef CONFIG_X86_64
15081 -static inline void set_nmi_gate(int gate, void *addr)
15082 +static inline void set_nmi_gate(int gate, const void *addr)
15083 {
15084 gate_desc s;
15085
15086 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15087 #endif
15088
15089 #ifdef CONFIG_TRACING
15090 -extern struct desc_ptr trace_idt_descr;
15091 -extern gate_desc trace_idt_table[];
15092 +extern const struct desc_ptr trace_idt_descr;
15093 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15094 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15095 {
15096 write_idt_entry(trace_idt_table, entry, gate);
15097 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15098 }
15099 #endif
15100
15101 -static inline void _set_gate(int gate, unsigned type, void *addr,
15102 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15103 unsigned dpl, unsigned ist, unsigned seg)
15104 {
15105 gate_desc s;
15106 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15107 * Pentium F0 0F bugfix can have resulted in the mapped
15108 * IDT being write-protected.
15109 */
15110 -static inline void set_intr_gate(unsigned int n, void *addr)
15111 +static inline void set_intr_gate(unsigned int n, const void *addr)
15112 {
15113 BUG_ON((unsigned)n > 0xFF);
15114 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15115 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15116 /*
15117 * This routine sets up an interrupt gate at directory privilege level 3.
15118 */
15119 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15120 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15121 {
15122 BUG_ON((unsigned)n > 0xFF);
15123 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15124 }
15125
15126 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15127 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15128 {
15129 BUG_ON((unsigned)n > 0xFF);
15130 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15131 }
15132
15133 -static inline void set_trap_gate(unsigned int n, void *addr)
15134 +static inline void set_trap_gate(unsigned int n, const void *addr)
15135 {
15136 BUG_ON((unsigned)n > 0xFF);
15137 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15138 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15139 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15140 {
15141 BUG_ON((unsigned)n > 0xFF);
15142 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15143 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15144 }
15145
15146 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15147 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15148 {
15149 BUG_ON((unsigned)n > 0xFF);
15150 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15151 }
15152
15153 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15154 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15155 {
15156 BUG_ON((unsigned)n > 0xFF);
15157 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15158 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15159 else
15160 load_idt((const struct desc_ptr *)&idt_descr);
15161 }
15162 +
15163 +#ifdef CONFIG_X86_32
15164 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15165 +{
15166 + struct desc_struct d;
15167 +
15168 + if (likely(limit))
15169 + limit = (limit - 1UL) >> PAGE_SHIFT;
15170 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15171 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15172 +}
15173 +#endif
15174 +
15175 #endif /* _ASM_X86_DESC_H */
15176 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15177 index 278441f..b95a174 100644
15178 --- a/arch/x86/include/asm/desc_defs.h
15179 +++ b/arch/x86/include/asm/desc_defs.h
15180 @@ -31,6 +31,12 @@ struct desc_struct {
15181 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15182 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15183 };
15184 + struct {
15185 + u16 offset_low;
15186 + u16 seg;
15187 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15188 + unsigned offset_high: 16;
15189 + } gate;
15190 };
15191 } __attribute__((packed));
15192
15193 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15194 index ced283a..ffe04cc 100644
15195 --- a/arch/x86/include/asm/div64.h
15196 +++ b/arch/x86/include/asm/div64.h
15197 @@ -39,7 +39,7 @@
15198 __mod; \
15199 })
15200
15201 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15202 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15203 {
15204 union {
15205 u64 v64;
15206 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15207 index 9c999c1..3860cb8 100644
15208 --- a/arch/x86/include/asm/elf.h
15209 +++ b/arch/x86/include/asm/elf.h
15210 @@ -243,7 +243,25 @@ extern int force_personality32;
15211 the loader. We need to make sure that it is out of the way of the program
15212 that it will "exec", and that there is sufficient room for the brk. */
15213
15214 +#ifdef CONFIG_PAX_SEGMEXEC
15215 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15216 +#else
15217 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15218 +#endif
15219 +
15220 +#ifdef CONFIG_PAX_ASLR
15221 +#ifdef CONFIG_X86_32
15222 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15223 +
15224 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15225 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15226 +#else
15227 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15228 +
15229 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15230 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15231 +#endif
15232 +#endif
15233
15234 /* This yields a mask that user programs can use to figure out what
15235 instruction set this CPU supports. This could be done in user space,
15236 @@ -296,16 +314,12 @@ do { \
15237
15238 #define ARCH_DLINFO \
15239 do { \
15240 - if (vdso_enabled) \
15241 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15242 - (unsigned long)current->mm->context.vdso); \
15243 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15244 } while (0)
15245
15246 #define ARCH_DLINFO_X32 \
15247 do { \
15248 - if (vdso_enabled) \
15249 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15250 - (unsigned long)current->mm->context.vdso); \
15251 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15252 } while (0)
15253
15254 #define AT_SYSINFO 32
15255 @@ -320,7 +334,7 @@ else \
15256
15257 #endif /* !CONFIG_X86_32 */
15258
15259 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15260 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15261
15262 #define VDSO_ENTRY \
15263 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15264 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15265 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15266 #define compat_arch_setup_additional_pages syscall32_setup_pages
15267
15268 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15269 -#define arch_randomize_brk arch_randomize_brk
15270 -
15271 /*
15272 * True on X86_32 or when emulating IA32 on X86_64
15273 */
15274 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15275 index 77a99ac..39ff7f5 100644
15276 --- a/arch/x86/include/asm/emergency-restart.h
15277 +++ b/arch/x86/include/asm/emergency-restart.h
15278 @@ -1,6 +1,6 @@
15279 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15280 #define _ASM_X86_EMERGENCY_RESTART_H
15281
15282 -extern void machine_emergency_restart(void);
15283 +extern void machine_emergency_restart(void) __noreturn;
15284
15285 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15286 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15287 index 4d0bda7..221da4d 100644
15288 --- a/arch/x86/include/asm/fpu-internal.h
15289 +++ b/arch/x86/include/asm/fpu-internal.h
15290 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15291 #define user_insn(insn, output, input...) \
15292 ({ \
15293 int err; \
15294 + pax_open_userland(); \
15295 asm volatile(ASM_STAC "\n" \
15296 - "1:" #insn "\n\t" \
15297 + "1:" \
15298 + __copyuser_seg \
15299 + #insn "\n\t" \
15300 "2: " ASM_CLAC "\n" \
15301 ".section .fixup,\"ax\"\n" \
15302 "3: movl $-1,%[err]\n" \
15303 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15304 _ASM_EXTABLE(1b, 3b) \
15305 : [err] "=r" (err), output \
15306 : "0"(0), input); \
15307 + pax_close_userland(); \
15308 err; \
15309 })
15310
15311 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15312 "emms\n\t" /* clear stack tags */
15313 "fildl %P[addr]", /* set F?P to defined value */
15314 X86_FEATURE_FXSAVE_LEAK,
15315 - [addr] "m" (tsk->thread.fpu.has_fpu));
15316 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15317
15318 return fpu_restore_checking(&tsk->thread.fpu);
15319 }
15320 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15321 index be27ba1..04a8801 100644
15322 --- a/arch/x86/include/asm/futex.h
15323 +++ b/arch/x86/include/asm/futex.h
15324 @@ -12,6 +12,7 @@
15325 #include <asm/smap.h>
15326
15327 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15328 + typecheck(u32 __user *, uaddr); \
15329 asm volatile("\t" ASM_STAC "\n" \
15330 "1:\t" insn "\n" \
15331 "2:\t" ASM_CLAC "\n" \
15332 @@ -20,15 +21,16 @@
15333 "\tjmp\t2b\n" \
15334 "\t.previous\n" \
15335 _ASM_EXTABLE(1b, 3b) \
15336 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15337 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15338 : "i" (-EFAULT), "0" (oparg), "1" (0))
15339
15340 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15341 + typecheck(u32 __user *, uaddr); \
15342 asm volatile("\t" ASM_STAC "\n" \
15343 "1:\tmovl %2, %0\n" \
15344 "\tmovl\t%0, %3\n" \
15345 "\t" insn "\n" \
15346 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15347 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15348 "\tjnz\t1b\n" \
15349 "3:\t" ASM_CLAC "\n" \
15350 "\t.section .fixup,\"ax\"\n" \
15351 @@ -38,7 +40,7 @@
15352 _ASM_EXTABLE(1b, 4b) \
15353 _ASM_EXTABLE(2b, 4b) \
15354 : "=&a" (oldval), "=&r" (ret), \
15355 - "+m" (*uaddr), "=&r" (tem) \
15356 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15357 : "r" (oparg), "i" (-EFAULT), "1" (0))
15358
15359 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15360 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15361
15362 pagefault_disable();
15363
15364 + pax_open_userland();
15365 switch (op) {
15366 case FUTEX_OP_SET:
15367 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15368 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15369 break;
15370 case FUTEX_OP_ADD:
15371 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15372 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15373 uaddr, oparg);
15374 break;
15375 case FUTEX_OP_OR:
15376 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15377 default:
15378 ret = -ENOSYS;
15379 }
15380 + pax_close_userland();
15381
15382 pagefault_enable();
15383
15384 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15385 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15386 return -EFAULT;
15387
15388 + pax_open_userland();
15389 asm volatile("\t" ASM_STAC "\n"
15390 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15391 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15392 "2:\t" ASM_CLAC "\n"
15393 "\t.section .fixup, \"ax\"\n"
15394 "3:\tmov %3, %0\n"
15395 "\tjmp 2b\n"
15396 "\t.previous\n"
15397 _ASM_EXTABLE(1b, 3b)
15398 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15399 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15400 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15401 : "memory"
15402 );
15403 + pax_close_userland();
15404
15405 *uval = oldval;
15406 return ret;
15407 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15408 index e4ac559..c1c0c87 100644
15409 --- a/arch/x86/include/asm/hw_irq.h
15410 +++ b/arch/x86/include/asm/hw_irq.h
15411 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15412 extern void enable_IO_APIC(void);
15413
15414 /* Statistics */
15415 -extern atomic_t irq_err_count;
15416 -extern atomic_t irq_mis_count;
15417 +extern atomic_unchecked_t irq_err_count;
15418 +extern atomic_unchecked_t irq_mis_count;
15419
15420 /* EISA */
15421 extern void eisa_set_level_irq(unsigned int irq);
15422 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15423 index a203659..9889f1c 100644
15424 --- a/arch/x86/include/asm/i8259.h
15425 +++ b/arch/x86/include/asm/i8259.h
15426 @@ -62,7 +62,7 @@ struct legacy_pic {
15427 void (*init)(int auto_eoi);
15428 int (*irq_pending)(unsigned int irq);
15429 void (*make_irq)(unsigned int irq);
15430 -};
15431 +} __do_const;
15432
15433 extern struct legacy_pic *legacy_pic;
15434 extern struct legacy_pic null_legacy_pic;
15435 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15436 index 34f69cb..6d95446 100644
15437 --- a/arch/x86/include/asm/io.h
15438 +++ b/arch/x86/include/asm/io.h
15439 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15440 "m" (*(volatile type __force *)addr) barrier); }
15441
15442 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15443 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15444 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15445 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15446 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15447
15448 build_mmio_read(__readb, "b", unsigned char, "=q", )
15449 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15450 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15451 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15452 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15453
15454 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15455 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15456 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15457 return ioremap_nocache(offset, size);
15458 }
15459
15460 -extern void iounmap(volatile void __iomem *addr);
15461 +extern void iounmap(const volatile void __iomem *addr);
15462
15463 extern void set_iounmap_nonlazy(void);
15464
15465 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15466
15467 #include <linux/vmalloc.h>
15468
15469 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15470 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15471 +{
15472 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15473 +}
15474 +
15475 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15476 +{
15477 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15478 +}
15479 +
15480 /*
15481 * Convert a virtual cached pointer to an uncached pointer
15482 */
15483 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15484 index bba3cf8..06bc8da 100644
15485 --- a/arch/x86/include/asm/irqflags.h
15486 +++ b/arch/x86/include/asm/irqflags.h
15487 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15488 sti; \
15489 sysexit
15490
15491 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15492 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15493 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15494 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15495 +
15496 #else
15497 #define INTERRUPT_RETURN iret
15498 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15499 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15500 index 5a6d287..f815789 100644
15501 --- a/arch/x86/include/asm/kprobes.h
15502 +++ b/arch/x86/include/asm/kprobes.h
15503 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15504 #define RELATIVEJUMP_SIZE 5
15505 #define RELATIVECALL_OPCODE 0xe8
15506 #define RELATIVE_ADDR_SIZE 4
15507 -#define MAX_STACK_SIZE 64
15508 -#define MIN_STACK_SIZE(ADDR) \
15509 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15510 - THREAD_SIZE - (unsigned long)(ADDR))) \
15511 - ? (MAX_STACK_SIZE) \
15512 - : (((unsigned long)current_thread_info()) + \
15513 - THREAD_SIZE - (unsigned long)(ADDR)))
15514 +#define MAX_STACK_SIZE 64UL
15515 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15516
15517 #define flush_insn_slot(p) do { } while (0)
15518
15519 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15520 index 2d89e39..baee879 100644
15521 --- a/arch/x86/include/asm/local.h
15522 +++ b/arch/x86/include/asm/local.h
15523 @@ -10,33 +10,97 @@ typedef struct {
15524 atomic_long_t a;
15525 } local_t;
15526
15527 +typedef struct {
15528 + atomic_long_unchecked_t a;
15529 +} local_unchecked_t;
15530 +
15531 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15532
15533 #define local_read(l) atomic_long_read(&(l)->a)
15534 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15535 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15536 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15537
15538 static inline void local_inc(local_t *l)
15539 {
15540 - asm volatile(_ASM_INC "%0"
15541 + asm volatile(_ASM_INC "%0\n"
15542 +
15543 +#ifdef CONFIG_PAX_REFCOUNT
15544 + "jno 0f\n"
15545 + _ASM_DEC "%0\n"
15546 + "int $4\n0:\n"
15547 + _ASM_EXTABLE(0b, 0b)
15548 +#endif
15549 +
15550 + : "+m" (l->a.counter));
15551 +}
15552 +
15553 +static inline void local_inc_unchecked(local_unchecked_t *l)
15554 +{
15555 + asm volatile(_ASM_INC "%0\n"
15556 : "+m" (l->a.counter));
15557 }
15558
15559 static inline void local_dec(local_t *l)
15560 {
15561 - asm volatile(_ASM_DEC "%0"
15562 + asm volatile(_ASM_DEC "%0\n"
15563 +
15564 +#ifdef CONFIG_PAX_REFCOUNT
15565 + "jno 0f\n"
15566 + _ASM_INC "%0\n"
15567 + "int $4\n0:\n"
15568 + _ASM_EXTABLE(0b, 0b)
15569 +#endif
15570 +
15571 + : "+m" (l->a.counter));
15572 +}
15573 +
15574 +static inline void local_dec_unchecked(local_unchecked_t *l)
15575 +{
15576 + asm volatile(_ASM_DEC "%0\n"
15577 : "+m" (l->a.counter));
15578 }
15579
15580 static inline void local_add(long i, local_t *l)
15581 {
15582 - asm volatile(_ASM_ADD "%1,%0"
15583 + asm volatile(_ASM_ADD "%1,%0\n"
15584 +
15585 +#ifdef CONFIG_PAX_REFCOUNT
15586 + "jno 0f\n"
15587 + _ASM_SUB "%1,%0\n"
15588 + "int $4\n0:\n"
15589 + _ASM_EXTABLE(0b, 0b)
15590 +#endif
15591 +
15592 + : "+m" (l->a.counter)
15593 + : "ir" (i));
15594 +}
15595 +
15596 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15597 +{
15598 + asm volatile(_ASM_ADD "%1,%0\n"
15599 : "+m" (l->a.counter)
15600 : "ir" (i));
15601 }
15602
15603 static inline void local_sub(long i, local_t *l)
15604 {
15605 - asm volatile(_ASM_SUB "%1,%0"
15606 + asm volatile(_ASM_SUB "%1,%0\n"
15607 +
15608 +#ifdef CONFIG_PAX_REFCOUNT
15609 + "jno 0f\n"
15610 + _ASM_ADD "%1,%0\n"
15611 + "int $4\n0:\n"
15612 + _ASM_EXTABLE(0b, 0b)
15613 +#endif
15614 +
15615 + : "+m" (l->a.counter)
15616 + : "ir" (i));
15617 +}
15618 +
15619 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15620 +{
15621 + asm volatile(_ASM_SUB "%1,%0\n"
15622 : "+m" (l->a.counter)
15623 : "ir" (i));
15624 }
15625 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15626 {
15627 unsigned char c;
15628
15629 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15630 + asm volatile(_ASM_SUB "%2,%0\n"
15631 +
15632 +#ifdef CONFIG_PAX_REFCOUNT
15633 + "jno 0f\n"
15634 + _ASM_ADD "%2,%0\n"
15635 + "int $4\n0:\n"
15636 + _ASM_EXTABLE(0b, 0b)
15637 +#endif
15638 +
15639 + "sete %1\n"
15640 : "+m" (l->a.counter), "=qm" (c)
15641 : "ir" (i) : "memory");
15642 return c;
15643 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15644 {
15645 unsigned char c;
15646
15647 - asm volatile(_ASM_DEC "%0; sete %1"
15648 + asm volatile(_ASM_DEC "%0\n"
15649 +
15650 +#ifdef CONFIG_PAX_REFCOUNT
15651 + "jno 0f\n"
15652 + _ASM_INC "%0\n"
15653 + "int $4\n0:\n"
15654 + _ASM_EXTABLE(0b, 0b)
15655 +#endif
15656 +
15657 + "sete %1\n"
15658 : "+m" (l->a.counter), "=qm" (c)
15659 : : "memory");
15660 return c != 0;
15661 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15662 {
15663 unsigned char c;
15664
15665 - asm volatile(_ASM_INC "%0; sete %1"
15666 + asm volatile(_ASM_INC "%0\n"
15667 +
15668 +#ifdef CONFIG_PAX_REFCOUNT
15669 + "jno 0f\n"
15670 + _ASM_DEC "%0\n"
15671 + "int $4\n0:\n"
15672 + _ASM_EXTABLE(0b, 0b)
15673 +#endif
15674 +
15675 + "sete %1\n"
15676 : "+m" (l->a.counter), "=qm" (c)
15677 : : "memory");
15678 return c != 0;
15679 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15680 {
15681 unsigned char c;
15682
15683 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15684 + asm volatile(_ASM_ADD "%2,%0\n"
15685 +
15686 +#ifdef CONFIG_PAX_REFCOUNT
15687 + "jno 0f\n"
15688 + _ASM_SUB "%2,%0\n"
15689 + "int $4\n0:\n"
15690 + _ASM_EXTABLE(0b, 0b)
15691 +#endif
15692 +
15693 + "sets %1\n"
15694 : "+m" (l->a.counter), "=qm" (c)
15695 : "ir" (i) : "memory");
15696 return c;
15697 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15698 static inline long local_add_return(long i, local_t *l)
15699 {
15700 long __i = i;
15701 + asm volatile(_ASM_XADD "%0, %1\n"
15702 +
15703 +#ifdef CONFIG_PAX_REFCOUNT
15704 + "jno 0f\n"
15705 + _ASM_MOV "%0,%1\n"
15706 + "int $4\n0:\n"
15707 + _ASM_EXTABLE(0b, 0b)
15708 +#endif
15709 +
15710 + : "+r" (i), "+m" (l->a.counter)
15711 + : : "memory");
15712 + return i + __i;
15713 +}
15714 +
15715 +/**
15716 + * local_add_return_unchecked - add and return
15717 + * @i: integer value to add
15718 + * @l: pointer to type local_unchecked_t
15719 + *
15720 + * Atomically adds @i to @l and returns @i + @l
15721 + */
15722 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15723 +{
15724 + long __i = i;
15725 asm volatile(_ASM_XADD "%0, %1;"
15726 : "+r" (i), "+m" (l->a.counter)
15727 : : "memory");
15728 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15729
15730 #define local_cmpxchg(l, o, n) \
15731 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15732 +#define local_cmpxchg_unchecked(l, o, n) \
15733 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15734 /* Always has a lock prefix */
15735 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15736
15737 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15738 new file mode 100644
15739 index 0000000..2bfd3ba
15740 --- /dev/null
15741 +++ b/arch/x86/include/asm/mman.h
15742 @@ -0,0 +1,15 @@
15743 +#ifndef _X86_MMAN_H
15744 +#define _X86_MMAN_H
15745 +
15746 +#include <uapi/asm/mman.h>
15747 +
15748 +#ifdef __KERNEL__
15749 +#ifndef __ASSEMBLY__
15750 +#ifdef CONFIG_X86_32
15751 +#define arch_mmap_check i386_mmap_check
15752 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15753 +#endif
15754 +#endif
15755 +#endif
15756 +
15757 +#endif /* X86_MMAN_H */
15758 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15759 index 5f55e69..e20bfb1 100644
15760 --- a/arch/x86/include/asm/mmu.h
15761 +++ b/arch/x86/include/asm/mmu.h
15762 @@ -9,7 +9,7 @@
15763 * we put the segment information here.
15764 */
15765 typedef struct {
15766 - void *ldt;
15767 + struct desc_struct *ldt;
15768 int size;
15769
15770 #ifdef CONFIG_X86_64
15771 @@ -18,7 +18,19 @@ typedef struct {
15772 #endif
15773
15774 struct mutex lock;
15775 - void *vdso;
15776 + unsigned long vdso;
15777 +
15778 +#ifdef CONFIG_X86_32
15779 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15780 + unsigned long user_cs_base;
15781 + unsigned long user_cs_limit;
15782 +
15783 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15784 + cpumask_t cpu_user_cs_mask;
15785 +#endif
15786 +
15787 +#endif
15788 +#endif
15789 } mm_context_t;
15790
15791 #ifdef CONFIG_SMP
15792 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15793 index be12c53..2124e35 100644
15794 --- a/arch/x86/include/asm/mmu_context.h
15795 +++ b/arch/x86/include/asm/mmu_context.h
15796 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15797
15798 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15799 {
15800 +
15801 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15802 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15803 + unsigned int i;
15804 + pgd_t *pgd;
15805 +
15806 + pax_open_kernel();
15807 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15808 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15809 + set_pgd_batched(pgd+i, native_make_pgd(0));
15810 + pax_close_kernel();
15811 + }
15812 +#endif
15813 +
15814 #ifdef CONFIG_SMP
15815 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15816 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15817 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15818 struct task_struct *tsk)
15819 {
15820 unsigned cpu = smp_processor_id();
15821 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15822 + int tlbstate = TLBSTATE_OK;
15823 +#endif
15824
15825 if (likely(prev != next)) {
15826 #ifdef CONFIG_SMP
15827 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15828 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15829 +#endif
15830 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15831 this_cpu_write(cpu_tlbstate.active_mm, next);
15832 #endif
15833 cpumask_set_cpu(cpu, mm_cpumask(next));
15834
15835 /* Re-load page tables */
15836 +#ifdef CONFIG_PAX_PER_CPU_PGD
15837 + pax_open_kernel();
15838 +
15839 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15840 + if (static_cpu_has(X86_FEATURE_PCID))
15841 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15842 + else
15843 +#endif
15844 +
15845 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15846 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15847 + pax_close_kernel();
15848 + 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));
15849 +
15850 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15851 + if (static_cpu_has(X86_FEATURE_PCID)) {
15852 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15853 + u64 descriptor[2];
15854 + descriptor[0] = PCID_USER;
15855 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15856 + } else {
15857 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15858 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15859 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15860 + else
15861 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15862 + }
15863 + } else
15864 +#endif
15865 +
15866 + load_cr3(get_cpu_pgd(cpu, kernel));
15867 +#else
15868 load_cr3(next->pgd);
15869 +#endif
15870
15871 /* Stop flush ipis for the previous mm */
15872 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15873 @@ -51,9 +104,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15874 /* Load the LDT, if the LDT is different: */
15875 if (unlikely(prev->context.ldt != next->context.ldt))
15876 load_LDT_nolock(&next->context);
15877 +
15878 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15879 + if (!(__supported_pte_mask & _PAGE_NX)) {
15880 + smp_mb__before_clear_bit();
15881 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15882 + smp_mb__after_clear_bit();
15883 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15884 + }
15885 +#endif
15886 +
15887 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15888 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15889 + prev->context.user_cs_limit != next->context.user_cs_limit))
15890 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15891 +#ifdef CONFIG_SMP
15892 + else if (unlikely(tlbstate != TLBSTATE_OK))
15893 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15894 +#endif
15895 +#endif
15896 +
15897 }
15898 + else {
15899 +
15900 +#ifdef CONFIG_PAX_PER_CPU_PGD
15901 + pax_open_kernel();
15902 +
15903 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15904 + if (static_cpu_has(X86_FEATURE_PCID))
15905 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15906 + else
15907 +#endif
15908 +
15909 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15910 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15911 + pax_close_kernel();
15912 + 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));
15913 +
15914 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15915 + if (static_cpu_has(X86_FEATURE_PCID)) {
15916 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15917 + u64 descriptor[2];
15918 + descriptor[0] = PCID_USER;
15919 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15920 + } else {
15921 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15922 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15923 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15924 + else
15925 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15926 + }
15927 + } else
15928 +#endif
15929 +
15930 + load_cr3(get_cpu_pgd(cpu, kernel));
15931 +#endif
15932 +
15933 #ifdef CONFIG_SMP
15934 - else {
15935 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15936 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15937
15938 @@ -70,11 +177,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15939 * tlb flush IPI delivery. We must reload CR3
15940 * to make sure to use no freed page tables.
15941 */
15942 +
15943 +#ifndef CONFIG_PAX_PER_CPU_PGD
15944 load_cr3(next->pgd);
15945 +#endif
15946 +
15947 load_LDT_nolock(&next->context);
15948 +
15949 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15950 + if (!(__supported_pte_mask & _PAGE_NX))
15951 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15952 +#endif
15953 +
15954 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15955 +#ifdef CONFIG_PAX_PAGEEXEC
15956 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15957 +#endif
15958 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15959 +#endif
15960 +
15961 }
15962 +#endif
15963 }
15964 -#endif
15965 }
15966
15967 #define activate_mm(prev, next) \
15968 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15969 index e3b7819..b257c64 100644
15970 --- a/arch/x86/include/asm/module.h
15971 +++ b/arch/x86/include/asm/module.h
15972 @@ -5,6 +5,7 @@
15973
15974 #ifdef CONFIG_X86_64
15975 /* X86_64 does not define MODULE_PROC_FAMILY */
15976 +#define MODULE_PROC_FAMILY ""
15977 #elif defined CONFIG_M486
15978 #define MODULE_PROC_FAMILY "486 "
15979 #elif defined CONFIG_M586
15980 @@ -57,8 +58,20 @@
15981 #error unknown processor family
15982 #endif
15983
15984 -#ifdef CONFIG_X86_32
15985 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15986 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15987 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15988 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15989 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15990 +#else
15991 +#define MODULE_PAX_KERNEXEC ""
15992 #endif
15993
15994 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15995 +#define MODULE_PAX_UDEREF "UDEREF "
15996 +#else
15997 +#define MODULE_PAX_UDEREF ""
15998 +#endif
15999 +
16000 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16001 +
16002 #endif /* _ASM_X86_MODULE_H */
16003 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16004 index 86f9301..b365cda 100644
16005 --- a/arch/x86/include/asm/nmi.h
16006 +++ b/arch/x86/include/asm/nmi.h
16007 @@ -40,11 +40,11 @@ struct nmiaction {
16008 nmi_handler_t handler;
16009 unsigned long flags;
16010 const char *name;
16011 -};
16012 +} __do_const;
16013
16014 #define register_nmi_handler(t, fn, fg, n, init...) \
16015 ({ \
16016 - static struct nmiaction init fn##_na = { \
16017 + static const struct nmiaction init fn##_na = { \
16018 .handler = (fn), \
16019 .name = (n), \
16020 .flags = (fg), \
16021 @@ -52,7 +52,7 @@ struct nmiaction {
16022 __register_nmi_handler((t), &fn##_na); \
16023 })
16024
16025 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16026 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16027
16028 void unregister_nmi_handler(unsigned int, const char *);
16029
16030 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16031 index c878924..21f4889 100644
16032 --- a/arch/x86/include/asm/page.h
16033 +++ b/arch/x86/include/asm/page.h
16034 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16035 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16036
16037 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16038 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16039
16040 #define __boot_va(x) __va(x)
16041 #define __boot_pa(x) __pa(x)
16042 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16043 index 0f1ddee..e2fc3d1 100644
16044 --- a/arch/x86/include/asm/page_64.h
16045 +++ b/arch/x86/include/asm/page_64.h
16046 @@ -7,9 +7,9 @@
16047
16048 /* duplicated to the one in bootmem.h */
16049 extern unsigned long max_pfn;
16050 -extern unsigned long phys_base;
16051 +extern const unsigned long phys_base;
16052
16053 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16054 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16055 {
16056 unsigned long y = x - __START_KERNEL_map;
16057
16058 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16059 index cfdc9ee..3f7b5d6 100644
16060 --- a/arch/x86/include/asm/paravirt.h
16061 +++ b/arch/x86/include/asm/paravirt.h
16062 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16063 return (pmd_t) { ret };
16064 }
16065
16066 -static inline pmdval_t pmd_val(pmd_t pmd)
16067 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16068 {
16069 pmdval_t ret;
16070
16071 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16072 val);
16073 }
16074
16075 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16076 +{
16077 + pgdval_t val = native_pgd_val(pgd);
16078 +
16079 + if (sizeof(pgdval_t) > sizeof(long))
16080 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16081 + val, (u64)val >> 32);
16082 + else
16083 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16084 + val);
16085 +}
16086 +
16087 static inline void pgd_clear(pgd_t *pgdp)
16088 {
16089 set_pgd(pgdp, __pgd(0));
16090 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16091 pv_mmu_ops.set_fixmap(idx, phys, flags);
16092 }
16093
16094 +#ifdef CONFIG_PAX_KERNEXEC
16095 +static inline unsigned long pax_open_kernel(void)
16096 +{
16097 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16098 +}
16099 +
16100 +static inline unsigned long pax_close_kernel(void)
16101 +{
16102 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16103 +}
16104 +#else
16105 +static inline unsigned long pax_open_kernel(void) { return 0; }
16106 +static inline unsigned long pax_close_kernel(void) { return 0; }
16107 +#endif
16108 +
16109 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16110
16111 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16112 @@ -926,7 +953,7 @@ extern void default_banner(void);
16113
16114 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16115 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16116 -#define PARA_INDIRECT(addr) *%cs:addr
16117 +#define PARA_INDIRECT(addr) *%ss:addr
16118 #endif
16119
16120 #define INTERRUPT_RETURN \
16121 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16122 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16123 CLBR_NONE, \
16124 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16125 +
16126 +#define GET_CR0_INTO_RDI \
16127 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16128 + mov %rax,%rdi
16129 +
16130 +#define SET_RDI_INTO_CR0 \
16131 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16132 +
16133 +#define GET_CR3_INTO_RDI \
16134 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16135 + mov %rax,%rdi
16136 +
16137 +#define SET_RDI_INTO_CR3 \
16138 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16139 +
16140 #endif /* CONFIG_X86_32 */
16141
16142 #endif /* __ASSEMBLY__ */
16143 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16144 index 0db1fca..52310cc 100644
16145 --- a/arch/x86/include/asm/paravirt_types.h
16146 +++ b/arch/x86/include/asm/paravirt_types.h
16147 @@ -84,7 +84,7 @@ struct pv_init_ops {
16148 */
16149 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16150 unsigned long addr, unsigned len);
16151 -};
16152 +} __no_const;
16153
16154
16155 struct pv_lazy_ops {
16156 @@ -98,7 +98,7 @@ struct pv_time_ops {
16157 unsigned long long (*sched_clock)(void);
16158 unsigned long long (*steal_clock)(int cpu);
16159 unsigned long (*get_tsc_khz)(void);
16160 -};
16161 +} __no_const;
16162
16163 struct pv_cpu_ops {
16164 /* hooks for various privileged instructions */
16165 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16166
16167 void (*start_context_switch)(struct task_struct *prev);
16168 void (*end_context_switch)(struct task_struct *next);
16169 -};
16170 +} __no_const;
16171
16172 struct pv_irq_ops {
16173 /*
16174 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16175 unsigned long start_eip,
16176 unsigned long start_esp);
16177 #endif
16178 -};
16179 +} __no_const;
16180
16181 struct pv_mmu_ops {
16182 unsigned long (*read_cr2)(void);
16183 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16184 struct paravirt_callee_save make_pud;
16185
16186 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16187 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16188 #endif /* PAGETABLE_LEVELS == 4 */
16189 #endif /* PAGETABLE_LEVELS >= 3 */
16190
16191 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16192 an mfn. We can tell which is which from the index. */
16193 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16194 phys_addr_t phys, pgprot_t flags);
16195 +
16196 +#ifdef CONFIG_PAX_KERNEXEC
16197 + unsigned long (*pax_open_kernel)(void);
16198 + unsigned long (*pax_close_kernel)(void);
16199 +#endif
16200 +
16201 };
16202
16203 struct arch_spinlock;
16204 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16205 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16206 int (*spin_trylock)(struct arch_spinlock *lock);
16207 void (*spin_unlock)(struct arch_spinlock *lock);
16208 -};
16209 +} __no_const;
16210
16211 /* This contains all the paravirt structures: we get a convenient
16212 * number for each function using the offset which we use to indicate
16213 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16214 index b4389a4..7024269 100644
16215 --- a/arch/x86/include/asm/pgalloc.h
16216 +++ b/arch/x86/include/asm/pgalloc.h
16217 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16218 pmd_t *pmd, pte_t *pte)
16219 {
16220 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16221 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16222 +}
16223 +
16224 +static inline void pmd_populate_user(struct mm_struct *mm,
16225 + pmd_t *pmd, pte_t *pte)
16226 +{
16227 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16228 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16229 }
16230
16231 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16232
16233 #ifdef CONFIG_X86_PAE
16234 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16235 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16236 +{
16237 + pud_populate(mm, pudp, pmd);
16238 +}
16239 #else /* !CONFIG_X86_PAE */
16240 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16241 {
16242 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16243 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16244 }
16245 +
16246 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16247 +{
16248 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16249 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16250 +}
16251 #endif /* CONFIG_X86_PAE */
16252
16253 #if PAGETABLE_LEVELS > 3
16254 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16255 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16256 }
16257
16258 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16259 +{
16260 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16261 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16262 +}
16263 +
16264 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16265 {
16266 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16267 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16268 index 3bf2dd0..23d2a9f 100644
16269 --- a/arch/x86/include/asm/pgtable-2level.h
16270 +++ b/arch/x86/include/asm/pgtable-2level.h
16271 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16272
16273 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16274 {
16275 + pax_open_kernel();
16276 *pmdp = pmd;
16277 + pax_close_kernel();
16278 }
16279
16280 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16281 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16282 index 81bb91b..9392125 100644
16283 --- a/arch/x86/include/asm/pgtable-3level.h
16284 +++ b/arch/x86/include/asm/pgtable-3level.h
16285 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16286
16287 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16288 {
16289 + pax_open_kernel();
16290 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16291 + pax_close_kernel();
16292 }
16293
16294 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16295 {
16296 + pax_open_kernel();
16297 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16298 + pax_close_kernel();
16299 }
16300
16301 /*
16302 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16303 index 1c00631..845f898 100644
16304 --- a/arch/x86/include/asm/pgtable.h
16305 +++ b/arch/x86/include/asm/pgtable.h
16306 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16307
16308 #ifndef __PAGETABLE_PUD_FOLDED
16309 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16310 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16311 #define pgd_clear(pgd) native_pgd_clear(pgd)
16312 #endif
16313
16314 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16315
16316 #define arch_end_context_switch(prev) do {} while(0)
16317
16318 +#define pax_open_kernel() native_pax_open_kernel()
16319 +#define pax_close_kernel() native_pax_close_kernel()
16320 #endif /* CONFIG_PARAVIRT */
16321
16322 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16323 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16324 +
16325 +#ifdef CONFIG_PAX_KERNEXEC
16326 +static inline unsigned long native_pax_open_kernel(void)
16327 +{
16328 + unsigned long cr0;
16329 +
16330 + preempt_disable();
16331 + barrier();
16332 + cr0 = read_cr0() ^ X86_CR0_WP;
16333 + BUG_ON(cr0 & X86_CR0_WP);
16334 + write_cr0(cr0);
16335 + return cr0 ^ X86_CR0_WP;
16336 +}
16337 +
16338 +static inline unsigned long native_pax_close_kernel(void)
16339 +{
16340 + unsigned long cr0;
16341 +
16342 + cr0 = read_cr0() ^ X86_CR0_WP;
16343 + BUG_ON(!(cr0 & X86_CR0_WP));
16344 + write_cr0(cr0);
16345 + barrier();
16346 + preempt_enable_no_resched();
16347 + return cr0 ^ X86_CR0_WP;
16348 +}
16349 +#else
16350 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16351 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16352 +#endif
16353 +
16354 /*
16355 * The following only work if pte_present() is true.
16356 * Undefined behaviour if not..
16357 */
16358 +static inline int pte_user(pte_t pte)
16359 +{
16360 + return pte_val(pte) & _PAGE_USER;
16361 +}
16362 +
16363 static inline int pte_dirty(pte_t pte)
16364 {
16365 return pte_flags(pte) & _PAGE_DIRTY;
16366 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16367 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16368 }
16369
16370 +static inline unsigned long pgd_pfn(pgd_t pgd)
16371 +{
16372 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16373 +}
16374 +
16375 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16376
16377 static inline int pmd_large(pmd_t pte)
16378 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16379 return pte_clear_flags(pte, _PAGE_RW);
16380 }
16381
16382 +static inline pte_t pte_mkread(pte_t pte)
16383 +{
16384 + return __pte(pte_val(pte) | _PAGE_USER);
16385 +}
16386 +
16387 static inline pte_t pte_mkexec(pte_t pte)
16388 {
16389 - return pte_clear_flags(pte, _PAGE_NX);
16390 +#ifdef CONFIG_X86_PAE
16391 + if (__supported_pte_mask & _PAGE_NX)
16392 + return pte_clear_flags(pte, _PAGE_NX);
16393 + else
16394 +#endif
16395 + return pte_set_flags(pte, _PAGE_USER);
16396 +}
16397 +
16398 +static inline pte_t pte_exprotect(pte_t pte)
16399 +{
16400 +#ifdef CONFIG_X86_PAE
16401 + if (__supported_pte_mask & _PAGE_NX)
16402 + return pte_set_flags(pte, _PAGE_NX);
16403 + else
16404 +#endif
16405 + return pte_clear_flags(pte, _PAGE_USER);
16406 }
16407
16408 static inline pte_t pte_mkdirty(pte_t pte)
16409 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16410 #endif
16411
16412 #ifndef __ASSEMBLY__
16413 +
16414 +#ifdef CONFIG_PAX_PER_CPU_PGD
16415 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16416 +enum cpu_pgd_type {kernel = 0, user = 1};
16417 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16418 +{
16419 + return cpu_pgd[cpu][type];
16420 +}
16421 +#endif
16422 +
16423 #include <linux/mm_types.h>
16424 #include <linux/log2.h>
16425
16426 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16427 * Currently stuck as a macro due to indirect forward reference to
16428 * linux/mmzone.h's __section_mem_map_addr() definition:
16429 */
16430 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16431 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16432
16433 /* Find an entry in the second-level page table.. */
16434 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16435 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16436 * Currently stuck as a macro due to indirect forward reference to
16437 * linux/mmzone.h's __section_mem_map_addr() definition:
16438 */
16439 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16440 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16441
16442 /* to find an entry in a page-table-directory. */
16443 static inline unsigned long pud_index(unsigned long address)
16444 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16445
16446 static inline int pgd_bad(pgd_t pgd)
16447 {
16448 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16449 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16450 }
16451
16452 static inline int pgd_none(pgd_t pgd)
16453 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16454 * pgd_offset() returns a (pgd_t *)
16455 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16456 */
16457 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16458 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16459 +
16460 +#ifdef CONFIG_PAX_PER_CPU_PGD
16461 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16462 +#endif
16463 +
16464 /*
16465 * a shortcut which implies the use of the kernel's pgd, instead
16466 * of a process's
16467 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16468 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16469 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16470
16471 +#ifdef CONFIG_X86_32
16472 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16473 +#else
16474 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16475 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16476 +
16477 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16478 +#ifdef __ASSEMBLY__
16479 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16480 +#else
16481 +extern unsigned long pax_user_shadow_base;
16482 +extern pgdval_t clone_pgd_mask;
16483 +#endif
16484 +#endif
16485 +
16486 +#endif
16487 +
16488 #ifndef __ASSEMBLY__
16489
16490 extern int direct_gbpages;
16491 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16492 * dst and src can be on the same page, but the range must not overlap,
16493 * and must not cross a page boundary.
16494 */
16495 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16496 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16497 {
16498 - memcpy(dst, src, count * sizeof(pgd_t));
16499 + pax_open_kernel();
16500 + while (count--)
16501 + *dst++ = *src++;
16502 + pax_close_kernel();
16503 }
16504
16505 +#ifdef CONFIG_PAX_PER_CPU_PGD
16506 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16507 +#endif
16508 +
16509 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16510 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16511 +#else
16512 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16513 +#endif
16514 +
16515 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16516 static inline int page_level_shift(enum pg_level level)
16517 {
16518 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16519 index 9ee3221..b979c6b 100644
16520 --- a/arch/x86/include/asm/pgtable_32.h
16521 +++ b/arch/x86/include/asm/pgtable_32.h
16522 @@ -25,9 +25,6 @@
16523 struct mm_struct;
16524 struct vm_area_struct;
16525
16526 -extern pgd_t swapper_pg_dir[1024];
16527 -extern pgd_t initial_page_table[1024];
16528 -
16529 static inline void pgtable_cache_init(void) { }
16530 static inline void check_pgt_cache(void) { }
16531 void paging_init(void);
16532 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16533 # include <asm/pgtable-2level.h>
16534 #endif
16535
16536 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16537 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16538 +#ifdef CONFIG_X86_PAE
16539 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16540 +#endif
16541 +
16542 #if defined(CONFIG_HIGHPTE)
16543 #define pte_offset_map(dir, address) \
16544 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16545 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16546 /* Clear a kernel PTE and flush it from the TLB */
16547 #define kpte_clear_flush(ptep, vaddr) \
16548 do { \
16549 + pax_open_kernel(); \
16550 pte_clear(&init_mm, (vaddr), (ptep)); \
16551 + pax_close_kernel(); \
16552 __flush_tlb_one((vaddr)); \
16553 } while (0)
16554
16555 #endif /* !__ASSEMBLY__ */
16556
16557 +#define HAVE_ARCH_UNMAPPED_AREA
16558 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16559 +
16560 /*
16561 * kern_addr_valid() is (1) for FLATMEM and (0) for
16562 * SPARSEMEM and DISCONTIGMEM
16563 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16564 index ed5903b..c7fe163 100644
16565 --- a/arch/x86/include/asm/pgtable_32_types.h
16566 +++ b/arch/x86/include/asm/pgtable_32_types.h
16567 @@ -8,7 +8,7 @@
16568 */
16569 #ifdef CONFIG_X86_PAE
16570 # include <asm/pgtable-3level_types.h>
16571 -# define PMD_SIZE (1UL << PMD_SHIFT)
16572 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16573 # define PMD_MASK (~(PMD_SIZE - 1))
16574 #else
16575 # include <asm/pgtable-2level_types.h>
16576 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16577 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16578 #endif
16579
16580 +#ifdef CONFIG_PAX_KERNEXEC
16581 +#ifndef __ASSEMBLY__
16582 +extern unsigned char MODULES_EXEC_VADDR[];
16583 +extern unsigned char MODULES_EXEC_END[];
16584 +#endif
16585 +#include <asm/boot.h>
16586 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16587 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16588 +#else
16589 +#define ktla_ktva(addr) (addr)
16590 +#define ktva_ktla(addr) (addr)
16591 +#endif
16592 +
16593 #define MODULES_VADDR VMALLOC_START
16594 #define MODULES_END VMALLOC_END
16595 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16596 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16597 index e22c1db..23a625a 100644
16598 --- a/arch/x86/include/asm/pgtable_64.h
16599 +++ b/arch/x86/include/asm/pgtable_64.h
16600 @@ -16,10 +16,14 @@
16601
16602 extern pud_t level3_kernel_pgt[512];
16603 extern pud_t level3_ident_pgt[512];
16604 +extern pud_t level3_vmalloc_start_pgt[512];
16605 +extern pud_t level3_vmalloc_end_pgt[512];
16606 +extern pud_t level3_vmemmap_pgt[512];
16607 +extern pud_t level2_vmemmap_pgt[512];
16608 extern pmd_t level2_kernel_pgt[512];
16609 extern pmd_t level2_fixmap_pgt[512];
16610 -extern pmd_t level2_ident_pgt[512];
16611 -extern pgd_t init_level4_pgt[];
16612 +extern pmd_t level2_ident_pgt[512*2];
16613 +extern pgd_t init_level4_pgt[512];
16614
16615 #define swapper_pg_dir init_level4_pgt
16616
16617 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16618
16619 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16620 {
16621 + pax_open_kernel();
16622 *pmdp = pmd;
16623 + pax_close_kernel();
16624 }
16625
16626 static inline void native_pmd_clear(pmd_t *pmd)
16627 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16628
16629 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16630 {
16631 + pax_open_kernel();
16632 *pudp = pud;
16633 + pax_close_kernel();
16634 }
16635
16636 static inline void native_pud_clear(pud_t *pud)
16637 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16638
16639 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16640 {
16641 + pax_open_kernel();
16642 + *pgdp = pgd;
16643 + pax_close_kernel();
16644 +}
16645 +
16646 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16647 +{
16648 *pgdp = pgd;
16649 }
16650
16651 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16652 index 2d88344..4679fc3 100644
16653 --- a/arch/x86/include/asm/pgtable_64_types.h
16654 +++ b/arch/x86/include/asm/pgtable_64_types.h
16655 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16656 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16657 #define MODULES_END _AC(0xffffffffff000000, UL)
16658 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16659 +#define MODULES_EXEC_VADDR MODULES_VADDR
16660 +#define MODULES_EXEC_END MODULES_END
16661 +
16662 +#define ktla_ktva(addr) (addr)
16663 +#define ktva_ktla(addr) (addr)
16664
16665 #define EARLY_DYNAMIC_PAGE_TABLES 64
16666
16667 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16668 index f4843e0..a2526f8 100644
16669 --- a/arch/x86/include/asm/pgtable_types.h
16670 +++ b/arch/x86/include/asm/pgtable_types.h
16671 @@ -16,13 +16,12 @@
16672 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16673 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16674 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16675 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16676 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16677 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16678 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16679 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16680 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16681 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16682 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16683 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16684 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16685 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16686
16687 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16688 @@ -40,7 +39,6 @@
16689 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16690 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16691 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16692 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16693 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16694 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16695 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16696 @@ -84,8 +82,10 @@
16697
16698 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16699 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16700 -#else
16701 +#elif defined(CONFIG_KMEMCHECK)
16702 #define _PAGE_NX (_AT(pteval_t, 0))
16703 +#else
16704 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16705 #endif
16706
16707 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16708 @@ -143,6 +143,9 @@
16709 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16710 _PAGE_ACCESSED)
16711
16712 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16713 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16714 +
16715 #define __PAGE_KERNEL_EXEC \
16716 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16717 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16718 @@ -153,7 +156,7 @@
16719 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16720 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16721 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16722 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16723 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16724 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16725 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16726 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16727 @@ -215,8 +218,8 @@
16728 * bits are combined, this will alow user to access the high address mapped
16729 * VDSO in the presence of CONFIG_COMPAT_VDSO
16730 */
16731 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16732 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16733 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16734 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16735 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16736 #endif
16737
16738 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16739 {
16740 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16741 }
16742 +#endif
16743
16744 +#if PAGETABLE_LEVELS == 3
16745 +#include <asm-generic/pgtable-nopud.h>
16746 +#endif
16747 +
16748 +#if PAGETABLE_LEVELS == 2
16749 +#include <asm-generic/pgtable-nopmd.h>
16750 +#endif
16751 +
16752 +#ifndef __ASSEMBLY__
16753 #if PAGETABLE_LEVELS > 3
16754 typedef struct { pudval_t pud; } pud_t;
16755
16756 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16757 return pud.pud;
16758 }
16759 #else
16760 -#include <asm-generic/pgtable-nopud.h>
16761 -
16762 static inline pudval_t native_pud_val(pud_t pud)
16763 {
16764 return native_pgd_val(pud.pgd);
16765 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16766 return pmd.pmd;
16767 }
16768 #else
16769 -#include <asm-generic/pgtable-nopmd.h>
16770 -
16771 static inline pmdval_t native_pmd_val(pmd_t pmd)
16772 {
16773 return native_pgd_val(pmd.pud.pgd);
16774 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16775
16776 extern pteval_t __supported_pte_mask;
16777 extern void set_nx(void);
16778 -extern int nx_enabled;
16779
16780 #define pgprot_writecombine pgprot_writecombine
16781 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16782 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16783 index 24cf5ae..4d9fa2d 100644
16784 --- a/arch/x86/include/asm/processor.h
16785 +++ b/arch/x86/include/asm/processor.h
16786 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16787 : "memory");
16788 }
16789
16790 +/* invpcid (%rdx),%rax */
16791 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16792 +
16793 +#define INVPCID_SINGLE_ADDRESS 0UL
16794 +#define INVPCID_SINGLE_CONTEXT 1UL
16795 +#define INVPCID_ALL_GLOBAL 2UL
16796 +#define INVPCID_ALL_MONGLOBAL 3UL
16797 +
16798 +#define PCID_KERNEL 0UL
16799 +#define PCID_USER 1UL
16800 +#define PCID_NOFLUSH (1UL << 63)
16801 +
16802 static inline void load_cr3(pgd_t *pgdir)
16803 {
16804 - write_cr3(__pa(pgdir));
16805 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16806 }
16807
16808 #ifdef CONFIG_X86_32
16809 @@ -283,7 +295,7 @@ struct tss_struct {
16810
16811 } ____cacheline_aligned;
16812
16813 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16814 +extern struct tss_struct init_tss[NR_CPUS];
16815
16816 /*
16817 * Save the original ist values for checking stack pointers during debugging
16818 @@ -453,6 +465,7 @@ struct thread_struct {
16819 unsigned short ds;
16820 unsigned short fsindex;
16821 unsigned short gsindex;
16822 + unsigned short ss;
16823 #endif
16824 #ifdef CONFIG_X86_32
16825 unsigned long ip;
16826 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16827 extern unsigned long mmu_cr4_features;
16828 extern u32 *trampoline_cr4_features;
16829
16830 -static inline void set_in_cr4(unsigned long mask)
16831 -{
16832 - unsigned long cr4;
16833 -
16834 - mmu_cr4_features |= mask;
16835 - if (trampoline_cr4_features)
16836 - *trampoline_cr4_features = mmu_cr4_features;
16837 - cr4 = read_cr4();
16838 - cr4 |= mask;
16839 - write_cr4(cr4);
16840 -}
16841 -
16842 -static inline void clear_in_cr4(unsigned long mask)
16843 -{
16844 - unsigned long cr4;
16845 -
16846 - mmu_cr4_features &= ~mask;
16847 - if (trampoline_cr4_features)
16848 - *trampoline_cr4_features = mmu_cr4_features;
16849 - cr4 = read_cr4();
16850 - cr4 &= ~mask;
16851 - write_cr4(cr4);
16852 -}
16853 +extern void set_in_cr4(unsigned long mask);
16854 +extern void clear_in_cr4(unsigned long mask);
16855
16856 typedef struct {
16857 unsigned long seg;
16858 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16859 */
16860 #define TASK_SIZE PAGE_OFFSET
16861 #define TASK_SIZE_MAX TASK_SIZE
16862 +
16863 +#ifdef CONFIG_PAX_SEGMEXEC
16864 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16865 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16866 +#else
16867 #define STACK_TOP TASK_SIZE
16868 -#define STACK_TOP_MAX STACK_TOP
16869 +#endif
16870 +
16871 +#define STACK_TOP_MAX TASK_SIZE
16872
16873 #define INIT_THREAD { \
16874 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16875 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16876 .vm86_info = NULL, \
16877 .sysenter_cs = __KERNEL_CS, \
16878 .io_bitmap_ptr = NULL, \
16879 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16880 */
16881 #define INIT_TSS { \
16882 .x86_tss = { \
16883 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16884 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16885 .ss0 = __KERNEL_DS, \
16886 .ss1 = __KERNEL_CS, \
16887 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16888 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16889 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16890
16891 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16892 -#define KSTK_TOP(info) \
16893 -({ \
16894 - unsigned long *__ptr = (unsigned long *)(info); \
16895 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16896 -})
16897 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16898
16899 /*
16900 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16901 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16902 #define task_pt_regs(task) \
16903 ({ \
16904 struct pt_regs *__regs__; \
16905 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16906 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16907 __regs__ - 1; \
16908 })
16909
16910 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16911 /*
16912 * User space process size. 47bits minus one guard page.
16913 */
16914 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16915 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16916
16917 /* This decides where the kernel will search for a free chunk of vm
16918 * space during mmap's.
16919 */
16920 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16921 - 0xc0000000 : 0xFFFFe000)
16922 + 0xc0000000 : 0xFFFFf000)
16923
16924 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16925 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16926 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16927 #define STACK_TOP_MAX TASK_SIZE_MAX
16928
16929 #define INIT_THREAD { \
16930 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16931 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16932 }
16933
16934 #define INIT_TSS { \
16935 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16936 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16937 }
16938
16939 /*
16940 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16941 */
16942 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16943
16944 +#ifdef CONFIG_PAX_SEGMEXEC
16945 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16946 +#endif
16947 +
16948 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16949
16950 /* Get/set a process' ability to use the timestamp counter instruction */
16951 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16952 extern u16 amd_get_nb_id(int cpu);
16953
16954 struct aperfmperf {
16955 - u64 aperf, mperf;
16956 + u64 aperf __intentional_overflow(0);
16957 + u64 mperf __intentional_overflow(0);
16958 };
16959
16960 static inline void get_aperfmperf(struct aperfmperf *am)
16961 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16962 return ratio;
16963 }
16964
16965 -extern unsigned long arch_align_stack(unsigned long sp);
16966 +#define arch_align_stack(x) ((x) & ~0xfUL)
16967 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16968
16969 void default_idle(void);
16970 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16971 #define xen_set_default_idle 0
16972 #endif
16973
16974 -void stop_this_cpu(void *dummy);
16975 +void stop_this_cpu(void *dummy) __noreturn;
16976 void df_debug(struct pt_regs *regs, long error_code);
16977 #endif /* _ASM_X86_PROCESSOR_H */
16978 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16979 index 942a086..6c26446 100644
16980 --- a/arch/x86/include/asm/ptrace.h
16981 +++ b/arch/x86/include/asm/ptrace.h
16982 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16983 }
16984
16985 /*
16986 - * user_mode_vm(regs) determines whether a register set came from user mode.
16987 + * user_mode(regs) determines whether a register set came from user mode.
16988 * This is true if V8086 mode was enabled OR if the register set was from
16989 * protected mode with RPL-3 CS value. This tricky test checks that with
16990 * one comparison. Many places in the kernel can bypass this full check
16991 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16992 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16993 + * be used.
16994 */
16995 -static inline int user_mode(struct pt_regs *regs)
16996 +static inline int user_mode_novm(struct pt_regs *regs)
16997 {
16998 #ifdef CONFIG_X86_32
16999 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17000 #else
17001 - return !!(regs->cs & 3);
17002 + return !!(regs->cs & SEGMENT_RPL_MASK);
17003 #endif
17004 }
17005
17006 -static inline int user_mode_vm(struct pt_regs *regs)
17007 +static inline int user_mode(struct pt_regs *regs)
17008 {
17009 #ifdef CONFIG_X86_32
17010 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17011 USER_RPL;
17012 #else
17013 - return user_mode(regs);
17014 + return user_mode_novm(regs);
17015 #endif
17016 }
17017
17018 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17019 #ifdef CONFIG_X86_64
17020 static inline bool user_64bit_mode(struct pt_regs *regs)
17021 {
17022 + unsigned long cs = regs->cs & 0xffff;
17023 #ifndef CONFIG_PARAVIRT
17024 /*
17025 * On non-paravirt systems, this is the only long mode CPL 3
17026 * selector. We do not allow long mode selectors in the LDT.
17027 */
17028 - return regs->cs == __USER_CS;
17029 + return cs == __USER_CS;
17030 #else
17031 /* Headers are too twisted for this to go in paravirt.h. */
17032 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17033 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17034 #endif
17035 }
17036
17037 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17038 * Traps from the kernel do not save sp and ss.
17039 * Use the helper function to retrieve sp.
17040 */
17041 - if (offset == offsetof(struct pt_regs, sp) &&
17042 - regs->cs == __KERNEL_CS)
17043 - return kernel_stack_pointer(regs);
17044 + if (offset == offsetof(struct pt_regs, sp)) {
17045 + unsigned long cs = regs->cs & 0xffff;
17046 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17047 + return kernel_stack_pointer(regs);
17048 + }
17049 #endif
17050 return *(unsigned long *)((unsigned long)regs + offset);
17051 }
17052 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17053 index 9c6b890..5305f53 100644
17054 --- a/arch/x86/include/asm/realmode.h
17055 +++ b/arch/x86/include/asm/realmode.h
17056 @@ -22,16 +22,14 @@ struct real_mode_header {
17057 #endif
17058 /* APM/BIOS reboot */
17059 u32 machine_real_restart_asm;
17060 -#ifdef CONFIG_X86_64
17061 u32 machine_real_restart_seg;
17062 -#endif
17063 };
17064
17065 /* This must match data at trampoline_32/64.S */
17066 struct trampoline_header {
17067 #ifdef CONFIG_X86_32
17068 u32 start;
17069 - u16 gdt_pad;
17070 + u16 boot_cs;
17071 u16 gdt_limit;
17072 u32 gdt_base;
17073 #else
17074 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17075 index a82c4f1..ac45053 100644
17076 --- a/arch/x86/include/asm/reboot.h
17077 +++ b/arch/x86/include/asm/reboot.h
17078 @@ -6,13 +6,13 @@
17079 struct pt_regs;
17080
17081 struct machine_ops {
17082 - void (*restart)(char *cmd);
17083 - void (*halt)(void);
17084 - void (*power_off)(void);
17085 + void (* __noreturn restart)(char *cmd);
17086 + void (* __noreturn halt)(void);
17087 + void (* __noreturn power_off)(void);
17088 void (*shutdown)(void);
17089 void (*crash_shutdown)(struct pt_regs *);
17090 - void (*emergency_restart)(void);
17091 -};
17092 + void (* __noreturn emergency_restart)(void);
17093 +} __no_const;
17094
17095 extern struct machine_ops machine_ops;
17096
17097 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17098 index cad82c9..2e5c5c1 100644
17099 --- a/arch/x86/include/asm/rwsem.h
17100 +++ b/arch/x86/include/asm/rwsem.h
17101 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17102 {
17103 asm volatile("# beginning down_read\n\t"
17104 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17105 +
17106 +#ifdef CONFIG_PAX_REFCOUNT
17107 + "jno 0f\n"
17108 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17109 + "int $4\n0:\n"
17110 + _ASM_EXTABLE(0b, 0b)
17111 +#endif
17112 +
17113 /* adds 0x00000001 */
17114 " jns 1f\n"
17115 " call call_rwsem_down_read_failed\n"
17116 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17117 "1:\n\t"
17118 " mov %1,%2\n\t"
17119 " add %3,%2\n\t"
17120 +
17121 +#ifdef CONFIG_PAX_REFCOUNT
17122 + "jno 0f\n"
17123 + "sub %3,%2\n"
17124 + "int $4\n0:\n"
17125 + _ASM_EXTABLE(0b, 0b)
17126 +#endif
17127 +
17128 " jle 2f\n\t"
17129 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17130 " jnz 1b\n\t"
17131 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17132 long tmp;
17133 asm volatile("# beginning down_write\n\t"
17134 LOCK_PREFIX " xadd %1,(%2)\n\t"
17135 +
17136 +#ifdef CONFIG_PAX_REFCOUNT
17137 + "jno 0f\n"
17138 + "mov %1,(%2)\n"
17139 + "int $4\n0:\n"
17140 + _ASM_EXTABLE(0b, 0b)
17141 +#endif
17142 +
17143 /* adds 0xffff0001, returns the old value */
17144 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17145 /* was the active mask 0 before? */
17146 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17147 long tmp;
17148 asm volatile("# beginning __up_read\n\t"
17149 LOCK_PREFIX " xadd %1,(%2)\n\t"
17150 +
17151 +#ifdef CONFIG_PAX_REFCOUNT
17152 + "jno 0f\n"
17153 + "mov %1,(%2)\n"
17154 + "int $4\n0:\n"
17155 + _ASM_EXTABLE(0b, 0b)
17156 +#endif
17157 +
17158 /* subtracts 1, returns the old value */
17159 " jns 1f\n\t"
17160 " call call_rwsem_wake\n" /* expects old value in %edx */
17161 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17162 long tmp;
17163 asm volatile("# beginning __up_write\n\t"
17164 LOCK_PREFIX " xadd %1,(%2)\n\t"
17165 +
17166 +#ifdef CONFIG_PAX_REFCOUNT
17167 + "jno 0f\n"
17168 + "mov %1,(%2)\n"
17169 + "int $4\n0:\n"
17170 + _ASM_EXTABLE(0b, 0b)
17171 +#endif
17172 +
17173 /* subtracts 0xffff0001, returns the old value */
17174 " jns 1f\n\t"
17175 " call call_rwsem_wake\n" /* expects old value in %edx */
17176 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17177 {
17178 asm volatile("# beginning __downgrade_write\n\t"
17179 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17180 +
17181 +#ifdef CONFIG_PAX_REFCOUNT
17182 + "jno 0f\n"
17183 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17184 + "int $4\n0:\n"
17185 + _ASM_EXTABLE(0b, 0b)
17186 +#endif
17187 +
17188 /*
17189 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17190 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17191 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17192 */
17193 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17194 {
17195 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17196 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17197 +
17198 +#ifdef CONFIG_PAX_REFCOUNT
17199 + "jno 0f\n"
17200 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17201 + "int $4\n0:\n"
17202 + _ASM_EXTABLE(0b, 0b)
17203 +#endif
17204 +
17205 : "+m" (sem->count)
17206 : "er" (delta));
17207 }
17208 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17209 */
17210 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17211 {
17212 - return delta + xadd(&sem->count, delta);
17213 + return delta + xadd_check_overflow(&sem->count, delta);
17214 }
17215
17216 #endif /* __KERNEL__ */
17217 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17218 index c48a950..bc40804 100644
17219 --- a/arch/x86/include/asm/segment.h
17220 +++ b/arch/x86/include/asm/segment.h
17221 @@ -64,10 +64,15 @@
17222 * 26 - ESPFIX small SS
17223 * 27 - per-cpu [ offset to per-cpu data area ]
17224 * 28 - stack_canary-20 [ for stack protector ]
17225 - * 29 - unused
17226 - * 30 - unused
17227 + * 29 - PCI BIOS CS
17228 + * 30 - PCI BIOS DS
17229 * 31 - TSS for double fault handler
17230 */
17231 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17232 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17233 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17234 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17235 +
17236 #define GDT_ENTRY_TLS_MIN 6
17237 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17238
17239 @@ -79,6 +84,8 @@
17240
17241 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17242
17243 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17244 +
17245 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17246
17247 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17248 @@ -104,6 +111,12 @@
17249 #define __KERNEL_STACK_CANARY 0
17250 #endif
17251
17252 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17253 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17254 +
17255 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17256 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17257 +
17258 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17259
17260 /*
17261 @@ -141,7 +154,7 @@
17262 */
17263
17264 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17265 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17266 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17267
17268
17269 #else
17270 @@ -165,6 +178,8 @@
17271 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17272 #define __USER32_DS __USER_DS
17273
17274 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17275 +
17276 #define GDT_ENTRY_TSS 8 /* needs two entries */
17277 #define GDT_ENTRY_LDT 10 /* needs two entries */
17278 #define GDT_ENTRY_TLS_MIN 12
17279 @@ -173,6 +188,8 @@
17280 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17281 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17282
17283 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17284 +
17285 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17286 #define FS_TLS 0
17287 #define GS_TLS 1
17288 @@ -180,12 +197,14 @@
17289 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17290 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17291
17292 -#define GDT_ENTRIES 16
17293 +#define GDT_ENTRIES 17
17294
17295 #endif
17296
17297 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17298 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17299 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17300 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17301 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17302 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17303 #ifndef CONFIG_PARAVIRT
17304 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17305 {
17306 unsigned long __limit;
17307 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17308 - return __limit + 1;
17309 + return __limit;
17310 }
17311
17312 #endif /* !__ASSEMBLY__ */
17313 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17314 index 8d3120f..352b440 100644
17315 --- a/arch/x86/include/asm/smap.h
17316 +++ b/arch/x86/include/asm/smap.h
17317 @@ -25,11 +25,40 @@
17318
17319 #include <asm/alternative-asm.h>
17320
17321 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17322 +#define ASM_PAX_OPEN_USERLAND \
17323 + 661: jmp 663f; \
17324 + .pushsection .altinstr_replacement, "a" ; \
17325 + 662: pushq %rax; nop; \
17326 + .popsection ; \
17327 + .pushsection .altinstructions, "a" ; \
17328 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17329 + .popsection ; \
17330 + call __pax_open_userland; \
17331 + popq %rax; \
17332 + 663:
17333 +
17334 +#define ASM_PAX_CLOSE_USERLAND \
17335 + 661: jmp 663f; \
17336 + .pushsection .altinstr_replacement, "a" ; \
17337 + 662: pushq %rax; nop; \
17338 + .popsection; \
17339 + .pushsection .altinstructions, "a" ; \
17340 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17341 + .popsection; \
17342 + call __pax_close_userland; \
17343 + popq %rax; \
17344 + 663:
17345 +#else
17346 +#define ASM_PAX_OPEN_USERLAND
17347 +#define ASM_PAX_CLOSE_USERLAND
17348 +#endif
17349 +
17350 #ifdef CONFIG_X86_SMAP
17351
17352 #define ASM_CLAC \
17353 661: ASM_NOP3 ; \
17354 - .pushsection .altinstr_replacement, "ax" ; \
17355 + .pushsection .altinstr_replacement, "a" ; \
17356 662: __ASM_CLAC ; \
17357 .popsection ; \
17358 .pushsection .altinstructions, "a" ; \
17359 @@ -38,7 +67,7 @@
17360
17361 #define ASM_STAC \
17362 661: ASM_NOP3 ; \
17363 - .pushsection .altinstr_replacement, "ax" ; \
17364 + .pushsection .altinstr_replacement, "a" ; \
17365 662: __ASM_STAC ; \
17366 .popsection ; \
17367 .pushsection .altinstructions, "a" ; \
17368 @@ -56,6 +85,37 @@
17369
17370 #include <asm/alternative.h>
17371
17372 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17373 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17374 +
17375 +extern void __pax_open_userland(void);
17376 +static __always_inline unsigned long pax_open_userland(void)
17377 +{
17378 +
17379 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17380 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17381 + :
17382 + : [open] "i" (__pax_open_userland)
17383 + : "memory", "rax");
17384 +#endif
17385 +
17386 + return 0;
17387 +}
17388 +
17389 +extern void __pax_close_userland(void);
17390 +static __always_inline unsigned long pax_close_userland(void)
17391 +{
17392 +
17393 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17394 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17395 + :
17396 + : [close] "i" (__pax_close_userland)
17397 + : "memory", "rax");
17398 +#endif
17399 +
17400 + return 0;
17401 +}
17402 +
17403 #ifdef CONFIG_X86_SMAP
17404
17405 static __always_inline void clac(void)
17406 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17407 index 4137890..03fa172 100644
17408 --- a/arch/x86/include/asm/smp.h
17409 +++ b/arch/x86/include/asm/smp.h
17410 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17411 /* cpus sharing the last level cache: */
17412 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17413 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17414 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17415 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17416
17417 static inline struct cpumask *cpu_sibling_mask(int cpu)
17418 {
17419 @@ -79,7 +79,7 @@ struct smp_ops {
17420
17421 void (*send_call_func_ipi)(const struct cpumask *mask);
17422 void (*send_call_func_single_ipi)(int cpu);
17423 -};
17424 +} __no_const;
17425
17426 /* Globals due to paravirt */
17427 extern void set_cpu_sibling_map(int cpu);
17428 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17429 extern int safe_smp_processor_id(void);
17430
17431 #elif defined(CONFIG_X86_64_SMP)
17432 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17433 -
17434 -#define stack_smp_processor_id() \
17435 -({ \
17436 - struct thread_info *ti; \
17437 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17438 - ti->cpu; \
17439 -})
17440 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17441 +#define stack_smp_processor_id() raw_smp_processor_id()
17442 #define safe_smp_processor_id() smp_processor_id()
17443
17444 #endif
17445 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17446 index e3ddd7d..3611fce 100644
17447 --- a/arch/x86/include/asm/spinlock.h
17448 +++ b/arch/x86/include/asm/spinlock.h
17449 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17450 static inline void arch_read_lock(arch_rwlock_t *rw)
17451 {
17452 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17453 +
17454 +#ifdef CONFIG_PAX_REFCOUNT
17455 + "jno 0f\n"
17456 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17457 + "int $4\n0:\n"
17458 + _ASM_EXTABLE(0b, 0b)
17459 +#endif
17460 +
17461 "jns 1f\n"
17462 "call __read_lock_failed\n\t"
17463 "1:\n"
17464 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17465 static inline void arch_write_lock(arch_rwlock_t *rw)
17466 {
17467 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17468 +
17469 +#ifdef CONFIG_PAX_REFCOUNT
17470 + "jno 0f\n"
17471 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17472 + "int $4\n0:\n"
17473 + _ASM_EXTABLE(0b, 0b)
17474 +#endif
17475 +
17476 "jz 1f\n"
17477 "call __write_lock_failed\n\t"
17478 "1:\n"
17479 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17480
17481 static inline void arch_read_unlock(arch_rwlock_t *rw)
17482 {
17483 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17484 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17485 +
17486 +#ifdef CONFIG_PAX_REFCOUNT
17487 + "jno 0f\n"
17488 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17489 + "int $4\n0:\n"
17490 + _ASM_EXTABLE(0b, 0b)
17491 +#endif
17492 +
17493 :"+m" (rw->lock) : : "memory");
17494 }
17495
17496 static inline void arch_write_unlock(arch_rwlock_t *rw)
17497 {
17498 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17499 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17500 +
17501 +#ifdef CONFIG_PAX_REFCOUNT
17502 + "jno 0f\n"
17503 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17504 + "int $4\n0:\n"
17505 + _ASM_EXTABLE(0b, 0b)
17506 +#endif
17507 +
17508 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17509 }
17510
17511 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17512 index 6a99859..03cb807 100644
17513 --- a/arch/x86/include/asm/stackprotector.h
17514 +++ b/arch/x86/include/asm/stackprotector.h
17515 @@ -47,7 +47,7 @@
17516 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17517 */
17518 #define GDT_STACK_CANARY_INIT \
17519 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17520 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17521
17522 /*
17523 * Initialize the stackprotector canary value.
17524 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17525
17526 static inline void load_stack_canary_segment(void)
17527 {
17528 -#ifdef CONFIG_X86_32
17529 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17530 asm volatile ("mov %0, %%gs" : : "r" (0));
17531 #endif
17532 }
17533 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17534 index 70bbe39..4ae2bd4 100644
17535 --- a/arch/x86/include/asm/stacktrace.h
17536 +++ b/arch/x86/include/asm/stacktrace.h
17537 @@ -11,28 +11,20 @@
17538
17539 extern int kstack_depth_to_print;
17540
17541 -struct thread_info;
17542 +struct task_struct;
17543 struct stacktrace_ops;
17544
17545 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17546 - unsigned long *stack,
17547 - unsigned long bp,
17548 - const struct stacktrace_ops *ops,
17549 - void *data,
17550 - unsigned long *end,
17551 - int *graph);
17552 +typedef unsigned long walk_stack_t(struct task_struct *task,
17553 + void *stack_start,
17554 + unsigned long *stack,
17555 + unsigned long bp,
17556 + const struct stacktrace_ops *ops,
17557 + void *data,
17558 + unsigned long *end,
17559 + int *graph);
17560
17561 -extern unsigned long
17562 -print_context_stack(struct thread_info *tinfo,
17563 - unsigned long *stack, unsigned long bp,
17564 - const struct stacktrace_ops *ops, void *data,
17565 - unsigned long *end, int *graph);
17566 -
17567 -extern unsigned long
17568 -print_context_stack_bp(struct thread_info *tinfo,
17569 - unsigned long *stack, unsigned long bp,
17570 - const struct stacktrace_ops *ops, void *data,
17571 - unsigned long *end, int *graph);
17572 +extern walk_stack_t print_context_stack;
17573 +extern walk_stack_t print_context_stack_bp;
17574
17575 /* Generic stack tracer with callbacks */
17576
17577 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17578 void (*address)(void *data, unsigned long address, int reliable);
17579 /* On negative return stop dumping */
17580 int (*stack)(void *data, char *name);
17581 - walk_stack_t walk_stack;
17582 + walk_stack_t *walk_stack;
17583 };
17584
17585 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17586 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17587 index 4ec45b3..a4f0a8a 100644
17588 --- a/arch/x86/include/asm/switch_to.h
17589 +++ b/arch/x86/include/asm/switch_to.h
17590 @@ -108,7 +108,7 @@ do { \
17591 "call __switch_to\n\t" \
17592 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17593 __switch_canary \
17594 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17595 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17596 "movq %%rax,%%rdi\n\t" \
17597 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17598 "jnz ret_from_fork\n\t" \
17599 @@ -119,7 +119,7 @@ do { \
17600 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17601 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17602 [_tif_fork] "i" (_TIF_FORK), \
17603 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17604 + [thread_info] "m" (current_tinfo), \
17605 [current_task] "m" (current_task) \
17606 __switch_canary_iparam \
17607 : "memory", "cc" __EXTRA_CLOBBER)
17608 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17609 index 2781119..618b59b 100644
17610 --- a/arch/x86/include/asm/thread_info.h
17611 +++ b/arch/x86/include/asm/thread_info.h
17612 @@ -10,6 +10,7 @@
17613 #include <linux/compiler.h>
17614 #include <asm/page.h>
17615 #include <asm/types.h>
17616 +#include <asm/percpu.h>
17617
17618 /*
17619 * low level task data that entry.S needs immediate access to
17620 @@ -23,7 +24,6 @@ struct exec_domain;
17621 #include <linux/atomic.h>
17622
17623 struct thread_info {
17624 - struct task_struct *task; /* main task structure */
17625 struct exec_domain *exec_domain; /* execution domain */
17626 __u32 flags; /* low level flags */
17627 __u32 status; /* thread synchronous flags */
17628 @@ -33,19 +33,13 @@ struct thread_info {
17629 mm_segment_t addr_limit;
17630 struct restart_block restart_block;
17631 void __user *sysenter_return;
17632 -#ifdef CONFIG_X86_32
17633 - unsigned long previous_esp; /* ESP of the previous stack in
17634 - case of nested (IRQ) stacks
17635 - */
17636 - __u8 supervisor_stack[0];
17637 -#endif
17638 + unsigned long lowest_stack;
17639 unsigned int sig_on_uaccess_error:1;
17640 unsigned int uaccess_err:1; /* uaccess failed */
17641 };
17642
17643 -#define INIT_THREAD_INFO(tsk) \
17644 +#define INIT_THREAD_INFO \
17645 { \
17646 - .task = &tsk, \
17647 .exec_domain = &default_exec_domain, \
17648 .flags = 0, \
17649 .cpu = 0, \
17650 @@ -56,7 +50,7 @@ struct thread_info {
17651 }, \
17652 }
17653
17654 -#define init_thread_info (init_thread_union.thread_info)
17655 +#define init_thread_info (init_thread_union.stack)
17656 #define init_stack (init_thread_union.stack)
17657
17658 #else /* !__ASSEMBLY__ */
17659 @@ -96,6 +90,7 @@ struct thread_info {
17660 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17661 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17662 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17663 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17664
17665 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17666 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17667 @@ -119,17 +114,18 @@ struct thread_info {
17668 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17669 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17670 #define _TIF_X32 (1 << TIF_X32)
17671 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17672
17673 /* work to do in syscall_trace_enter() */
17674 #define _TIF_WORK_SYSCALL_ENTRY \
17675 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17676 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17677 - _TIF_NOHZ)
17678 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17679
17680 /* work to do in syscall_trace_leave() */
17681 #define _TIF_WORK_SYSCALL_EXIT \
17682 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17683 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17684 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17685
17686 /* work to do on interrupt/exception return */
17687 #define _TIF_WORK_MASK \
17688 @@ -140,7 +136,7 @@ struct thread_info {
17689 /* work to do on any return to user space */
17690 #define _TIF_ALLWORK_MASK \
17691 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17692 - _TIF_NOHZ)
17693 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17694
17695 /* Only used for 64 bit */
17696 #define _TIF_DO_NOTIFY_MASK \
17697 @@ -156,45 +152,40 @@ struct thread_info {
17698
17699 #define PREEMPT_ACTIVE 0x10000000
17700
17701 -#ifdef CONFIG_X86_32
17702 -
17703 -#define STACK_WARN (THREAD_SIZE/8)
17704 -/*
17705 - * macros/functions for gaining access to the thread information structure
17706 - *
17707 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17708 - */
17709 -#ifndef __ASSEMBLY__
17710 -
17711 -
17712 -/* how to get the current stack pointer from C */
17713 -register unsigned long current_stack_pointer asm("esp") __used;
17714 -
17715 -/* how to get the thread information struct from C */
17716 -static inline struct thread_info *current_thread_info(void)
17717 -{
17718 - return (struct thread_info *)
17719 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17720 -}
17721 -
17722 -#else /* !__ASSEMBLY__ */
17723 -
17724 +#ifdef __ASSEMBLY__
17725 /* how to get the thread information struct from ASM */
17726 #define GET_THREAD_INFO(reg) \
17727 - movl $-THREAD_SIZE, reg; \
17728 - andl %esp, reg
17729 + mov PER_CPU_VAR(current_tinfo), reg
17730
17731 /* use this one if reg already contains %esp */
17732 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17733 - andl $-THREAD_SIZE, reg
17734 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17735 +#else
17736 +/* how to get the thread information struct from C */
17737 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17738 +
17739 +static __always_inline struct thread_info *current_thread_info(void)
17740 +{
17741 + return this_cpu_read_stable(current_tinfo);
17742 +}
17743 +#endif
17744 +
17745 +#ifdef CONFIG_X86_32
17746 +
17747 +#define STACK_WARN (THREAD_SIZE/8)
17748 +/*
17749 + * macros/functions for gaining access to the thread information structure
17750 + *
17751 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17752 + */
17753 +#ifndef __ASSEMBLY__
17754 +
17755 +/* how to get the current stack pointer from C */
17756 +register unsigned long current_stack_pointer asm("esp") __used;
17757
17758 #endif
17759
17760 #else /* X86_32 */
17761
17762 -#include <asm/percpu.h>
17763 -#define KERNEL_STACK_OFFSET (5*8)
17764 -
17765 /*
17766 * macros/functions for gaining access to the thread information structure
17767 * preempt_count needs to be 1 initially, until the scheduler is functional.
17768 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17769 #ifndef __ASSEMBLY__
17770 DECLARE_PER_CPU(unsigned long, kernel_stack);
17771
17772 -static inline struct thread_info *current_thread_info(void)
17773 -{
17774 - struct thread_info *ti;
17775 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17776 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17777 - return ti;
17778 -}
17779 -
17780 -#else /* !__ASSEMBLY__ */
17781 -
17782 -/* how to get the thread information struct from ASM */
17783 -#define GET_THREAD_INFO(reg) \
17784 - movq PER_CPU_VAR(kernel_stack),reg ; \
17785 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17786 -
17787 -/*
17788 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17789 - * a certain register (to be used in assembler memory operands).
17790 - */
17791 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17792 -
17793 +/* how to get the current stack pointer from C */
17794 +register unsigned long current_stack_pointer asm("rsp") __used;
17795 #endif
17796
17797 #endif /* !X86_32 */
17798 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17799 extern void arch_task_cache_init(void);
17800 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17801 extern void arch_release_task_struct(struct task_struct *tsk);
17802 +
17803 +#define __HAVE_THREAD_FUNCTIONS
17804 +#define task_thread_info(task) (&(task)->tinfo)
17805 +#define task_stack_page(task) ((task)->stack)
17806 +#define setup_thread_stack(p, org) do {} while (0)
17807 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17808 +
17809 #endif
17810 #endif /* _ASM_X86_THREAD_INFO_H */
17811 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17812 index cf51200..63ff068 100644
17813 --- a/arch/x86/include/asm/tlbflush.h
17814 +++ b/arch/x86/include/asm/tlbflush.h
17815 @@ -17,18 +17,44 @@
17816
17817 static inline void __native_flush_tlb(void)
17818 {
17819 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17820 + u64 descriptor[2];
17821 +
17822 + descriptor[0] = PCID_KERNEL;
17823 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17824 + return;
17825 + }
17826 +
17827 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17828 + if (static_cpu_has(X86_FEATURE_PCID)) {
17829 + unsigned int cpu = raw_get_cpu();
17830 +
17831 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17832 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17833 + raw_put_cpu_no_resched();
17834 + return;
17835 + }
17836 +#endif
17837 +
17838 native_write_cr3(native_read_cr3());
17839 }
17840
17841 static inline void __native_flush_tlb_global_irq_disabled(void)
17842 {
17843 - unsigned long cr4;
17844 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17845 + u64 descriptor[2];
17846
17847 - cr4 = native_read_cr4();
17848 - /* clear PGE */
17849 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17850 - /* write old PGE again and flush TLBs */
17851 - native_write_cr4(cr4);
17852 + descriptor[0] = PCID_KERNEL;
17853 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17854 + } else {
17855 + unsigned long cr4;
17856 +
17857 + cr4 = native_read_cr4();
17858 + /* clear PGE */
17859 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17860 + /* write old PGE again and flush TLBs */
17861 + native_write_cr4(cr4);
17862 + }
17863 }
17864
17865 static inline void __native_flush_tlb_global(void)
17866 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17867
17868 static inline void __native_flush_tlb_single(unsigned long addr)
17869 {
17870 +
17871 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17872 + u64 descriptor[2];
17873 +
17874 + descriptor[0] = PCID_KERNEL;
17875 + descriptor[1] = addr;
17876 +
17877 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17878 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17879 + if (addr < TASK_SIZE_MAX)
17880 + descriptor[1] += pax_user_shadow_base;
17881 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17882 + }
17883 +
17884 + descriptor[0] = PCID_USER;
17885 + descriptor[1] = addr;
17886 +#endif
17887 +
17888 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17889 + return;
17890 + }
17891 +
17892 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17893 + if (static_cpu_has(X86_FEATURE_PCID)) {
17894 + unsigned int cpu = raw_get_cpu();
17895 +
17896 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17897 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17898 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17899 + raw_put_cpu_no_resched();
17900 +
17901 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17902 + addr += pax_user_shadow_base;
17903 + }
17904 +#endif
17905 +
17906 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17907 }
17908
17909 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17910 index 5ee2687..74590b9 100644
17911 --- a/arch/x86/include/asm/uaccess.h
17912 +++ b/arch/x86/include/asm/uaccess.h
17913 @@ -7,6 +7,7 @@
17914 #include <linux/compiler.h>
17915 #include <linux/thread_info.h>
17916 #include <linux/string.h>
17917 +#include <linux/sched.h>
17918 #include <asm/asm.h>
17919 #include <asm/page.h>
17920 #include <asm/smap.h>
17921 @@ -29,7 +30,12 @@
17922
17923 #define get_ds() (KERNEL_DS)
17924 #define get_fs() (current_thread_info()->addr_limit)
17925 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17926 +void __set_fs(mm_segment_t x);
17927 +void set_fs(mm_segment_t x);
17928 +#else
17929 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17930 +#endif
17931
17932 #define segment_eq(a, b) ((a).seg == (b).seg)
17933
17934 @@ -77,8 +83,33 @@
17935 * checks that the pointer is in the user space range - after calling
17936 * this function, memory access functions may still return -EFAULT.
17937 */
17938 -#define access_ok(type, addr, size) \
17939 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17940 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17941 +#define access_ok(type, addr, size) \
17942 +({ \
17943 + long __size = size; \
17944 + unsigned long __addr = (unsigned long)addr; \
17945 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17946 + unsigned long __end_ao = __addr + __size - 1; \
17947 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17948 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17949 + while(__addr_ao <= __end_ao) { \
17950 + char __c_ao; \
17951 + __addr_ao += PAGE_SIZE; \
17952 + if (__size > PAGE_SIZE) \
17953 + cond_resched(); \
17954 + if (__get_user(__c_ao, (char __user *)__addr)) \
17955 + break; \
17956 + if (type != VERIFY_WRITE) { \
17957 + __addr = __addr_ao; \
17958 + continue; \
17959 + } \
17960 + if (__put_user(__c_ao, (char __user *)__addr)) \
17961 + break; \
17962 + __addr = __addr_ao; \
17963 + } \
17964 + } \
17965 + __ret_ao; \
17966 +})
17967
17968 /*
17969 * The exception table consists of pairs of addresses relative to the
17970 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17971 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17972 __chk_user_ptr(ptr); \
17973 might_fault(); \
17974 + pax_open_userland(); \
17975 asm volatile("call __get_user_%P3" \
17976 : "=a" (__ret_gu), "=r" (__val_gu) \
17977 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17978 (x) = (__typeof__(*(ptr))) __val_gu; \
17979 + pax_close_userland(); \
17980 __ret_gu; \
17981 })
17982
17983 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17984 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17985 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17986
17987 -
17988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17989 +#define __copyuser_seg "gs;"
17990 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17991 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17992 +#else
17993 +#define __copyuser_seg
17994 +#define __COPYUSER_SET_ES
17995 +#define __COPYUSER_RESTORE_ES
17996 +#endif
17997
17998 #ifdef CONFIG_X86_32
17999 #define __put_user_asm_u64(x, addr, err, errret) \
18000 asm volatile(ASM_STAC "\n" \
18001 - "1: movl %%eax,0(%2)\n" \
18002 - "2: movl %%edx,4(%2)\n" \
18003 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18004 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18005 "3: " ASM_CLAC "\n" \
18006 ".section .fixup,\"ax\"\n" \
18007 "4: movl %3,%0\n" \
18008 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18009
18010 #define __put_user_asm_ex_u64(x, addr) \
18011 asm volatile(ASM_STAC "\n" \
18012 - "1: movl %%eax,0(%1)\n" \
18013 - "2: movl %%edx,4(%1)\n" \
18014 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18015 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18016 "3: " ASM_CLAC "\n" \
18017 _ASM_EXTABLE_EX(1b, 2b) \
18018 _ASM_EXTABLE_EX(2b, 3b) \
18019 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18020 __typeof__(*(ptr)) __pu_val; \
18021 __chk_user_ptr(ptr); \
18022 might_fault(); \
18023 - __pu_val = x; \
18024 + __pu_val = (x); \
18025 + pax_open_userland(); \
18026 switch (sizeof(*(ptr))) { \
18027 case 1: \
18028 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18029 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18030 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18031 break; \
18032 } \
18033 + pax_close_userland(); \
18034 __ret_pu; \
18035 })
18036
18037 @@ -344,8 +387,10 @@ do { \
18038 } while (0)
18039
18040 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18041 +do { \
18042 + pax_open_userland(); \
18043 asm volatile(ASM_STAC "\n" \
18044 - "1: mov"itype" %2,%"rtype"1\n" \
18045 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18046 "2: " ASM_CLAC "\n" \
18047 ".section .fixup,\"ax\"\n" \
18048 "3: mov %3,%0\n" \
18049 @@ -353,8 +398,10 @@ do { \
18050 " jmp 2b\n" \
18051 ".previous\n" \
18052 _ASM_EXTABLE(1b, 3b) \
18053 - : "=r" (err), ltype(x) \
18054 - : "m" (__m(addr)), "i" (errret), "0" (err))
18055 + : "=r" (err), ltype (x) \
18056 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18057 + pax_close_userland(); \
18058 +} while (0)
18059
18060 #define __get_user_size_ex(x, ptr, size) \
18061 do { \
18062 @@ -378,7 +425,7 @@ do { \
18063 } while (0)
18064
18065 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18066 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18067 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18068 "2:\n" \
18069 _ASM_EXTABLE_EX(1b, 2b) \
18070 : ltype(x) : "m" (__m(addr)))
18071 @@ -395,13 +442,24 @@ do { \
18072 int __gu_err; \
18073 unsigned long __gu_val; \
18074 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18075 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18076 + (x) = (__typeof__(*(ptr)))__gu_val; \
18077 __gu_err; \
18078 })
18079
18080 /* FIXME: this hack is definitely wrong -AK */
18081 struct __large_struct { unsigned long buf[100]; };
18082 -#define __m(x) (*(struct __large_struct __user *)(x))
18083 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18084 +#define ____m(x) \
18085 +({ \
18086 + unsigned long ____x = (unsigned long)(x); \
18087 + if (____x < pax_user_shadow_base) \
18088 + ____x += pax_user_shadow_base; \
18089 + (typeof(x))____x; \
18090 +})
18091 +#else
18092 +#define ____m(x) (x)
18093 +#endif
18094 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18095
18096 /*
18097 * Tell gcc we read from memory instead of writing: this is because
18098 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18099 * aliasing issues.
18100 */
18101 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18102 +do { \
18103 + pax_open_userland(); \
18104 asm volatile(ASM_STAC "\n" \
18105 - "1: mov"itype" %"rtype"1,%2\n" \
18106 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18107 "2: " ASM_CLAC "\n" \
18108 ".section .fixup,\"ax\"\n" \
18109 "3: mov %3,%0\n" \
18110 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18111 ".previous\n" \
18112 _ASM_EXTABLE(1b, 3b) \
18113 : "=r"(err) \
18114 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18115 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18116 + pax_close_userland(); \
18117 +} while (0)
18118
18119 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18120 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18121 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18122 "2:\n" \
18123 _ASM_EXTABLE_EX(1b, 2b) \
18124 : : ltype(x), "m" (__m(addr)))
18125 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18126 */
18127 #define uaccess_try do { \
18128 current_thread_info()->uaccess_err = 0; \
18129 + pax_open_userland(); \
18130 stac(); \
18131 barrier();
18132
18133 #define uaccess_catch(err) \
18134 clac(); \
18135 + pax_close_userland(); \
18136 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18137 } while (0)
18138
18139 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18140 * On error, the variable @x is set to zero.
18141 */
18142
18143 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18144 +#define __get_user(x, ptr) get_user((x), (ptr))
18145 +#else
18146 #define __get_user(x, ptr) \
18147 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18148 +#endif
18149
18150 /**
18151 * __put_user: - Write a simple value into user space, with less checking.
18152 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18153 * Returns zero on success, or -EFAULT on error.
18154 */
18155
18156 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18157 +#define __put_user(x, ptr) put_user((x), (ptr))
18158 +#else
18159 #define __put_user(x, ptr) \
18160 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18161 +#endif
18162
18163 #define __get_user_unaligned __get_user
18164 #define __put_user_unaligned __put_user
18165 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18166 #define get_user_ex(x, ptr) do { \
18167 unsigned long __gue_val; \
18168 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18169 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18170 + (x) = (__typeof__(*(ptr)))__gue_val; \
18171 } while (0)
18172
18173 #define put_user_try uaccess_try
18174 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18175 extern __must_check long strlen_user(const char __user *str);
18176 extern __must_check long strnlen_user(const char __user *str, long n);
18177
18178 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18179 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18180 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18181 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18182
18183 /*
18184 * movsl can be slow when source and dest are not both 8-byte aligned
18185 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18186 index 7f760a9..04b1c65 100644
18187 --- a/arch/x86/include/asm/uaccess_32.h
18188 +++ b/arch/x86/include/asm/uaccess_32.h
18189 @@ -11,15 +11,15 @@
18190 #include <asm/page.h>
18191
18192 unsigned long __must_check __copy_to_user_ll
18193 - (void __user *to, const void *from, unsigned long n);
18194 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18195 unsigned long __must_check __copy_from_user_ll
18196 - (void *to, const void __user *from, unsigned long n);
18197 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18198 unsigned long __must_check __copy_from_user_ll_nozero
18199 - (void *to, const void __user *from, unsigned long n);
18200 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18201 unsigned long __must_check __copy_from_user_ll_nocache
18202 - (void *to, const void __user *from, unsigned long n);
18203 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18204 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18205 - (void *to, const void __user *from, unsigned long n);
18206 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18207
18208 /**
18209 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18210 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18211 static __always_inline unsigned long __must_check
18212 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18213 {
18214 + if ((long)n < 0)
18215 + return n;
18216 +
18217 + check_object_size(from, n, true);
18218 +
18219 if (__builtin_constant_p(n)) {
18220 unsigned long ret;
18221
18222 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18223 __copy_to_user(void __user *to, const void *from, unsigned long n)
18224 {
18225 might_fault();
18226 +
18227 return __copy_to_user_inatomic(to, from, n);
18228 }
18229
18230 static __always_inline unsigned long
18231 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18232 {
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 /* Avoid zeroing the tail if the copy fails..
18237 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18238 * but as the zeroing behaviour is only significant when n is not
18239 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18240 __copy_from_user(void *to, const void __user *from, unsigned long n)
18241 {
18242 might_fault();
18243 +
18244 + if ((long)n < 0)
18245 + return n;
18246 +
18247 + check_object_size(to, n, false);
18248 +
18249 if (__builtin_constant_p(n)) {
18250 unsigned long ret;
18251
18252 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18253 const void __user *from, unsigned long n)
18254 {
18255 might_fault();
18256 +
18257 + if ((long)n < 0)
18258 + return n;
18259 +
18260 if (__builtin_constant_p(n)) {
18261 unsigned long ret;
18262
18263 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18264 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18265 unsigned long n)
18266 {
18267 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18268 + if ((long)n < 0)
18269 + return n;
18270 +
18271 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18272 }
18273
18274 -unsigned long __must_check copy_to_user(void __user *to,
18275 - const void *from, unsigned long n);
18276 -unsigned long __must_check _copy_from_user(void *to,
18277 - const void __user *from,
18278 - unsigned long n);
18279 -
18280 +extern void copy_to_user_overflow(void)
18281 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18282 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18283 +#else
18284 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18285 +#endif
18286 +;
18287
18288 extern void copy_from_user_overflow(void)
18289 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18290 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18291 #endif
18292 ;
18293
18294 -static inline unsigned long __must_check copy_from_user(void *to,
18295 - const void __user *from,
18296 - unsigned long n)
18297 +/**
18298 + * copy_to_user: - Copy a block of data into user space.
18299 + * @to: Destination address, in user space.
18300 + * @from: Source address, in kernel space.
18301 + * @n: Number of bytes to copy.
18302 + *
18303 + * Context: User context only. This function may sleep.
18304 + *
18305 + * Copy data from kernel space to user space.
18306 + *
18307 + * Returns number of bytes that could not be copied.
18308 + * On success, this will be zero.
18309 + */
18310 +static inline unsigned long __must_check
18311 +copy_to_user(void __user *to, const void *from, unsigned long n)
18312 {
18313 - int sz = __compiletime_object_size(to);
18314 + size_t sz = __compiletime_object_size(from);
18315
18316 - if (likely(sz == -1 || sz >= n))
18317 - n = _copy_from_user(to, from, n);
18318 - else
18319 + if (unlikely(sz != (size_t)-1 && sz < n))
18320 + copy_to_user_overflow();
18321 + else if (access_ok(VERIFY_WRITE, to, n))
18322 + n = __copy_to_user(to, from, n);
18323 + return n;
18324 +}
18325 +
18326 +/**
18327 + * copy_from_user: - Copy a block of data from user space.
18328 + * @to: Destination address, in kernel space.
18329 + * @from: Source address, in user space.
18330 + * @n: Number of bytes to copy.
18331 + *
18332 + * Context: User context only. This function may sleep.
18333 + *
18334 + * Copy data from user space to kernel space.
18335 + *
18336 + * Returns number of bytes that could not be copied.
18337 + * On success, this will be zero.
18338 + *
18339 + * If some data could not be copied, this function will pad the copied
18340 + * data to the requested size using zero bytes.
18341 + */
18342 +static inline unsigned long __must_check
18343 +copy_from_user(void *to, const void __user *from, unsigned long n)
18344 +{
18345 + size_t sz = __compiletime_object_size(to);
18346 +
18347 + check_object_size(to, n, false);
18348 +
18349 + if (unlikely(sz != (size_t)-1 && sz < n))
18350 copy_from_user_overflow();
18351 -
18352 + else if (access_ok(VERIFY_READ, from, n))
18353 + n = __copy_from_user(to, from, n);
18354 + else if ((long)n > 0)
18355 + memset(to, 0, n);
18356 return n;
18357 }
18358
18359 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18360 index 4f7923d..d3526c1 100644
18361 --- a/arch/x86/include/asm/uaccess_64.h
18362 +++ b/arch/x86/include/asm/uaccess_64.h
18363 @@ -10,6 +10,9 @@
18364 #include <asm/alternative.h>
18365 #include <asm/cpufeature.h>
18366 #include <asm/page.h>
18367 +#include <asm/pgtable.h>
18368 +
18369 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18370
18371 /*
18372 * Copy To/From Userspace
18373 @@ -17,14 +20,14 @@
18374
18375 /* Handles exceptions in both to and from, but doesn't do access_ok */
18376 __must_check unsigned long
18377 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18378 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18379 __must_check unsigned long
18380 -copy_user_generic_string(void *to, const void *from, unsigned len);
18381 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18382 __must_check unsigned long
18383 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18384 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18385
18386 -static __always_inline __must_check unsigned long
18387 -copy_user_generic(void *to, const void *from, unsigned len)
18388 +static __always_inline __must_check __size_overflow(3) unsigned long
18389 +copy_user_generic(void *to, const void *from, unsigned long len)
18390 {
18391 unsigned ret;
18392
18393 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18394 return ret;
18395 }
18396
18397 +static __always_inline __must_check unsigned long
18398 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18399 +static __always_inline __must_check unsigned long
18400 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18401 __must_check unsigned long
18402 -_copy_to_user(void __user *to, const void *from, unsigned len);
18403 -__must_check unsigned long
18404 -_copy_from_user(void *to, const void __user *from, unsigned len);
18405 -__must_check unsigned long
18406 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18407 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18408 +
18409 +extern void copy_to_user_overflow(void)
18410 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18411 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18412 +#else
18413 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18414 +#endif
18415 +;
18416 +
18417 +extern void copy_from_user_overflow(void)
18418 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18419 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18420 +#else
18421 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18422 +#endif
18423 +;
18424
18425 static inline unsigned long __must_check copy_from_user(void *to,
18426 const void __user *from,
18427 unsigned long n)
18428 {
18429 - int sz = __compiletime_object_size(to);
18430 -
18431 might_fault();
18432 - if (likely(sz == -1 || sz >= n))
18433 - n = _copy_from_user(to, from, n);
18434 -#ifdef CONFIG_DEBUG_VM
18435 - else
18436 - WARN(1, "Buffer overflow detected!\n");
18437 -#endif
18438 +
18439 + check_object_size(to, n, false);
18440 +
18441 + if (access_ok(VERIFY_READ, from, n))
18442 + n = __copy_from_user(to, from, n);
18443 + else if (n < INT_MAX)
18444 + memset(to, 0, n);
18445 return n;
18446 }
18447
18448 static __always_inline __must_check
18449 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18450 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18451 {
18452 might_fault();
18453
18454 - return _copy_to_user(dst, src, size);
18455 + if (access_ok(VERIFY_WRITE, dst, size))
18456 + size = __copy_to_user(dst, src, size);
18457 + return size;
18458 }
18459
18460 static __always_inline __must_check
18461 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18462 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18463 {
18464 - int ret = 0;
18465 + size_t sz = __compiletime_object_size(dst);
18466 + unsigned ret = 0;
18467
18468 might_fault();
18469 +
18470 + if (size > INT_MAX)
18471 + return size;
18472 +
18473 + check_object_size(dst, size, false);
18474 +
18475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18476 + if (!__access_ok(VERIFY_READ, src, size))
18477 + return size;
18478 +#endif
18479 +
18480 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18481 + copy_from_user_overflow();
18482 + return size;
18483 + }
18484 +
18485 if (!__builtin_constant_p(size))
18486 - return copy_user_generic(dst, (__force void *)src, size);
18487 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18488 switch (size) {
18489 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18490 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18491 ret, "b", "b", "=q", 1);
18492 return ret;
18493 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18494 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18495 ret, "w", "w", "=r", 2);
18496 return ret;
18497 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18498 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18499 ret, "l", "k", "=r", 4);
18500 return ret;
18501 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18502 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18503 ret, "q", "", "=r", 8);
18504 return ret;
18505 case 10:
18506 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18507 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18508 ret, "q", "", "=r", 10);
18509 if (unlikely(ret))
18510 return ret;
18511 __get_user_asm(*(u16 *)(8 + (char *)dst),
18512 - (u16 __user *)(8 + (char __user *)src),
18513 + (const u16 __user *)(8 + (const char __user *)src),
18514 ret, "w", "w", "=r", 2);
18515 return ret;
18516 case 16:
18517 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18518 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18519 ret, "q", "", "=r", 16);
18520 if (unlikely(ret))
18521 return ret;
18522 __get_user_asm(*(u64 *)(8 + (char *)dst),
18523 - (u64 __user *)(8 + (char __user *)src),
18524 + (const u64 __user *)(8 + (const char __user *)src),
18525 ret, "q", "", "=r", 8);
18526 return ret;
18527 default:
18528 - return copy_user_generic(dst, (__force void *)src, size);
18529 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18530 }
18531 }
18532
18533 static __always_inline __must_check
18534 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18535 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18536 {
18537 - int ret = 0;
18538 + size_t sz = __compiletime_object_size(src);
18539 + unsigned ret = 0;
18540
18541 might_fault();
18542 +
18543 + if (size > INT_MAX)
18544 + return size;
18545 +
18546 + check_object_size(src, size, true);
18547 +
18548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18549 + if (!__access_ok(VERIFY_WRITE, dst, size))
18550 + return size;
18551 +#endif
18552 +
18553 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18554 + copy_to_user_overflow();
18555 + return size;
18556 + }
18557 +
18558 if (!__builtin_constant_p(size))
18559 - return copy_user_generic((__force void *)dst, src, size);
18560 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18561 switch (size) {
18562 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18563 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18564 ret, "b", "b", "iq", 1);
18565 return ret;
18566 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18567 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18568 ret, "w", "w", "ir", 2);
18569 return ret;
18570 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18571 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18572 ret, "l", "k", "ir", 4);
18573 return ret;
18574 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18575 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18576 ret, "q", "", "er", 8);
18577 return ret;
18578 case 10:
18579 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18580 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18581 ret, "q", "", "er", 10);
18582 if (unlikely(ret))
18583 return ret;
18584 asm("":::"memory");
18585 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18586 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18587 ret, "w", "w", "ir", 2);
18588 return ret;
18589 case 16:
18590 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18591 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18592 ret, "q", "", "er", 16);
18593 if (unlikely(ret))
18594 return ret;
18595 asm("":::"memory");
18596 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18597 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18598 ret, "q", "", "er", 8);
18599 return ret;
18600 default:
18601 - return copy_user_generic((__force void *)dst, src, size);
18602 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18603 }
18604 }
18605
18606 static __always_inline __must_check
18607 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18608 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18609 {
18610 - int ret = 0;
18611 + unsigned ret = 0;
18612
18613 might_fault();
18614 +
18615 + if (size > INT_MAX)
18616 + return size;
18617 +
18618 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18619 + if (!__access_ok(VERIFY_READ, src, size))
18620 + return size;
18621 + if (!__access_ok(VERIFY_WRITE, dst, size))
18622 + return size;
18623 +#endif
18624 +
18625 if (!__builtin_constant_p(size))
18626 - return copy_user_generic((__force void *)dst,
18627 - (__force void *)src, size);
18628 + return copy_user_generic((__force_kernel void *)____m(dst),
18629 + (__force_kernel const void *)____m(src), size);
18630 switch (size) {
18631 case 1: {
18632 u8 tmp;
18633 - __get_user_asm(tmp, (u8 __user *)src,
18634 + __get_user_asm(tmp, (const u8 __user *)src,
18635 ret, "b", "b", "=q", 1);
18636 if (likely(!ret))
18637 __put_user_asm(tmp, (u8 __user *)dst,
18638 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18639 }
18640 case 2: {
18641 u16 tmp;
18642 - __get_user_asm(tmp, (u16 __user *)src,
18643 + __get_user_asm(tmp, (const u16 __user *)src,
18644 ret, "w", "w", "=r", 2);
18645 if (likely(!ret))
18646 __put_user_asm(tmp, (u16 __user *)dst,
18647 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18648
18649 case 4: {
18650 u32 tmp;
18651 - __get_user_asm(tmp, (u32 __user *)src,
18652 + __get_user_asm(tmp, (const u32 __user *)src,
18653 ret, "l", "k", "=r", 4);
18654 if (likely(!ret))
18655 __put_user_asm(tmp, (u32 __user *)dst,
18656 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18657 }
18658 case 8: {
18659 u64 tmp;
18660 - __get_user_asm(tmp, (u64 __user *)src,
18661 + __get_user_asm(tmp, (const u64 __user *)src,
18662 ret, "q", "", "=r", 8);
18663 if (likely(!ret))
18664 __put_user_asm(tmp, (u64 __user *)dst,
18665 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18666 return ret;
18667 }
18668 default:
18669 - return copy_user_generic((__force void *)dst,
18670 - (__force void *)src, size);
18671 + return copy_user_generic((__force_kernel void *)____m(dst),
18672 + (__force_kernel const void *)____m(src), size);
18673 }
18674 }
18675
18676 -static __must_check __always_inline int
18677 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18678 +static __must_check __always_inline unsigned long
18679 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18680 {
18681 - return copy_user_generic(dst, (__force const void *)src, size);
18682 + if (size > INT_MAX)
18683 + return size;
18684 +
18685 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18686 + if (!__access_ok(VERIFY_READ, src, size))
18687 + return size;
18688 +#endif
18689 +
18690 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18691 }
18692
18693 -static __must_check __always_inline int
18694 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18695 +static __must_check __always_inline unsigned long
18696 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18697 {
18698 - return copy_user_generic((__force void *)dst, src, size);
18699 + if (size > INT_MAX)
18700 + return size;
18701 +
18702 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18703 + if (!__access_ok(VERIFY_WRITE, dst, size))
18704 + return size;
18705 +#endif
18706 +
18707 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18708 }
18709
18710 -extern long __copy_user_nocache(void *dst, const void __user *src,
18711 - unsigned size, int zerorest);
18712 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18713 + unsigned long size, int zerorest) __size_overflow(3);
18714
18715 -static inline int
18716 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18717 +static inline unsigned long
18718 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18719 {
18720 might_fault();
18721 +
18722 + if (size > INT_MAX)
18723 + return size;
18724 +
18725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18726 + if (!__access_ok(VERIFY_READ, src, size))
18727 + return size;
18728 +#endif
18729 +
18730 return __copy_user_nocache(dst, src, size, 1);
18731 }
18732
18733 -static inline int
18734 +static inline unsigned long
18735 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18736 - unsigned size)
18737 + unsigned long size)
18738 {
18739 + if (size > INT_MAX)
18740 + return size;
18741 +
18742 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18743 + if (!__access_ok(VERIFY_READ, src, size))
18744 + return size;
18745 +#endif
18746 +
18747 return __copy_user_nocache(dst, src, size, 0);
18748 }
18749
18750 unsigned long
18751 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18752 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18753
18754 #endif /* _ASM_X86_UACCESS_64_H */
18755 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18756 index 5b238981..77fdd78 100644
18757 --- a/arch/x86/include/asm/word-at-a-time.h
18758 +++ b/arch/x86/include/asm/word-at-a-time.h
18759 @@ -11,7 +11,7 @@
18760 * and shift, for example.
18761 */
18762 struct word_at_a_time {
18763 - const unsigned long one_bits, high_bits;
18764 + unsigned long one_bits, high_bits;
18765 };
18766
18767 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18768 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18769 index 828a156..650e625 100644
18770 --- a/arch/x86/include/asm/x86_init.h
18771 +++ b/arch/x86/include/asm/x86_init.h
18772 @@ -129,7 +129,7 @@ struct x86_init_ops {
18773 struct x86_init_timers timers;
18774 struct x86_init_iommu iommu;
18775 struct x86_init_pci pci;
18776 -};
18777 +} __no_const;
18778
18779 /**
18780 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18781 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18782 void (*setup_percpu_clockev)(void);
18783 void (*early_percpu_clock_init)(void);
18784 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18785 -};
18786 +} __no_const;
18787
18788 struct timespec;
18789
18790 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18791 void (*save_sched_clock_state)(void);
18792 void (*restore_sched_clock_state)(void);
18793 void (*apic_post_init)(void);
18794 -};
18795 +} __no_const;
18796
18797 struct pci_dev;
18798 struct msi_msg;
18799 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18800 void (*teardown_msi_irqs)(struct pci_dev *dev);
18801 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18802 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18803 -};
18804 +} __no_const;
18805
18806 struct IO_APIC_route_entry;
18807 struct io_apic_irq_attr;
18808 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18809 unsigned int destination, int vector,
18810 struct io_apic_irq_attr *attr);
18811 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18812 -};
18813 +} __no_const;
18814
18815 extern struct x86_init_ops x86_init;
18816 extern struct x86_cpuinit_ops x86_cpuinit;
18817 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18818 index 0415cda..3b22adc 100644
18819 --- a/arch/x86/include/asm/xsave.h
18820 +++ b/arch/x86/include/asm/xsave.h
18821 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18822 if (unlikely(err))
18823 return -EFAULT;
18824
18825 + pax_open_userland();
18826 __asm__ __volatile__(ASM_STAC "\n"
18827 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18828 + "1:"
18829 + __copyuser_seg
18830 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18831 "2: " ASM_CLAC "\n"
18832 ".section .fixup,\"ax\"\n"
18833 "3: movl $-1,%[err]\n"
18834 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18835 : [err] "=r" (err)
18836 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18837 : "memory");
18838 + pax_close_userland();
18839 return err;
18840 }
18841
18842 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18843 {
18844 int err;
18845 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18846 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18847 u32 lmask = mask;
18848 u32 hmask = mask >> 32;
18849
18850 + pax_open_userland();
18851 __asm__ __volatile__(ASM_STAC "\n"
18852 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18853 + "1:"
18854 + __copyuser_seg
18855 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18856 "2: " ASM_CLAC "\n"
18857 ".section .fixup,\"ax\"\n"
18858 "3: movl $-1,%[err]\n"
18859 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18860 : [err] "=r" (err)
18861 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18862 : "memory"); /* memory required? */
18863 + pax_close_userland();
18864 return err;
18865 }
18866
18867 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18868 index bbae024..e1528f9 100644
18869 --- a/arch/x86/include/uapi/asm/e820.h
18870 +++ b/arch/x86/include/uapi/asm/e820.h
18871 @@ -63,7 +63,7 @@ struct e820map {
18872 #define ISA_START_ADDRESS 0xa0000
18873 #define ISA_END_ADDRESS 0x100000
18874
18875 -#define BIOS_BEGIN 0x000a0000
18876 +#define BIOS_BEGIN 0x000c0000
18877 #define BIOS_END 0x00100000
18878
18879 #define BIOS_ROM_BASE 0xffe00000
18880 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18881 index 88d99ea..9fc7e17 100644
18882 --- a/arch/x86/kernel/Makefile
18883 +++ b/arch/x86/kernel/Makefile
18884 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18885 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18886 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18887 obj-y += probe_roms.o
18888 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18889 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18890 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18891 obj-y += syscall_$(BITS).o
18892 obj-$(CONFIG_X86_64) += vsyscall_64.o
18893 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18894 index 2627a81..cd8325e 100644
18895 --- a/arch/x86/kernel/acpi/boot.c
18896 +++ b/arch/x86/kernel/acpi/boot.c
18897 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18898 * If your system is blacklisted here, but you find that acpi=force
18899 * works for you, please contact linux-acpi@vger.kernel.org
18900 */
18901 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18902 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18903 /*
18904 * Boxes that need ACPI disabled
18905 */
18906 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18907 };
18908
18909 /* second table for DMI checks that should run after early-quirks */
18910 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18911 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18912 /*
18913 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18914 * which includes some code which overrides all temperature
18915 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18916 index 3312010..a65ca7b 100644
18917 --- a/arch/x86/kernel/acpi/sleep.c
18918 +++ b/arch/x86/kernel/acpi/sleep.c
18919 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18920 #else /* CONFIG_64BIT */
18921 #ifdef CONFIG_SMP
18922 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18923 +
18924 + pax_open_kernel();
18925 early_gdt_descr.address =
18926 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18927 + pax_close_kernel();
18928 +
18929 initial_gs = per_cpu_offset(smp_processor_id());
18930 #endif
18931 initial_code = (unsigned long)wakeup_long64;
18932 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18933 index d1daa66..59fecba 100644
18934 --- a/arch/x86/kernel/acpi/wakeup_32.S
18935 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18936 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18937 # and restore the stack ... but you need gdt for this to work
18938 movl saved_context_esp, %esp
18939
18940 - movl %cs:saved_magic, %eax
18941 - cmpl $0x12345678, %eax
18942 + cmpl $0x12345678, saved_magic
18943 jne bogus_magic
18944
18945 # jump to place where we left off
18946 - movl saved_eip, %eax
18947 - jmp *%eax
18948 + jmp *(saved_eip)
18949
18950 bogus_magic:
18951 jmp bogus_magic
18952 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18953 index c15cf9a..0e63558 100644
18954 --- a/arch/x86/kernel/alternative.c
18955 +++ b/arch/x86/kernel/alternative.c
18956 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18957 */
18958 for (a = start; a < end; a++) {
18959 instr = (u8 *)&a->instr_offset + a->instr_offset;
18960 +
18961 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18962 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18963 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18964 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18965 +#endif
18966 +
18967 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18968 BUG_ON(a->replacementlen > a->instrlen);
18969 BUG_ON(a->instrlen > sizeof(insnbuf));
18970 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18971 for (poff = start; poff < end; poff++) {
18972 u8 *ptr = (u8 *)poff + *poff;
18973
18974 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18975 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18976 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18977 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18978 +#endif
18979 +
18980 if (!*poff || ptr < text || ptr >= text_end)
18981 continue;
18982 /* turn DS segment override prefix into lock prefix */
18983 - if (*ptr == 0x3e)
18984 + if (*ktla_ktva(ptr) == 0x3e)
18985 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18986 }
18987 mutex_unlock(&text_mutex);
18988 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18989 for (poff = start; poff < end; poff++) {
18990 u8 *ptr = (u8 *)poff + *poff;
18991
18992 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18993 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18994 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18995 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18996 +#endif
18997 +
18998 if (!*poff || ptr < text || ptr >= text_end)
18999 continue;
19000 /* turn lock prefix into DS segment override prefix */
19001 - if (*ptr == 0xf0)
19002 + if (*ktla_ktva(ptr) == 0xf0)
19003 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19004 }
19005 mutex_unlock(&text_mutex);
19006 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19007
19008 BUG_ON(p->len > MAX_PATCH_LEN);
19009 /* prep the buffer with the original instructions */
19010 - memcpy(insnbuf, p->instr, p->len);
19011 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19012 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19013 (unsigned long)p->instr, p->len);
19014
19015 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19016 if (!uniproc_patched || num_possible_cpus() == 1)
19017 free_init_pages("SMP alternatives",
19018 (unsigned long)__smp_locks,
19019 - (unsigned long)__smp_locks_end);
19020 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19021 #endif
19022
19023 apply_paravirt(__parainstructions, __parainstructions_end);
19024 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19025 * instructions. And on the local CPU you need to be protected again NMI or MCE
19026 * handlers seeing an inconsistent instruction while you patch.
19027 */
19028 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19029 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19030 size_t len)
19031 {
19032 unsigned long flags;
19033 local_irq_save(flags);
19034 - memcpy(addr, opcode, len);
19035 +
19036 + pax_open_kernel();
19037 + memcpy(ktla_ktva(addr), opcode, len);
19038 sync_core();
19039 + pax_close_kernel();
19040 +
19041 local_irq_restore(flags);
19042 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19043 that causes hangs on some VIA CPUs. */
19044 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19045 */
19046 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19047 {
19048 - unsigned long flags;
19049 - char *vaddr;
19050 + unsigned char *vaddr = ktla_ktva(addr);
19051 struct page *pages[2];
19052 - int i;
19053 + size_t i;
19054
19055 if (!core_kernel_text((unsigned long)addr)) {
19056 - pages[0] = vmalloc_to_page(addr);
19057 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19058 + pages[0] = vmalloc_to_page(vaddr);
19059 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19060 } else {
19061 - pages[0] = virt_to_page(addr);
19062 + pages[0] = virt_to_page(vaddr);
19063 WARN_ON(!PageReserved(pages[0]));
19064 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19065 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19066 }
19067 BUG_ON(!pages[0]);
19068 - local_irq_save(flags);
19069 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19070 - if (pages[1])
19071 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19072 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19073 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19074 - clear_fixmap(FIX_TEXT_POKE0);
19075 - if (pages[1])
19076 - clear_fixmap(FIX_TEXT_POKE1);
19077 - local_flush_tlb();
19078 - sync_core();
19079 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19080 - that causes hangs on some VIA CPUs. */
19081 + text_poke_early(addr, opcode, len);
19082 for (i = 0; i < len; i++)
19083 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19084 - local_irq_restore(flags);
19085 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19086 return addr;
19087 }
19088
19089 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19090 index eca89c5..d566b78 100644
19091 --- a/arch/x86/kernel/apic/apic.c
19092 +++ b/arch/x86/kernel/apic/apic.c
19093 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19094 /*
19095 * Debug level, exported for io_apic.c
19096 */
19097 -unsigned int apic_verbosity;
19098 +int apic_verbosity;
19099
19100 int pic_mode;
19101
19102 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19103 apic_write(APIC_ESR, 0);
19104 v1 = apic_read(APIC_ESR);
19105 ack_APIC_irq();
19106 - atomic_inc(&irq_err_count);
19107 + atomic_inc_unchecked(&irq_err_count);
19108
19109 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19110 smp_processor_id(), v0 , v1);
19111 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19112 index 00c77cf..2dc6a2d 100644
19113 --- a/arch/x86/kernel/apic/apic_flat_64.c
19114 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19115 @@ -157,7 +157,7 @@ static int flat_probe(void)
19116 return 1;
19117 }
19118
19119 -static struct apic apic_flat = {
19120 +static struct apic apic_flat __read_only = {
19121 .name = "flat",
19122 .probe = flat_probe,
19123 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19124 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19125 return 0;
19126 }
19127
19128 -static struct apic apic_physflat = {
19129 +static struct apic apic_physflat __read_only = {
19130
19131 .name = "physical flat",
19132 .probe = physflat_probe,
19133 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19134 index e145f28..2752888 100644
19135 --- a/arch/x86/kernel/apic/apic_noop.c
19136 +++ b/arch/x86/kernel/apic/apic_noop.c
19137 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19138 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19139 }
19140
19141 -struct apic apic_noop = {
19142 +struct apic apic_noop __read_only = {
19143 .name = "noop",
19144 .probe = noop_probe,
19145 .acpi_madt_oem_check = NULL,
19146 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19147 index d50e364..543bee3 100644
19148 --- a/arch/x86/kernel/apic/bigsmp_32.c
19149 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19150 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19151 return dmi_bigsmp;
19152 }
19153
19154 -static struct apic apic_bigsmp = {
19155 +static struct apic apic_bigsmp __read_only = {
19156
19157 .name = "bigsmp",
19158 .probe = probe_bigsmp,
19159 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19160 index c552247..587a316 100644
19161 --- a/arch/x86/kernel/apic/es7000_32.c
19162 +++ b/arch/x86/kernel/apic/es7000_32.c
19163 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19164 return ret && es7000_apic_is_cluster();
19165 }
19166
19167 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19168 -static struct apic __refdata apic_es7000_cluster = {
19169 +static struct apic apic_es7000_cluster __read_only = {
19170
19171 .name = "es7000",
19172 .probe = probe_es7000,
19173 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19174 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19175 };
19176
19177 -static struct apic __refdata apic_es7000 = {
19178 +static struct apic apic_es7000 __read_only = {
19179
19180 .name = "es7000",
19181 .probe = probe_es7000,
19182 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19183 index 9ed796c..e930fe4 100644
19184 --- a/arch/x86/kernel/apic/io_apic.c
19185 +++ b/arch/x86/kernel/apic/io_apic.c
19186 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19187 }
19188 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19189
19190 -void lock_vector_lock(void)
19191 +void lock_vector_lock(void) __acquires(vector_lock)
19192 {
19193 /* Used to the online set of cpus does not change
19194 * during assign_irq_vector.
19195 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19196 raw_spin_lock(&vector_lock);
19197 }
19198
19199 -void unlock_vector_lock(void)
19200 +void unlock_vector_lock(void) __releases(vector_lock)
19201 {
19202 raw_spin_unlock(&vector_lock);
19203 }
19204 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19205 ack_APIC_irq();
19206 }
19207
19208 -atomic_t irq_mis_count;
19209 +atomic_unchecked_t irq_mis_count;
19210
19211 #ifdef CONFIG_GENERIC_PENDING_IRQ
19212 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19213 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19214 * at the cpu.
19215 */
19216 if (!(v & (1 << (i & 0x1f)))) {
19217 - atomic_inc(&irq_mis_count);
19218 + atomic_inc_unchecked(&irq_mis_count);
19219
19220 eoi_ioapic_irq(irq, cfg);
19221 }
19222 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19223 index 1e42e8f..daacf44 100644
19224 --- a/arch/x86/kernel/apic/numaq_32.c
19225 +++ b/arch/x86/kernel/apic/numaq_32.c
19226 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19227 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19228 }
19229
19230 -/* Use __refdata to keep false positive warning calm. */
19231 -static struct apic __refdata apic_numaq = {
19232 +static struct apic apic_numaq __read_only = {
19233
19234 .name = "NUMAQ",
19235 .probe = probe_numaq,
19236 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19237 index eb35ef9..f184a21 100644
19238 --- a/arch/x86/kernel/apic/probe_32.c
19239 +++ b/arch/x86/kernel/apic/probe_32.c
19240 @@ -72,7 +72,7 @@ static int probe_default(void)
19241 return 1;
19242 }
19243
19244 -static struct apic apic_default = {
19245 +static struct apic apic_default __read_only = {
19246
19247 .name = "default",
19248 .probe = probe_default,
19249 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19250 index 77c95c0..434f8a4 100644
19251 --- a/arch/x86/kernel/apic/summit_32.c
19252 +++ b/arch/x86/kernel/apic/summit_32.c
19253 @@ -486,7 +486,7 @@ void setup_summit(void)
19254 }
19255 #endif
19256
19257 -static struct apic apic_summit = {
19258 +static struct apic apic_summit __read_only = {
19259
19260 .name = "summit",
19261 .probe = probe_summit,
19262 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19263 index 140e29d..d88bc95 100644
19264 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19265 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19266 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19267 return notifier_from_errno(err);
19268 }
19269
19270 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19271 +static struct notifier_block x2apic_cpu_notifier = {
19272 .notifier_call = update_clusterinfo,
19273 };
19274
19275 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19276 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19277 }
19278
19279 -static struct apic apic_x2apic_cluster = {
19280 +static struct apic apic_x2apic_cluster __read_only = {
19281
19282 .name = "cluster x2apic",
19283 .probe = x2apic_cluster_probe,
19284 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19285 index 562a76d..a003c0f 100644
19286 --- a/arch/x86/kernel/apic/x2apic_phys.c
19287 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19288 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19289 return apic == &apic_x2apic_phys;
19290 }
19291
19292 -static struct apic apic_x2apic_phys = {
19293 +static struct apic apic_x2apic_phys __read_only = {
19294
19295 .name = "physical x2apic",
19296 .probe = x2apic_phys_probe,
19297 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19298 index 1191ac1..2335fa4 100644
19299 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19300 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19301 @@ -357,7 +357,7 @@ static int uv_probe(void)
19302 return apic == &apic_x2apic_uv_x;
19303 }
19304
19305 -static struct apic __refdata apic_x2apic_uv_x = {
19306 +static struct apic apic_x2apic_uv_x __read_only = {
19307
19308 .name = "UV large system",
19309 .probe = uv_probe,
19310 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19311 index 53a4e27..038760a 100644
19312 --- a/arch/x86/kernel/apm_32.c
19313 +++ b/arch/x86/kernel/apm_32.c
19314 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19315 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19316 * even though they are called in protected mode.
19317 */
19318 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19319 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19320 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19321
19322 static const char driver_version[] = "1.16ac"; /* no spaces */
19323 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19324 BUG_ON(cpu != 0);
19325 gdt = get_cpu_gdt_table(cpu);
19326 save_desc_40 = gdt[0x40 / 8];
19327 +
19328 + pax_open_kernel();
19329 gdt[0x40 / 8] = bad_bios_desc;
19330 + pax_close_kernel();
19331
19332 apm_irq_save(flags);
19333 APM_DO_SAVE_SEGS;
19334 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19335 &call->esi);
19336 APM_DO_RESTORE_SEGS;
19337 apm_irq_restore(flags);
19338 +
19339 + pax_open_kernel();
19340 gdt[0x40 / 8] = save_desc_40;
19341 + pax_close_kernel();
19342 +
19343 put_cpu();
19344
19345 return call->eax & 0xff;
19346 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19347 BUG_ON(cpu != 0);
19348 gdt = get_cpu_gdt_table(cpu);
19349 save_desc_40 = gdt[0x40 / 8];
19350 +
19351 + pax_open_kernel();
19352 gdt[0x40 / 8] = bad_bios_desc;
19353 + pax_close_kernel();
19354
19355 apm_irq_save(flags);
19356 APM_DO_SAVE_SEGS;
19357 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19358 &call->eax);
19359 APM_DO_RESTORE_SEGS;
19360 apm_irq_restore(flags);
19361 +
19362 + pax_open_kernel();
19363 gdt[0x40 / 8] = save_desc_40;
19364 + pax_close_kernel();
19365 +
19366 put_cpu();
19367 return error;
19368 }
19369 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19370 * code to that CPU.
19371 */
19372 gdt = get_cpu_gdt_table(0);
19373 +
19374 + pax_open_kernel();
19375 set_desc_base(&gdt[APM_CS >> 3],
19376 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19377 set_desc_base(&gdt[APM_CS_16 >> 3],
19378 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19379 set_desc_base(&gdt[APM_DS >> 3],
19380 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19381 + pax_close_kernel();
19382
19383 proc_create("apm", 0, NULL, &apm_file_ops);
19384
19385 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19386 index 2861082..6d4718e 100644
19387 --- a/arch/x86/kernel/asm-offsets.c
19388 +++ b/arch/x86/kernel/asm-offsets.c
19389 @@ -33,6 +33,8 @@ void common(void) {
19390 OFFSET(TI_status, thread_info, status);
19391 OFFSET(TI_addr_limit, thread_info, addr_limit);
19392 OFFSET(TI_preempt_count, thread_info, preempt_count);
19393 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19394 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19395
19396 BLANK();
19397 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19398 @@ -53,8 +55,26 @@ void common(void) {
19399 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19400 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19401 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19402 +
19403 +#ifdef CONFIG_PAX_KERNEXEC
19404 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19405 #endif
19406
19407 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19408 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19409 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19410 +#ifdef CONFIG_X86_64
19411 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19412 +#endif
19413 +#endif
19414 +
19415 +#endif
19416 +
19417 + BLANK();
19418 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19419 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19420 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19421 +
19422 #ifdef CONFIG_XEN
19423 BLANK();
19424 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19425 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19426 index e7c798b..2b2019b 100644
19427 --- a/arch/x86/kernel/asm-offsets_64.c
19428 +++ b/arch/x86/kernel/asm-offsets_64.c
19429 @@ -77,6 +77,7 @@ int main(void)
19430 BLANK();
19431 #undef ENTRY
19432
19433 + DEFINE(TSS_size, sizeof(struct tss_struct));
19434 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19435 BLANK();
19436
19437 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19438 index 47b56a7..efc2bc6 100644
19439 --- a/arch/x86/kernel/cpu/Makefile
19440 +++ b/arch/x86/kernel/cpu/Makefile
19441 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19442 CFLAGS_REMOVE_perf_event.o = -pg
19443 endif
19444
19445 -# Make sure load_percpu_segment has no stackprotector
19446 -nostackp := $(call cc-option, -fno-stack-protector)
19447 -CFLAGS_common.o := $(nostackp)
19448 -
19449 obj-y := intel_cacheinfo.o scattered.o topology.o
19450 obj-y += proc.o capflags.o powerflags.o common.o
19451 obj-y += rdrand.o
19452 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19453 index 08a0890..e557865 100644
19454 --- a/arch/x86/kernel/cpu/amd.c
19455 +++ b/arch/x86/kernel/cpu/amd.c
19456 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19457 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19458 {
19459 /* AMD errata T13 (order #21922) */
19460 - if ((c->x86 == 6)) {
19461 + if (c->x86 == 6) {
19462 /* Duron Rev A0 */
19463 if (c->x86_model == 3 && c->x86_mask == 0)
19464 size = 64;
19465 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19466 index 25eb274..3a92d93 100644
19467 --- a/arch/x86/kernel/cpu/common.c
19468 +++ b/arch/x86/kernel/cpu/common.c
19469 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19470
19471 static const struct cpu_dev *this_cpu = &default_cpu;
19472
19473 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19474 -#ifdef CONFIG_X86_64
19475 - /*
19476 - * We need valid kernel segments for data and code in long mode too
19477 - * IRET will check the segment types kkeil 2000/10/28
19478 - * Also sysret mandates a special GDT layout
19479 - *
19480 - * TLS descriptors are currently at a different place compared to i386.
19481 - * Hopefully nobody expects them at a fixed place (Wine?)
19482 - */
19483 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19484 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19485 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19486 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19487 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19488 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19489 -#else
19490 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19491 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19492 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19493 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19494 - /*
19495 - * Segments used for calling PnP BIOS have byte granularity.
19496 - * They code segments and data segments have fixed 64k limits,
19497 - * the transfer segment sizes are set at run time.
19498 - */
19499 - /* 32-bit code */
19500 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19501 - /* 16-bit code */
19502 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19503 - /* 16-bit data */
19504 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19505 - /* 16-bit data */
19506 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19507 - /* 16-bit data */
19508 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19509 - /*
19510 - * The APM segments have byte granularity and their bases
19511 - * are set at run time. All have 64k limits.
19512 - */
19513 - /* 32-bit code */
19514 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19515 - /* 16-bit code */
19516 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19517 - /* data */
19518 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19519 -
19520 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19521 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19522 - GDT_STACK_CANARY_INIT
19523 -#endif
19524 -} };
19525 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19526 -
19527 static int __init x86_xsave_setup(char *s)
19528 {
19529 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19530 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19531 set_in_cr4(X86_CR4_SMAP);
19532 }
19533
19534 +#ifdef CONFIG_X86_64
19535 +static __init int setup_disable_pcid(char *arg)
19536 +{
19537 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19538 +
19539 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19540 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19541 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19542 +#endif
19543 +
19544 + return 1;
19545 +}
19546 +__setup("nopcid", setup_disable_pcid);
19547 +
19548 +static void setup_pcid(struct cpuinfo_x86 *c)
19549 +{
19550 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19551 +
19552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19553 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19554 + pax_open_kernel();
19555 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19556 + pax_close_kernel();
19557 + printk("PAX: slow and weak UDEREF enabled\n");
19558 + } else
19559 + printk("PAX: UDEREF disabled\n");
19560 +#endif
19561 +
19562 + return;
19563 + }
19564 +
19565 + printk("PAX: PCID detected\n");
19566 + set_in_cr4(X86_CR4_PCIDE);
19567 +
19568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19569 + pax_open_kernel();
19570 + clone_pgd_mask = ~(pgdval_t)0UL;
19571 + pax_close_kernel();
19572 + if (pax_user_shadow_base)
19573 + printk("PAX: weak UDEREF enabled\n");
19574 + else {
19575 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19576 + printk("PAX: strong UDEREF enabled\n");
19577 + }
19578 +#endif
19579 +
19580 + if (cpu_has(c, X86_FEATURE_INVPCID))
19581 + printk("PAX: INVPCID detected\n");
19582 +}
19583 +#endif
19584 +
19585 /*
19586 * Some CPU features depend on higher CPUID levels, which may not always
19587 * be available due to CPUID level capping or broken virtualization
19588 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19589 {
19590 struct desc_ptr gdt_descr;
19591
19592 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19593 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19594 gdt_descr.size = GDT_SIZE - 1;
19595 load_gdt(&gdt_descr);
19596 /* Reload the per-cpu base */
19597 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19598 setup_smep(c);
19599 setup_smap(c);
19600
19601 +#ifdef CONFIG_X86_64
19602 + setup_pcid(c);
19603 +#endif
19604 +
19605 /*
19606 * The vendor-specific functions might have changed features.
19607 * Now we do "generic changes."
19608 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19609 /* Filter out anything that depends on CPUID levels we don't have */
19610 filter_cpuid_features(c, true);
19611
19612 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19613 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19614 +#endif
19615 +
19616 /* If the model name is still unset, do table lookup. */
19617 if (!c->x86_model_id[0]) {
19618 const char *p;
19619 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19620 }
19621 __setup("clearcpuid=", setup_disablecpuid);
19622
19623 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19624 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19625 +
19626 #ifdef CONFIG_X86_64
19627 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19628 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19629 - (unsigned long) debug_idt_table };
19630 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19631 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19632
19633 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19634 irq_stack_union) __aligned(PAGE_SIZE);
19635 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19636 EXPORT_PER_CPU_SYMBOL(current_task);
19637
19638 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19639 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19640 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19641 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19642
19643 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19644 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19645 load_ucode_ap();
19646
19647 cpu = stack_smp_processor_id();
19648 - t = &per_cpu(init_tss, cpu);
19649 + t = init_tss + cpu;
19650 oist = &per_cpu(orig_ist, cpu);
19651
19652 #ifdef CONFIG_NUMA
19653 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19654 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19655 barrier();
19656
19657 - x86_configure_nx();
19658 enable_x2apic();
19659
19660 /*
19661 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19662 {
19663 int cpu = smp_processor_id();
19664 struct task_struct *curr = current;
19665 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19666 + struct tss_struct *t = init_tss + cpu;
19667 struct thread_struct *thread = &curr->thread;
19668
19669 show_ucode_info_early();
19670 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19671 index 1414c90..1159406 100644
19672 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19673 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19674 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19675 };
19676
19677 #ifdef CONFIG_AMD_NB
19678 +static struct attribute *default_attrs_amd_nb[] = {
19679 + &type.attr,
19680 + &level.attr,
19681 + &coherency_line_size.attr,
19682 + &physical_line_partition.attr,
19683 + &ways_of_associativity.attr,
19684 + &number_of_sets.attr,
19685 + &size.attr,
19686 + &shared_cpu_map.attr,
19687 + &shared_cpu_list.attr,
19688 + NULL,
19689 + NULL,
19690 + NULL,
19691 + NULL
19692 +};
19693 +
19694 static struct attribute **amd_l3_attrs(void)
19695 {
19696 static struct attribute **attrs;
19697 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19698
19699 n = ARRAY_SIZE(default_attrs);
19700
19701 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19702 - n += 2;
19703 -
19704 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19705 - n += 1;
19706 -
19707 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19708 - if (attrs == NULL)
19709 - return attrs = default_attrs;
19710 -
19711 - for (n = 0; default_attrs[n]; n++)
19712 - attrs[n] = default_attrs[n];
19713 + attrs = default_attrs_amd_nb;
19714
19715 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19716 attrs[n++] = &cache_disable_0.attr;
19717 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19718 .default_attrs = default_attrs,
19719 };
19720
19721 +#ifdef CONFIG_AMD_NB
19722 +static struct kobj_type ktype_cache_amd_nb = {
19723 + .sysfs_ops = &sysfs_ops,
19724 + .default_attrs = default_attrs_amd_nb,
19725 +};
19726 +#endif
19727 +
19728 static struct kobj_type ktype_percpu_entry = {
19729 .sysfs_ops = &sysfs_ops,
19730 };
19731 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19732 return retval;
19733 }
19734
19735 +#ifdef CONFIG_AMD_NB
19736 + amd_l3_attrs();
19737 +#endif
19738 +
19739 for (i = 0; i < num_cache_leaves; i++) {
19740 + struct kobj_type *ktype;
19741 +
19742 this_object = INDEX_KOBJECT_PTR(cpu, i);
19743 this_object->cpu = cpu;
19744 this_object->index = i;
19745
19746 this_leaf = CPUID4_INFO_IDX(cpu, i);
19747
19748 - ktype_cache.default_attrs = default_attrs;
19749 + ktype = &ktype_cache;
19750 #ifdef CONFIG_AMD_NB
19751 if (this_leaf->base.nb)
19752 - ktype_cache.default_attrs = amd_l3_attrs();
19753 + ktype = &ktype_cache_amd_nb;
19754 #endif
19755 retval = kobject_init_and_add(&(this_object->kobj),
19756 - &ktype_cache,
19757 + ktype,
19758 per_cpu(ici_cache_kobject, cpu),
19759 "index%1lu", i);
19760 if (unlikely(retval)) {
19761 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19762 index 87a65c9..92fcce6 100644
19763 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19764 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19765 @@ -45,6 +45,7 @@
19766 #include <asm/processor.h>
19767 #include <asm/mce.h>
19768 #include <asm/msr.h>
19769 +#include <asm/local.h>
19770
19771 #include "mce-internal.h"
19772
19773 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19774 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19775 m->cs, m->ip);
19776
19777 - if (m->cs == __KERNEL_CS)
19778 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19779 print_symbol("{%s}", m->ip);
19780 pr_cont("\n");
19781 }
19782 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19783
19784 #define PANIC_TIMEOUT 5 /* 5 seconds */
19785
19786 -static atomic_t mce_paniced;
19787 +static atomic_unchecked_t mce_paniced;
19788
19789 static int fake_panic;
19790 -static atomic_t mce_fake_paniced;
19791 +static atomic_unchecked_t mce_fake_paniced;
19792
19793 /* Panic in progress. Enable interrupts and wait for final IPI */
19794 static void wait_for_panic(void)
19795 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19796 /*
19797 * Make sure only one CPU runs in machine check panic
19798 */
19799 - if (atomic_inc_return(&mce_paniced) > 1)
19800 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19801 wait_for_panic();
19802 barrier();
19803
19804 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19805 console_verbose();
19806 } else {
19807 /* Don't log too much for fake panic */
19808 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19809 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19810 return;
19811 }
19812 /* First print corrected ones that are still unlogged */
19813 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19814 if (!fake_panic) {
19815 if (panic_timeout == 0)
19816 panic_timeout = mca_cfg.panic_timeout;
19817 - panic(msg);
19818 + panic("%s", msg);
19819 } else
19820 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19821 }
19822 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19823 * might have been modified by someone else.
19824 */
19825 rmb();
19826 - if (atomic_read(&mce_paniced))
19827 + if (atomic_read_unchecked(&mce_paniced))
19828 wait_for_panic();
19829 if (!mca_cfg.monarch_timeout)
19830 goto out;
19831 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19832 }
19833
19834 /* Call the installed machine check handler for this CPU setup. */
19835 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19836 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19837 unexpected_machine_check;
19838
19839 /*
19840 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19841 return;
19842 }
19843
19844 + pax_open_kernel();
19845 machine_check_vector = do_machine_check;
19846 + pax_close_kernel();
19847
19848 __mcheck_cpu_init_generic();
19849 __mcheck_cpu_init_vendor(c);
19850 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19851 */
19852
19853 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19854 -static int mce_chrdev_open_count; /* #times opened */
19855 +static local_t mce_chrdev_open_count; /* #times opened */
19856 static int mce_chrdev_open_exclu; /* already open exclusive? */
19857
19858 static int mce_chrdev_open(struct inode *inode, struct file *file)
19859 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19860 spin_lock(&mce_chrdev_state_lock);
19861
19862 if (mce_chrdev_open_exclu ||
19863 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19864 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19865 spin_unlock(&mce_chrdev_state_lock);
19866
19867 return -EBUSY;
19868 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19869
19870 if (file->f_flags & O_EXCL)
19871 mce_chrdev_open_exclu = 1;
19872 - mce_chrdev_open_count++;
19873 + local_inc(&mce_chrdev_open_count);
19874
19875 spin_unlock(&mce_chrdev_state_lock);
19876
19877 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19878 {
19879 spin_lock(&mce_chrdev_state_lock);
19880
19881 - mce_chrdev_open_count--;
19882 + local_dec(&mce_chrdev_open_count);
19883 mce_chrdev_open_exclu = 0;
19884
19885 spin_unlock(&mce_chrdev_state_lock);
19886 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19887
19888 for (i = 0; i < mca_cfg.banks; i++) {
19889 struct mce_bank *b = &mce_banks[i];
19890 - struct device_attribute *a = &b->attr;
19891 + device_attribute_no_const *a = &b->attr;
19892
19893 sysfs_attr_init(&a->attr);
19894 a->attr.name = b->attrname;
19895 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19896 static void mce_reset(void)
19897 {
19898 cpu_missing = 0;
19899 - atomic_set(&mce_fake_paniced, 0);
19900 + atomic_set_unchecked(&mce_fake_paniced, 0);
19901 atomic_set(&mce_executing, 0);
19902 atomic_set(&mce_callin, 0);
19903 atomic_set(&global_nwo, 0);
19904 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19905 index 1c044b1..37a2a43 100644
19906 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19907 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19908 @@ -11,6 +11,7 @@
19909 #include <asm/processor.h>
19910 #include <asm/mce.h>
19911 #include <asm/msr.h>
19912 +#include <asm/pgtable.h>
19913
19914 /* By default disabled */
19915 int mce_p5_enabled __read_mostly;
19916 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19917 if (!cpu_has(c, X86_FEATURE_MCE))
19918 return;
19919
19920 + pax_open_kernel();
19921 machine_check_vector = pentium_machine_check;
19922 + pax_close_kernel();
19923 /* Make sure the vector pointer is visible before we enable MCEs: */
19924 wmb();
19925
19926 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19927 index e9a701a..35317d6 100644
19928 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19929 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19930 @@ -10,6 +10,7 @@
19931 #include <asm/processor.h>
19932 #include <asm/mce.h>
19933 #include <asm/msr.h>
19934 +#include <asm/pgtable.h>
19935
19936 /* Machine check handler for WinChip C6: */
19937 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19938 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19939 {
19940 u32 lo, hi;
19941
19942 + pax_open_kernel();
19943 machine_check_vector = winchip_machine_check;
19944 + pax_close_kernel();
19945 /* Make sure the vector pointer is visible before we enable MCEs: */
19946 wmb();
19947
19948 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19949 index f961de9..8a9d332 100644
19950 --- a/arch/x86/kernel/cpu/mtrr/main.c
19951 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19952 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19953 u64 size_or_mask, size_and_mask;
19954 static bool mtrr_aps_delayed_init;
19955
19956 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19957 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19958
19959 const struct mtrr_ops *mtrr_if;
19960
19961 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19962 index df5e41f..816c719 100644
19963 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19964 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19965 @@ -25,7 +25,7 @@ struct mtrr_ops {
19966 int (*validate_add_page)(unsigned long base, unsigned long size,
19967 unsigned int type);
19968 int (*have_wrcomb)(void);
19969 -};
19970 +} __do_const;
19971
19972 extern int generic_get_free_region(unsigned long base, unsigned long size,
19973 int replace_reg);
19974 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19975 index a7c7305..b9705ab 100644
19976 --- a/arch/x86/kernel/cpu/perf_event.c
19977 +++ b/arch/x86/kernel/cpu/perf_event.c
19978 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19979 pr_info("no hardware sampling interrupt available.\n");
19980 }
19981
19982 -static struct attribute_group x86_pmu_format_group = {
19983 +static attribute_group_no_const x86_pmu_format_group = {
19984 .name = "format",
19985 .attrs = NULL,
19986 };
19987 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19988 NULL,
19989 };
19990
19991 -static struct attribute_group x86_pmu_events_group = {
19992 +static attribute_group_no_const x86_pmu_events_group = {
19993 .name = "events",
19994 .attrs = events_attr,
19995 };
19996 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19997 if (idx > GDT_ENTRIES)
19998 return 0;
19999
20000 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20001 + desc = get_cpu_gdt_table(smp_processor_id());
20002 }
20003
20004 return get_desc_base(desc + idx);
20005 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20006 break;
20007
20008 perf_callchain_store(entry, frame.return_address);
20009 - fp = frame.next_frame;
20010 + fp = (const void __force_user *)frame.next_frame;
20011 }
20012 }
20013
20014 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20015 index 639d128..e92d7e5 100644
20016 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20017 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20018 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20019 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20020 {
20021 struct attribute **attrs;
20022 - struct attribute_group *attr_group;
20023 + attribute_group_no_const *attr_group;
20024 int i = 0, j;
20025
20026 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20027 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20028 index a45d8d4..8abd32c 100644
20029 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20030 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20031 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20032 * v2 and above have a perf capabilities MSR
20033 */
20034 if (version > 1) {
20035 - u64 capabilities;
20036 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20037
20038 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20039 - x86_pmu.intel_cap.capabilities = capabilities;
20040 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20041 + x86_pmu.intel_cap.capabilities = capabilities;
20042 }
20043
20044 intel_ds_init();
20045 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20046 index 1fb6c72..f5fa2a3 100644
20047 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20048 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20049 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20050 static int __init uncore_type_init(struct intel_uncore_type *type)
20051 {
20052 struct intel_uncore_pmu *pmus;
20053 - struct attribute_group *attr_group;
20054 + attribute_group_no_const *attr_group;
20055 struct attribute **attrs;
20056 int i, j;
20057
20058 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20059 index 47b3d00c..2cf1751 100644
20060 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20061 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20062 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20063 struct uncore_event_desc {
20064 struct kobj_attribute attr;
20065 const char *config;
20066 -};
20067 +} __do_const;
20068
20069 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20070 { \
20071 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20072 index 7d9481c..99c7e4b 100644
20073 --- a/arch/x86/kernel/cpuid.c
20074 +++ b/arch/x86/kernel/cpuid.c
20075 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20076 return notifier_from_errno(err);
20077 }
20078
20079 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20080 +static struct notifier_block cpuid_class_cpu_notifier =
20081 {
20082 .notifier_call = cpuid_class_cpu_callback,
20083 };
20084 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20085 index 74467fe..18793d5 100644
20086 --- a/arch/x86/kernel/crash.c
20087 +++ b/arch/x86/kernel/crash.c
20088 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20089 {
20090 #ifdef CONFIG_X86_32
20091 struct pt_regs fixed_regs;
20092 -#endif
20093
20094 -#ifdef CONFIG_X86_32
20095 - if (!user_mode_vm(regs)) {
20096 + if (!user_mode(regs)) {
20097 crash_fixup_ss_esp(&fixed_regs, regs);
20098 regs = &fixed_regs;
20099 }
20100 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20101 index afa64ad..dce67dd 100644
20102 --- a/arch/x86/kernel/crash_dump_64.c
20103 +++ b/arch/x86/kernel/crash_dump_64.c
20104 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20105 return -ENOMEM;
20106
20107 if (userbuf) {
20108 - if (copy_to_user(buf, vaddr + offset, csize)) {
20109 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20110 iounmap(vaddr);
20111 return -EFAULT;
20112 }
20113 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20114 index 5d3fe8d..02e1429 100644
20115 --- a/arch/x86/kernel/doublefault.c
20116 +++ b/arch/x86/kernel/doublefault.c
20117 @@ -13,7 +13,7 @@
20118
20119 #define DOUBLEFAULT_STACKSIZE (1024)
20120 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20121 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20122 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20123
20124 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20125
20126 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20127 unsigned long gdt, tss;
20128
20129 native_store_gdt(&gdt_desc);
20130 - gdt = gdt_desc.address;
20131 + gdt = (unsigned long)gdt_desc.address;
20132
20133 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20134
20135 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20136 /* 0x2 bit is always set */
20137 .flags = X86_EFLAGS_SF | 0x2,
20138 .sp = STACK_START,
20139 - .es = __USER_DS,
20140 + .es = __KERNEL_DS,
20141 .cs = __KERNEL_CS,
20142 .ss = __KERNEL_DS,
20143 - .ds = __USER_DS,
20144 + .ds = __KERNEL_DS,
20145 .fs = __KERNEL_PERCPU,
20146
20147 .__cr3 = __pa_nodebug(swapper_pg_dir),
20148 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20149 index deb6421..76bbc12 100644
20150 --- a/arch/x86/kernel/dumpstack.c
20151 +++ b/arch/x86/kernel/dumpstack.c
20152 @@ -2,6 +2,9 @@
20153 * Copyright (C) 1991, 1992 Linus Torvalds
20154 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20155 */
20156 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20157 +#define __INCLUDED_BY_HIDESYM 1
20158 +#endif
20159 #include <linux/kallsyms.h>
20160 #include <linux/kprobes.h>
20161 #include <linux/uaccess.h>
20162 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20163 static void
20164 print_ftrace_graph_addr(unsigned long addr, void *data,
20165 const struct stacktrace_ops *ops,
20166 - struct thread_info *tinfo, int *graph)
20167 + struct task_struct *task, int *graph)
20168 {
20169 - struct task_struct *task;
20170 unsigned long ret_addr;
20171 int index;
20172
20173 if (addr != (unsigned long)return_to_handler)
20174 return;
20175
20176 - task = tinfo->task;
20177 index = task->curr_ret_stack;
20178
20179 if (!task->ret_stack || index < *graph)
20180 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20181 static inline void
20182 print_ftrace_graph_addr(unsigned long addr, void *data,
20183 const struct stacktrace_ops *ops,
20184 - struct thread_info *tinfo, int *graph)
20185 + struct task_struct *task, int *graph)
20186 { }
20187 #endif
20188
20189 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20190 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20191 */
20192
20193 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20194 - void *p, unsigned int size, void *end)
20195 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20196 {
20197 - void *t = tinfo;
20198 if (end) {
20199 if (p < end && p >= (end-THREAD_SIZE))
20200 return 1;
20201 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20202 }
20203
20204 unsigned long
20205 -print_context_stack(struct thread_info *tinfo,
20206 +print_context_stack(struct task_struct *task, void *stack_start,
20207 unsigned long *stack, unsigned long bp,
20208 const struct stacktrace_ops *ops, void *data,
20209 unsigned long *end, int *graph)
20210 {
20211 struct stack_frame *frame = (struct stack_frame *)bp;
20212
20213 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20214 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20215 unsigned long addr;
20216
20217 addr = *stack;
20218 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20219 } else {
20220 ops->address(data, addr, 0);
20221 }
20222 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20223 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20224 }
20225 stack++;
20226 }
20227 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20228 EXPORT_SYMBOL_GPL(print_context_stack);
20229
20230 unsigned long
20231 -print_context_stack_bp(struct thread_info *tinfo,
20232 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20233 unsigned long *stack, unsigned long bp,
20234 const struct stacktrace_ops *ops, void *data,
20235 unsigned long *end, int *graph)
20236 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20237 struct stack_frame *frame = (struct stack_frame *)bp;
20238 unsigned long *ret_addr = &frame->return_address;
20239
20240 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20241 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20242 unsigned long addr = *ret_addr;
20243
20244 if (!__kernel_text_address(addr))
20245 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20246 ops->address(data, addr, 1);
20247 frame = frame->next_frame;
20248 ret_addr = &frame->return_address;
20249 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20250 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20251 }
20252
20253 return (unsigned long)frame;
20254 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20255 static void print_trace_address(void *data, unsigned long addr, int reliable)
20256 {
20257 touch_nmi_watchdog();
20258 - printk(data);
20259 + printk("%s", (char *)data);
20260 printk_address(addr, reliable);
20261 }
20262
20263 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20264 }
20265 EXPORT_SYMBOL_GPL(oops_begin);
20266
20267 +extern void gr_handle_kernel_exploit(void);
20268 +
20269 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20270 {
20271 if (regs && kexec_should_crash(current))
20272 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20273 panic("Fatal exception in interrupt");
20274 if (panic_on_oops)
20275 panic("Fatal exception");
20276 - do_exit(signr);
20277 +
20278 + gr_handle_kernel_exploit();
20279 +
20280 + do_group_exit(signr);
20281 }
20282
20283 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20284 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20285 print_modules();
20286 show_regs(regs);
20287 #ifdef CONFIG_X86_32
20288 - if (user_mode_vm(regs)) {
20289 + if (user_mode(regs)) {
20290 sp = regs->sp;
20291 ss = regs->ss & 0xffff;
20292 } else {
20293 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20294 unsigned long flags = oops_begin();
20295 int sig = SIGSEGV;
20296
20297 - if (!user_mode_vm(regs))
20298 + if (!user_mode(regs))
20299 report_bug(regs->ip, regs);
20300
20301 if (__die(str, regs, err))
20302 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20303 index f2a1770..540657f 100644
20304 --- a/arch/x86/kernel/dumpstack_32.c
20305 +++ b/arch/x86/kernel/dumpstack_32.c
20306 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20307 bp = stack_frame(task, regs);
20308
20309 for (;;) {
20310 - struct thread_info *context;
20311 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20312
20313 - context = (struct thread_info *)
20314 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20315 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20316 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20317
20318 - stack = (unsigned long *)context->previous_esp;
20319 - if (!stack)
20320 + if (stack_start == task_stack_page(task))
20321 break;
20322 + stack = *(unsigned long **)stack_start;
20323 if (ops->stack(data, "IRQ") < 0)
20324 break;
20325 touch_nmi_watchdog();
20326 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20327 int i;
20328
20329 show_regs_print_info(KERN_EMERG);
20330 - __show_regs(regs, !user_mode_vm(regs));
20331 + __show_regs(regs, !user_mode(regs));
20332
20333 /*
20334 * When in-kernel, we also print out the stack and code at the
20335 * time of the fault..
20336 */
20337 - if (!user_mode_vm(regs)) {
20338 + if (!user_mode(regs)) {
20339 unsigned int code_prologue = code_bytes * 43 / 64;
20340 unsigned int code_len = code_bytes;
20341 unsigned char c;
20342 u8 *ip;
20343 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20344
20345 pr_emerg("Stack:\n");
20346 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20347
20348 pr_emerg("Code:");
20349
20350 - ip = (u8 *)regs->ip - code_prologue;
20351 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20352 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20353 /* try starting at IP */
20354 - ip = (u8 *)regs->ip;
20355 + ip = (u8 *)regs->ip + cs_base;
20356 code_len = code_len - code_prologue + 1;
20357 }
20358 for (i = 0; i < code_len; i++, ip++) {
20359 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20360 pr_cont(" Bad EIP value.");
20361 break;
20362 }
20363 - if (ip == (u8 *)regs->ip)
20364 + if (ip == (u8 *)regs->ip + cs_base)
20365 pr_cont(" <%02x>", c);
20366 else
20367 pr_cont(" %02x", c);
20368 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20369 {
20370 unsigned short ud2;
20371
20372 + ip = ktla_ktva(ip);
20373 if (ip < PAGE_OFFSET)
20374 return 0;
20375 if (probe_kernel_address((unsigned short *)ip, ud2))
20376 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20377
20378 return ud2 == 0x0b0f;
20379 }
20380 +
20381 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20382 +void pax_check_alloca(unsigned long size)
20383 +{
20384 + unsigned long sp = (unsigned long)&sp, stack_left;
20385 +
20386 + /* all kernel stacks are of the same size */
20387 + stack_left = sp & (THREAD_SIZE - 1);
20388 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20389 +}
20390 +EXPORT_SYMBOL(pax_check_alloca);
20391 +#endif
20392 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20393 index addb207..99635fa 100644
20394 --- a/arch/x86/kernel/dumpstack_64.c
20395 +++ b/arch/x86/kernel/dumpstack_64.c
20396 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20397 unsigned long *irq_stack_end =
20398 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20399 unsigned used = 0;
20400 - struct thread_info *tinfo;
20401 int graph = 0;
20402 unsigned long dummy;
20403 + void *stack_start;
20404
20405 if (!task)
20406 task = current;
20407 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20408 * current stack address. If the stacks consist of nested
20409 * exceptions
20410 */
20411 - tinfo = task_thread_info(task);
20412 for (;;) {
20413 char *id;
20414 unsigned long *estack_end;
20415 +
20416 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20417 &used, &id);
20418
20419 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20420 if (ops->stack(data, id) < 0)
20421 break;
20422
20423 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20424 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20425 data, estack_end, &graph);
20426 ops->stack(data, "<EOE>");
20427 /*
20428 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20429 * second-to-last pointer (index -2 to end) in the
20430 * exception stack:
20431 */
20432 + if ((u16)estack_end[-1] != __KERNEL_DS)
20433 + goto out;
20434 stack = (unsigned long *) estack_end[-2];
20435 continue;
20436 }
20437 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20438 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20439 if (ops->stack(data, "IRQ") < 0)
20440 break;
20441 - bp = ops->walk_stack(tinfo, stack, bp,
20442 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20443 ops, data, irq_stack_end, &graph);
20444 /*
20445 * We link to the next stack (which would be
20446 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20447 /*
20448 * This handles the process stack:
20449 */
20450 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20451 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20452 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20453 +out:
20454 put_cpu();
20455 }
20456 EXPORT_SYMBOL(dump_trace);
20457 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20458
20459 return ud2 == 0x0b0f;
20460 }
20461 +
20462 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20463 +void pax_check_alloca(unsigned long size)
20464 +{
20465 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20466 + unsigned cpu, used;
20467 + char *id;
20468 +
20469 + /* check the process stack first */
20470 + stack_start = (unsigned long)task_stack_page(current);
20471 + stack_end = stack_start + THREAD_SIZE;
20472 + if (likely(stack_start <= sp && sp < stack_end)) {
20473 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20474 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20475 + return;
20476 + }
20477 +
20478 + cpu = get_cpu();
20479 +
20480 + /* check the irq stacks */
20481 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20482 + stack_start = stack_end - IRQ_STACK_SIZE;
20483 + if (stack_start <= sp && sp < stack_end) {
20484 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20485 + put_cpu();
20486 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20487 + return;
20488 + }
20489 +
20490 + /* check the exception stacks */
20491 + used = 0;
20492 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20493 + stack_start = stack_end - EXCEPTION_STKSZ;
20494 + if (stack_end && stack_start <= sp && sp < stack_end) {
20495 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20496 + put_cpu();
20497 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20498 + return;
20499 + }
20500 +
20501 + put_cpu();
20502 +
20503 + /* unknown stack */
20504 + BUG();
20505 +}
20506 +EXPORT_SYMBOL(pax_check_alloca);
20507 +#endif
20508 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20509 index 174da5f..5e55606 100644
20510 --- a/arch/x86/kernel/e820.c
20511 +++ b/arch/x86/kernel/e820.c
20512 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20513
20514 static void early_panic(char *msg)
20515 {
20516 - early_printk(msg);
20517 - panic(msg);
20518 + early_printk("%s", msg);
20519 + panic("%s", msg);
20520 }
20521
20522 static int userdef __initdata;
20523 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20524 index d15f575..d692043 100644
20525 --- a/arch/x86/kernel/early_printk.c
20526 +++ b/arch/x86/kernel/early_printk.c
20527 @@ -7,6 +7,7 @@
20528 #include <linux/pci_regs.h>
20529 #include <linux/pci_ids.h>
20530 #include <linux/errno.h>
20531 +#include <linux/sched.h>
20532 #include <asm/io.h>
20533 #include <asm/processor.h>
20534 #include <asm/fcntl.h>
20535 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20536 index 2cfbc3a..b756682 100644
20537 --- a/arch/x86/kernel/entry_32.S
20538 +++ b/arch/x86/kernel/entry_32.S
20539 @@ -177,13 +177,153 @@
20540 /*CFI_REL_OFFSET gs, PT_GS*/
20541 .endm
20542 .macro SET_KERNEL_GS reg
20543 +
20544 +#ifdef CONFIG_CC_STACKPROTECTOR
20545 movl $(__KERNEL_STACK_CANARY), \reg
20546 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20547 + movl $(__USER_DS), \reg
20548 +#else
20549 + xorl \reg, \reg
20550 +#endif
20551 +
20552 movl \reg, %gs
20553 .endm
20554
20555 #endif /* CONFIG_X86_32_LAZY_GS */
20556
20557 -.macro SAVE_ALL
20558 +.macro pax_enter_kernel
20559 +#ifdef CONFIG_PAX_KERNEXEC
20560 + call pax_enter_kernel
20561 +#endif
20562 +.endm
20563 +
20564 +.macro pax_exit_kernel
20565 +#ifdef CONFIG_PAX_KERNEXEC
20566 + call pax_exit_kernel
20567 +#endif
20568 +.endm
20569 +
20570 +#ifdef CONFIG_PAX_KERNEXEC
20571 +ENTRY(pax_enter_kernel)
20572 +#ifdef CONFIG_PARAVIRT
20573 + pushl %eax
20574 + pushl %ecx
20575 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20576 + mov %eax, %esi
20577 +#else
20578 + mov %cr0, %esi
20579 +#endif
20580 + bts $16, %esi
20581 + jnc 1f
20582 + mov %cs, %esi
20583 + cmp $__KERNEL_CS, %esi
20584 + jz 3f
20585 + ljmp $__KERNEL_CS, $3f
20586 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20587 +2:
20588 +#ifdef CONFIG_PARAVIRT
20589 + mov %esi, %eax
20590 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20591 +#else
20592 + mov %esi, %cr0
20593 +#endif
20594 +3:
20595 +#ifdef CONFIG_PARAVIRT
20596 + popl %ecx
20597 + popl %eax
20598 +#endif
20599 + ret
20600 +ENDPROC(pax_enter_kernel)
20601 +
20602 +ENTRY(pax_exit_kernel)
20603 +#ifdef CONFIG_PARAVIRT
20604 + pushl %eax
20605 + pushl %ecx
20606 +#endif
20607 + mov %cs, %esi
20608 + cmp $__KERNEXEC_KERNEL_CS, %esi
20609 + jnz 2f
20610 +#ifdef CONFIG_PARAVIRT
20611 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20612 + mov %eax, %esi
20613 +#else
20614 + mov %cr0, %esi
20615 +#endif
20616 + btr $16, %esi
20617 + ljmp $__KERNEL_CS, $1f
20618 +1:
20619 +#ifdef CONFIG_PARAVIRT
20620 + mov %esi, %eax
20621 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20622 +#else
20623 + mov %esi, %cr0
20624 +#endif
20625 +2:
20626 +#ifdef CONFIG_PARAVIRT
20627 + popl %ecx
20628 + popl %eax
20629 +#endif
20630 + ret
20631 +ENDPROC(pax_exit_kernel)
20632 +#endif
20633 +
20634 + .macro pax_erase_kstack
20635 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20636 + call pax_erase_kstack
20637 +#endif
20638 + .endm
20639 +
20640 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20641 +/*
20642 + * ebp: thread_info
20643 + */
20644 +ENTRY(pax_erase_kstack)
20645 + pushl %edi
20646 + pushl %ecx
20647 + pushl %eax
20648 +
20649 + mov TI_lowest_stack(%ebp), %edi
20650 + mov $-0xBEEF, %eax
20651 + std
20652 +
20653 +1: mov %edi, %ecx
20654 + and $THREAD_SIZE_asm - 1, %ecx
20655 + shr $2, %ecx
20656 + repne scasl
20657 + jecxz 2f
20658 +
20659 + cmp $2*16, %ecx
20660 + jc 2f
20661 +
20662 + mov $2*16, %ecx
20663 + repe scasl
20664 + jecxz 2f
20665 + jne 1b
20666 +
20667 +2: cld
20668 + mov %esp, %ecx
20669 + sub %edi, %ecx
20670 +
20671 + cmp $THREAD_SIZE_asm, %ecx
20672 + jb 3f
20673 + ud2
20674 +3:
20675 +
20676 + shr $2, %ecx
20677 + rep stosl
20678 +
20679 + mov TI_task_thread_sp0(%ebp), %edi
20680 + sub $128, %edi
20681 + mov %edi, TI_lowest_stack(%ebp)
20682 +
20683 + popl %eax
20684 + popl %ecx
20685 + popl %edi
20686 + ret
20687 +ENDPROC(pax_erase_kstack)
20688 +#endif
20689 +
20690 +.macro __SAVE_ALL _DS
20691 cld
20692 PUSH_GS
20693 pushl_cfi %fs
20694 @@ -206,7 +346,7 @@
20695 CFI_REL_OFFSET ecx, 0
20696 pushl_cfi %ebx
20697 CFI_REL_OFFSET ebx, 0
20698 - movl $(__USER_DS), %edx
20699 + movl $\_DS, %edx
20700 movl %edx, %ds
20701 movl %edx, %es
20702 movl $(__KERNEL_PERCPU), %edx
20703 @@ -214,6 +354,15 @@
20704 SET_KERNEL_GS %edx
20705 .endm
20706
20707 +.macro SAVE_ALL
20708 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20709 + __SAVE_ALL __KERNEL_DS
20710 + pax_enter_kernel
20711 +#else
20712 + __SAVE_ALL __USER_DS
20713 +#endif
20714 +.endm
20715 +
20716 .macro RESTORE_INT_REGS
20717 popl_cfi %ebx
20718 CFI_RESTORE ebx
20719 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20720 popfl_cfi
20721 jmp syscall_exit
20722 CFI_ENDPROC
20723 -END(ret_from_fork)
20724 +ENDPROC(ret_from_fork)
20725
20726 ENTRY(ret_from_kernel_thread)
20727 CFI_STARTPROC
20728 @@ -344,7 +493,15 @@ ret_from_intr:
20729 andl $SEGMENT_RPL_MASK, %eax
20730 #endif
20731 cmpl $USER_RPL, %eax
20732 +
20733 +#ifdef CONFIG_PAX_KERNEXEC
20734 + jae resume_userspace
20735 +
20736 + pax_exit_kernel
20737 + jmp resume_kernel
20738 +#else
20739 jb resume_kernel # not returning to v8086 or userspace
20740 +#endif
20741
20742 ENTRY(resume_userspace)
20743 LOCKDEP_SYS_EXIT
20744 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20745 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20746 # int/exception return?
20747 jne work_pending
20748 - jmp restore_all
20749 -END(ret_from_exception)
20750 + jmp restore_all_pax
20751 +ENDPROC(ret_from_exception)
20752
20753 #ifdef CONFIG_PREEMPT
20754 ENTRY(resume_kernel)
20755 @@ -372,7 +529,7 @@ need_resched:
20756 jz restore_all
20757 call preempt_schedule_irq
20758 jmp need_resched
20759 -END(resume_kernel)
20760 +ENDPROC(resume_kernel)
20761 #endif
20762 CFI_ENDPROC
20763 /*
20764 @@ -406,30 +563,45 @@ sysenter_past_esp:
20765 /*CFI_REL_OFFSET cs, 0*/
20766 /*
20767 * Push current_thread_info()->sysenter_return to the stack.
20768 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20769 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20770 */
20771 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20772 + pushl_cfi $0
20773 CFI_REL_OFFSET eip, 0
20774
20775 pushl_cfi %eax
20776 SAVE_ALL
20777 + GET_THREAD_INFO(%ebp)
20778 + movl TI_sysenter_return(%ebp),%ebp
20779 + movl %ebp,PT_EIP(%esp)
20780 ENABLE_INTERRUPTS(CLBR_NONE)
20781
20782 /*
20783 * Load the potential sixth argument from user stack.
20784 * Careful about security.
20785 */
20786 + movl PT_OLDESP(%esp),%ebp
20787 +
20788 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20789 + mov PT_OLDSS(%esp),%ds
20790 +1: movl %ds:(%ebp),%ebp
20791 + push %ss
20792 + pop %ds
20793 +#else
20794 cmpl $__PAGE_OFFSET-3,%ebp
20795 jae syscall_fault
20796 ASM_STAC
20797 1: movl (%ebp),%ebp
20798 ASM_CLAC
20799 +#endif
20800 +
20801 movl %ebp,PT_EBP(%esp)
20802 _ASM_EXTABLE(1b,syscall_fault)
20803
20804 GET_THREAD_INFO(%ebp)
20805
20806 +#ifdef CONFIG_PAX_RANDKSTACK
20807 + pax_erase_kstack
20808 +#endif
20809 +
20810 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20811 jnz sysenter_audit
20812 sysenter_do_call:
20813 @@ -444,12 +616,24 @@ sysenter_do_call:
20814 testl $_TIF_ALLWORK_MASK, %ecx
20815 jne sysexit_audit
20816 sysenter_exit:
20817 +
20818 +#ifdef CONFIG_PAX_RANDKSTACK
20819 + pushl_cfi %eax
20820 + movl %esp, %eax
20821 + call pax_randomize_kstack
20822 + popl_cfi %eax
20823 +#endif
20824 +
20825 + pax_erase_kstack
20826 +
20827 /* if something modifies registers it must also disable sysexit */
20828 movl PT_EIP(%esp), %edx
20829 movl PT_OLDESP(%esp), %ecx
20830 xorl %ebp,%ebp
20831 TRACE_IRQS_ON
20832 1: mov PT_FS(%esp), %fs
20833 +2: mov PT_DS(%esp), %ds
20834 +3: mov PT_ES(%esp), %es
20835 PTGS_TO_GS
20836 ENABLE_INTERRUPTS_SYSEXIT
20837
20838 @@ -466,6 +650,9 @@ sysenter_audit:
20839 movl %eax,%edx /* 2nd arg: syscall number */
20840 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20841 call __audit_syscall_entry
20842 +
20843 + pax_erase_kstack
20844 +
20845 pushl_cfi %ebx
20846 movl PT_EAX(%esp),%eax /* reload syscall number */
20847 jmp sysenter_do_call
20848 @@ -491,10 +678,16 @@ sysexit_audit:
20849
20850 CFI_ENDPROC
20851 .pushsection .fixup,"ax"
20852 -2: movl $0,PT_FS(%esp)
20853 +4: movl $0,PT_FS(%esp)
20854 + jmp 1b
20855 +5: movl $0,PT_DS(%esp)
20856 + jmp 1b
20857 +6: movl $0,PT_ES(%esp)
20858 jmp 1b
20859 .popsection
20860 - _ASM_EXTABLE(1b,2b)
20861 + _ASM_EXTABLE(1b,4b)
20862 + _ASM_EXTABLE(2b,5b)
20863 + _ASM_EXTABLE(3b,6b)
20864 PTGS_TO_GS_EX
20865 ENDPROC(ia32_sysenter_target)
20866
20867 @@ -509,6 +702,11 @@ ENTRY(system_call)
20868 pushl_cfi %eax # save orig_eax
20869 SAVE_ALL
20870 GET_THREAD_INFO(%ebp)
20871 +
20872 +#ifdef CONFIG_PAX_RANDKSTACK
20873 + pax_erase_kstack
20874 +#endif
20875 +
20876 # system call tracing in operation / emulation
20877 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20878 jnz syscall_trace_entry
20879 @@ -527,6 +725,15 @@ syscall_exit:
20880 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20881 jne syscall_exit_work
20882
20883 +restore_all_pax:
20884 +
20885 +#ifdef CONFIG_PAX_RANDKSTACK
20886 + movl %esp, %eax
20887 + call pax_randomize_kstack
20888 +#endif
20889 +
20890 + pax_erase_kstack
20891 +
20892 restore_all:
20893 TRACE_IRQS_IRET
20894 restore_all_notrace:
20895 @@ -583,14 +790,34 @@ ldt_ss:
20896 * compensating for the offset by changing to the ESPFIX segment with
20897 * a base address that matches for the difference.
20898 */
20899 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20900 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20901 mov %esp, %edx /* load kernel esp */
20902 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20903 mov %dx, %ax /* eax: new kernel esp */
20904 sub %eax, %edx /* offset (low word is 0) */
20905 +#ifdef CONFIG_SMP
20906 + movl PER_CPU_VAR(cpu_number), %ebx
20907 + shll $PAGE_SHIFT_asm, %ebx
20908 + addl $cpu_gdt_table, %ebx
20909 +#else
20910 + movl $cpu_gdt_table, %ebx
20911 +#endif
20912 shr $16, %edx
20913 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20914 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20915 +
20916 +#ifdef CONFIG_PAX_KERNEXEC
20917 + mov %cr0, %esi
20918 + btr $16, %esi
20919 + mov %esi, %cr0
20920 +#endif
20921 +
20922 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20923 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20924 +
20925 +#ifdef CONFIG_PAX_KERNEXEC
20926 + bts $16, %esi
20927 + mov %esi, %cr0
20928 +#endif
20929 +
20930 pushl_cfi $__ESPFIX_SS
20931 pushl_cfi %eax /* new kernel esp */
20932 /* Disable interrupts, but do not irqtrace this section: we
20933 @@ -619,20 +846,18 @@ work_resched:
20934 movl TI_flags(%ebp), %ecx
20935 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20936 # than syscall tracing?
20937 - jz restore_all
20938 + jz restore_all_pax
20939 testb $_TIF_NEED_RESCHED, %cl
20940 jnz work_resched
20941
20942 work_notifysig: # deal with pending signals and
20943 # notify-resume requests
20944 + movl %esp, %eax
20945 #ifdef CONFIG_VM86
20946 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20947 - movl %esp, %eax
20948 jne work_notifysig_v86 # returning to kernel-space or
20949 # vm86-space
20950 1:
20951 -#else
20952 - movl %esp, %eax
20953 #endif
20954 TRACE_IRQS_ON
20955 ENABLE_INTERRUPTS(CLBR_NONE)
20956 @@ -653,7 +878,7 @@ work_notifysig_v86:
20957 movl %eax, %esp
20958 jmp 1b
20959 #endif
20960 -END(work_pending)
20961 +ENDPROC(work_pending)
20962
20963 # perform syscall exit tracing
20964 ALIGN
20965 @@ -661,11 +886,14 @@ syscall_trace_entry:
20966 movl $-ENOSYS,PT_EAX(%esp)
20967 movl %esp, %eax
20968 call syscall_trace_enter
20969 +
20970 + pax_erase_kstack
20971 +
20972 /* What it returned is what we'll actually use. */
20973 cmpl $(NR_syscalls), %eax
20974 jnae syscall_call
20975 jmp syscall_exit
20976 -END(syscall_trace_entry)
20977 +ENDPROC(syscall_trace_entry)
20978
20979 # perform syscall exit tracing
20980 ALIGN
20981 @@ -678,21 +906,25 @@ syscall_exit_work:
20982 movl %esp, %eax
20983 call syscall_trace_leave
20984 jmp resume_userspace
20985 -END(syscall_exit_work)
20986 +ENDPROC(syscall_exit_work)
20987 CFI_ENDPROC
20988
20989 RING0_INT_FRAME # can't unwind into user space anyway
20990 syscall_fault:
20991 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20992 + push %ss
20993 + pop %ds
20994 +#endif
20995 ASM_CLAC
20996 GET_THREAD_INFO(%ebp)
20997 movl $-EFAULT,PT_EAX(%esp)
20998 jmp resume_userspace
20999 -END(syscall_fault)
21000 +ENDPROC(syscall_fault)
21001
21002 syscall_badsys:
21003 movl $-ENOSYS,PT_EAX(%esp)
21004 jmp resume_userspace
21005 -END(syscall_badsys)
21006 +ENDPROC(syscall_badsys)
21007 CFI_ENDPROC
21008 /*
21009 * End of kprobes section
21010 @@ -708,8 +940,15 @@ END(syscall_badsys)
21011 * normal stack and adjusts ESP with the matching offset.
21012 */
21013 /* fixup the stack */
21014 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21015 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21016 +#ifdef CONFIG_SMP
21017 + movl PER_CPU_VAR(cpu_number), %ebx
21018 + shll $PAGE_SHIFT_asm, %ebx
21019 + addl $cpu_gdt_table, %ebx
21020 +#else
21021 + movl $cpu_gdt_table, %ebx
21022 +#endif
21023 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21024 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21025 shl $16, %eax
21026 addl %esp, %eax /* the adjusted stack pointer */
21027 pushl_cfi $__KERNEL_DS
21028 @@ -762,7 +1001,7 @@ vector=vector+1
21029 .endr
21030 2: jmp common_interrupt
21031 .endr
21032 -END(irq_entries_start)
21033 +ENDPROC(irq_entries_start)
21034
21035 .previous
21036 END(interrupt)
21037 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21038 pushl_cfi $do_coprocessor_error
21039 jmp error_code
21040 CFI_ENDPROC
21041 -END(coprocessor_error)
21042 +ENDPROC(coprocessor_error)
21043
21044 ENTRY(simd_coprocessor_error)
21045 RING0_INT_FRAME
21046 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21047 .section .altinstructions,"a"
21048 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21049 .previous
21050 -.section .altinstr_replacement,"ax"
21051 +.section .altinstr_replacement,"a"
21052 663: pushl $do_simd_coprocessor_error
21053 664:
21054 .previous
21055 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21056 #endif
21057 jmp error_code
21058 CFI_ENDPROC
21059 -END(simd_coprocessor_error)
21060 +ENDPROC(simd_coprocessor_error)
21061
21062 ENTRY(device_not_available)
21063 RING0_INT_FRAME
21064 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21065 pushl_cfi $do_device_not_available
21066 jmp error_code
21067 CFI_ENDPROC
21068 -END(device_not_available)
21069 +ENDPROC(device_not_available)
21070
21071 #ifdef CONFIG_PARAVIRT
21072 ENTRY(native_iret)
21073 iret
21074 _ASM_EXTABLE(native_iret, iret_exc)
21075 -END(native_iret)
21076 +ENDPROC(native_iret)
21077
21078 ENTRY(native_irq_enable_sysexit)
21079 sti
21080 sysexit
21081 -END(native_irq_enable_sysexit)
21082 +ENDPROC(native_irq_enable_sysexit)
21083 #endif
21084
21085 ENTRY(overflow)
21086 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21087 pushl_cfi $do_overflow
21088 jmp error_code
21089 CFI_ENDPROC
21090 -END(overflow)
21091 +ENDPROC(overflow)
21092
21093 ENTRY(bounds)
21094 RING0_INT_FRAME
21095 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21096 pushl_cfi $do_bounds
21097 jmp error_code
21098 CFI_ENDPROC
21099 -END(bounds)
21100 +ENDPROC(bounds)
21101
21102 ENTRY(invalid_op)
21103 RING0_INT_FRAME
21104 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21105 pushl_cfi $do_invalid_op
21106 jmp error_code
21107 CFI_ENDPROC
21108 -END(invalid_op)
21109 +ENDPROC(invalid_op)
21110
21111 ENTRY(coprocessor_segment_overrun)
21112 RING0_INT_FRAME
21113 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21114 pushl_cfi $do_coprocessor_segment_overrun
21115 jmp error_code
21116 CFI_ENDPROC
21117 -END(coprocessor_segment_overrun)
21118 +ENDPROC(coprocessor_segment_overrun)
21119
21120 ENTRY(invalid_TSS)
21121 RING0_EC_FRAME
21122 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21123 pushl_cfi $do_invalid_TSS
21124 jmp error_code
21125 CFI_ENDPROC
21126 -END(invalid_TSS)
21127 +ENDPROC(invalid_TSS)
21128
21129 ENTRY(segment_not_present)
21130 RING0_EC_FRAME
21131 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21132 pushl_cfi $do_segment_not_present
21133 jmp error_code
21134 CFI_ENDPROC
21135 -END(segment_not_present)
21136 +ENDPROC(segment_not_present)
21137
21138 ENTRY(stack_segment)
21139 RING0_EC_FRAME
21140 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21141 pushl_cfi $do_stack_segment
21142 jmp error_code
21143 CFI_ENDPROC
21144 -END(stack_segment)
21145 +ENDPROC(stack_segment)
21146
21147 ENTRY(alignment_check)
21148 RING0_EC_FRAME
21149 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21150 pushl_cfi $do_alignment_check
21151 jmp error_code
21152 CFI_ENDPROC
21153 -END(alignment_check)
21154 +ENDPROC(alignment_check)
21155
21156 ENTRY(divide_error)
21157 RING0_INT_FRAME
21158 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21159 pushl_cfi $do_divide_error
21160 jmp error_code
21161 CFI_ENDPROC
21162 -END(divide_error)
21163 +ENDPROC(divide_error)
21164
21165 #ifdef CONFIG_X86_MCE
21166 ENTRY(machine_check)
21167 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21168 pushl_cfi machine_check_vector
21169 jmp error_code
21170 CFI_ENDPROC
21171 -END(machine_check)
21172 +ENDPROC(machine_check)
21173 #endif
21174
21175 ENTRY(spurious_interrupt_bug)
21176 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21177 pushl_cfi $do_spurious_interrupt_bug
21178 jmp error_code
21179 CFI_ENDPROC
21180 -END(spurious_interrupt_bug)
21181 +ENDPROC(spurious_interrupt_bug)
21182 /*
21183 * End of kprobes section
21184 */
21185 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21186
21187 ENTRY(mcount)
21188 ret
21189 -END(mcount)
21190 +ENDPROC(mcount)
21191
21192 ENTRY(ftrace_caller)
21193 cmpl $0, function_trace_stop
21194 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21195 .globl ftrace_stub
21196 ftrace_stub:
21197 ret
21198 -END(ftrace_caller)
21199 +ENDPROC(ftrace_caller)
21200
21201 ENTRY(ftrace_regs_caller)
21202 pushf /* push flags before compare (in cs location) */
21203 @@ -1207,7 +1446,7 @@ trace:
21204 popl %ecx
21205 popl %eax
21206 jmp ftrace_stub
21207 -END(mcount)
21208 +ENDPROC(mcount)
21209 #endif /* CONFIG_DYNAMIC_FTRACE */
21210 #endif /* CONFIG_FUNCTION_TRACER */
21211
21212 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21213 popl %ecx
21214 popl %eax
21215 ret
21216 -END(ftrace_graph_caller)
21217 +ENDPROC(ftrace_graph_caller)
21218
21219 .globl return_to_handler
21220 return_to_handler:
21221 @@ -1281,15 +1520,18 @@ error_code:
21222 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21223 REG_TO_PTGS %ecx
21224 SET_KERNEL_GS %ecx
21225 - movl $(__USER_DS), %ecx
21226 + movl $(__KERNEL_DS), %ecx
21227 movl %ecx, %ds
21228 movl %ecx, %es
21229 +
21230 + pax_enter_kernel
21231 +
21232 TRACE_IRQS_OFF
21233 movl %esp,%eax # pt_regs pointer
21234 call *%edi
21235 jmp ret_from_exception
21236 CFI_ENDPROC
21237 -END(page_fault)
21238 +ENDPROC(page_fault)
21239
21240 /*
21241 * Debug traps and NMI can happen at the one SYSENTER instruction
21242 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21243 call do_debug
21244 jmp ret_from_exception
21245 CFI_ENDPROC
21246 -END(debug)
21247 +ENDPROC(debug)
21248
21249 /*
21250 * NMI is doubly nasty. It can happen _while_ we're handling
21251 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21252 xorl %edx,%edx # zero error code
21253 movl %esp,%eax # pt_regs pointer
21254 call do_nmi
21255 +
21256 + pax_exit_kernel
21257 +
21258 jmp restore_all_notrace
21259 CFI_ENDPROC
21260
21261 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21262 FIXUP_ESPFIX_STACK # %eax == %esp
21263 xorl %edx,%edx # zero error code
21264 call do_nmi
21265 +
21266 + pax_exit_kernel
21267 +
21268 RESTORE_REGS
21269 lss 12+4(%esp), %esp # back to espfix stack
21270 CFI_ADJUST_CFA_OFFSET -24
21271 jmp irq_return
21272 CFI_ENDPROC
21273 -END(nmi)
21274 +ENDPROC(nmi)
21275
21276 ENTRY(int3)
21277 RING0_INT_FRAME
21278 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21279 call do_int3
21280 jmp ret_from_exception
21281 CFI_ENDPROC
21282 -END(int3)
21283 +ENDPROC(int3)
21284
21285 ENTRY(general_protection)
21286 RING0_EC_FRAME
21287 pushl_cfi $do_general_protection
21288 jmp error_code
21289 CFI_ENDPROC
21290 -END(general_protection)
21291 +ENDPROC(general_protection)
21292
21293 #ifdef CONFIG_KVM_GUEST
21294 ENTRY(async_page_fault)
21295 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21296 pushl_cfi $do_async_page_fault
21297 jmp error_code
21298 CFI_ENDPROC
21299 -END(async_page_fault)
21300 +ENDPROC(async_page_fault)
21301 #endif
21302
21303 /*
21304 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21305 index 1b69951..8430a6d 100644
21306 --- a/arch/x86/kernel/entry_64.S
21307 +++ b/arch/x86/kernel/entry_64.S
21308 @@ -59,6 +59,8 @@
21309 #include <asm/context_tracking.h>
21310 #include <asm/smap.h>
21311 #include <linux/err.h>
21312 +#include <asm/pgtable.h>
21313 +#include <asm/alternative-asm.h>
21314
21315 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21316 #include <linux/elf-em.h>
21317 @@ -80,8 +82,9 @@
21318 #ifdef CONFIG_DYNAMIC_FTRACE
21319
21320 ENTRY(function_hook)
21321 + pax_force_retaddr
21322 retq
21323 -END(function_hook)
21324 +ENDPROC(function_hook)
21325
21326 /* skip is set if stack has been adjusted */
21327 .macro ftrace_caller_setup skip=0
21328 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21329 #endif
21330
21331 GLOBAL(ftrace_stub)
21332 + pax_force_retaddr
21333 retq
21334 -END(ftrace_caller)
21335 +ENDPROC(ftrace_caller)
21336
21337 ENTRY(ftrace_regs_caller)
21338 /* Save the current flags before compare (in SS location)*/
21339 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21340 popfq
21341 jmp ftrace_stub
21342
21343 -END(ftrace_regs_caller)
21344 +ENDPROC(ftrace_regs_caller)
21345
21346
21347 #else /* ! CONFIG_DYNAMIC_FTRACE */
21348 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21349 #endif
21350
21351 GLOBAL(ftrace_stub)
21352 + pax_force_retaddr
21353 retq
21354
21355 trace:
21356 @@ -225,12 +230,13 @@ trace:
21357 #endif
21358 subq $MCOUNT_INSN_SIZE, %rdi
21359
21360 + pax_force_fptr ftrace_trace_function
21361 call *ftrace_trace_function
21362
21363 MCOUNT_RESTORE_FRAME
21364
21365 jmp ftrace_stub
21366 -END(function_hook)
21367 +ENDPROC(function_hook)
21368 #endif /* CONFIG_DYNAMIC_FTRACE */
21369 #endif /* CONFIG_FUNCTION_TRACER */
21370
21371 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21372
21373 MCOUNT_RESTORE_FRAME
21374
21375 + pax_force_retaddr
21376 retq
21377 -END(ftrace_graph_caller)
21378 +ENDPROC(ftrace_graph_caller)
21379
21380 GLOBAL(return_to_handler)
21381 subq $24, %rsp
21382 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21383 movq 8(%rsp), %rdx
21384 movq (%rsp), %rax
21385 addq $24, %rsp
21386 + pax_force_fptr %rdi
21387 jmp *%rdi
21388 +ENDPROC(return_to_handler)
21389 #endif
21390
21391
21392 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21393 ENDPROC(native_usergs_sysret64)
21394 #endif /* CONFIG_PARAVIRT */
21395
21396 + .macro ljmpq sel, off
21397 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21398 + .byte 0x48; ljmp *1234f(%rip)
21399 + .pushsection .rodata
21400 + .align 16
21401 + 1234: .quad \off; .word \sel
21402 + .popsection
21403 +#else
21404 + pushq $\sel
21405 + pushq $\off
21406 + lretq
21407 +#endif
21408 + .endm
21409 +
21410 + .macro pax_enter_kernel
21411 + pax_set_fptr_mask
21412 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21413 + call pax_enter_kernel
21414 +#endif
21415 + .endm
21416 +
21417 + .macro pax_exit_kernel
21418 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21419 + call pax_exit_kernel
21420 +#endif
21421 +
21422 + .endm
21423 +
21424 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21425 +ENTRY(pax_enter_kernel)
21426 + pushq %rdi
21427 +
21428 +#ifdef CONFIG_PARAVIRT
21429 + PV_SAVE_REGS(CLBR_RDI)
21430 +#endif
21431 +
21432 +#ifdef CONFIG_PAX_KERNEXEC
21433 + GET_CR0_INTO_RDI
21434 + bts $16,%rdi
21435 + jnc 3f
21436 + mov %cs,%edi
21437 + cmp $__KERNEL_CS,%edi
21438 + jnz 2f
21439 +1:
21440 +#endif
21441 +
21442 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21443 + 661: jmp 111f
21444 + .pushsection .altinstr_replacement, "a"
21445 + 662: ASM_NOP2
21446 + .popsection
21447 + .pushsection .altinstructions, "a"
21448 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21449 + .popsection
21450 + GET_CR3_INTO_RDI
21451 + cmp $0,%dil
21452 + jnz 112f
21453 + mov $__KERNEL_DS,%edi
21454 + mov %edi,%ss
21455 + jmp 111f
21456 +112: cmp $1,%dil
21457 + jz 113f
21458 + ud2
21459 +113: sub $4097,%rdi
21460 + bts $63,%rdi
21461 + SET_RDI_INTO_CR3
21462 + mov $__UDEREF_KERNEL_DS,%edi
21463 + mov %edi,%ss
21464 +111:
21465 +#endif
21466 +
21467 +#ifdef CONFIG_PARAVIRT
21468 + PV_RESTORE_REGS(CLBR_RDI)
21469 +#endif
21470 +
21471 + popq %rdi
21472 + pax_force_retaddr
21473 + retq
21474 +
21475 +#ifdef CONFIG_PAX_KERNEXEC
21476 +2: ljmpq __KERNEL_CS,1b
21477 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21478 +4: SET_RDI_INTO_CR0
21479 + jmp 1b
21480 +#endif
21481 +ENDPROC(pax_enter_kernel)
21482 +
21483 +ENTRY(pax_exit_kernel)
21484 + pushq %rdi
21485 +
21486 +#ifdef CONFIG_PARAVIRT
21487 + PV_SAVE_REGS(CLBR_RDI)
21488 +#endif
21489 +
21490 +#ifdef CONFIG_PAX_KERNEXEC
21491 + mov %cs,%rdi
21492 + cmp $__KERNEXEC_KERNEL_CS,%edi
21493 + jz 2f
21494 + GET_CR0_INTO_RDI
21495 + bts $16,%rdi
21496 + jnc 4f
21497 +1:
21498 +#endif
21499 +
21500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21501 + 661: jmp 111f
21502 + .pushsection .altinstr_replacement, "a"
21503 + 662: ASM_NOP2
21504 + .popsection
21505 + .pushsection .altinstructions, "a"
21506 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21507 + .popsection
21508 + mov %ss,%edi
21509 + cmp $__UDEREF_KERNEL_DS,%edi
21510 + jnz 111f
21511 + GET_CR3_INTO_RDI
21512 + cmp $0,%dil
21513 + jz 112f
21514 + ud2
21515 +112: add $4097,%rdi
21516 + bts $63,%rdi
21517 + SET_RDI_INTO_CR3
21518 + mov $__KERNEL_DS,%edi
21519 + mov %edi,%ss
21520 +111:
21521 +#endif
21522 +
21523 +#ifdef CONFIG_PARAVIRT
21524 + PV_RESTORE_REGS(CLBR_RDI);
21525 +#endif
21526 +
21527 + popq %rdi
21528 + pax_force_retaddr
21529 + retq
21530 +
21531 +#ifdef CONFIG_PAX_KERNEXEC
21532 +2: GET_CR0_INTO_RDI
21533 + btr $16,%rdi
21534 + jnc 4f
21535 + ljmpq __KERNEL_CS,3f
21536 +3: SET_RDI_INTO_CR0
21537 + jmp 1b
21538 +4: ud2
21539 + jmp 4b
21540 +#endif
21541 +ENDPROC(pax_exit_kernel)
21542 +#endif
21543 +
21544 + .macro pax_enter_kernel_user
21545 + pax_set_fptr_mask
21546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21547 + call pax_enter_kernel_user
21548 +#endif
21549 + .endm
21550 +
21551 + .macro pax_exit_kernel_user
21552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21553 + call pax_exit_kernel_user
21554 +#endif
21555 +#ifdef CONFIG_PAX_RANDKSTACK
21556 + pushq %rax
21557 + pushq %r11
21558 + call pax_randomize_kstack
21559 + popq %r11
21560 + popq %rax
21561 +#endif
21562 + .endm
21563 +
21564 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21565 +ENTRY(pax_enter_kernel_user)
21566 + pushq %rdi
21567 + pushq %rbx
21568 +
21569 +#ifdef CONFIG_PARAVIRT
21570 + PV_SAVE_REGS(CLBR_RDI)
21571 +#endif
21572 +
21573 + 661: jmp 111f
21574 + .pushsection .altinstr_replacement, "a"
21575 + 662: ASM_NOP2
21576 + .popsection
21577 + .pushsection .altinstructions, "a"
21578 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21579 + .popsection
21580 + GET_CR3_INTO_RDI
21581 + cmp $1,%dil
21582 + jnz 4f
21583 + sub $4097,%rdi
21584 + bts $63,%rdi
21585 + SET_RDI_INTO_CR3
21586 + jmp 3f
21587 +111:
21588 +
21589 + GET_CR3_INTO_RDI
21590 + mov %rdi,%rbx
21591 + add $__START_KERNEL_map,%rbx
21592 + sub phys_base(%rip),%rbx
21593 +
21594 +#ifdef CONFIG_PARAVIRT
21595 + cmpl $0, pv_info+PARAVIRT_enabled
21596 + jz 1f
21597 + pushq %rdi
21598 + i = 0
21599 + .rept USER_PGD_PTRS
21600 + mov i*8(%rbx),%rsi
21601 + mov $0,%sil
21602 + lea i*8(%rbx),%rdi
21603 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21604 + i = i + 1
21605 + .endr
21606 + popq %rdi
21607 + jmp 2f
21608 +1:
21609 +#endif
21610 +
21611 + i = 0
21612 + .rept USER_PGD_PTRS
21613 + movb $0,i*8(%rbx)
21614 + i = i + 1
21615 + .endr
21616 +
21617 +2: SET_RDI_INTO_CR3
21618 +
21619 +#ifdef CONFIG_PAX_KERNEXEC
21620 + GET_CR0_INTO_RDI
21621 + bts $16,%rdi
21622 + SET_RDI_INTO_CR0
21623 +#endif
21624 +
21625 +3:
21626 +
21627 +#ifdef CONFIG_PARAVIRT
21628 + PV_RESTORE_REGS(CLBR_RDI)
21629 +#endif
21630 +
21631 + popq %rbx
21632 + popq %rdi
21633 + pax_force_retaddr
21634 + retq
21635 +4: ud2
21636 +ENDPROC(pax_enter_kernel_user)
21637 +
21638 +ENTRY(pax_exit_kernel_user)
21639 + pushq %rdi
21640 + pushq %rbx
21641 +
21642 +#ifdef CONFIG_PARAVIRT
21643 + PV_SAVE_REGS(CLBR_RDI)
21644 +#endif
21645 +
21646 + GET_CR3_INTO_RDI
21647 + 661: jmp 1f
21648 + .pushsection .altinstr_replacement, "a"
21649 + 662: ASM_NOP2
21650 + .popsection
21651 + .pushsection .altinstructions, "a"
21652 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21653 + .popsection
21654 + cmp $0,%dil
21655 + jnz 3f
21656 + add $4097,%rdi
21657 + bts $63,%rdi
21658 + SET_RDI_INTO_CR3
21659 + jmp 2f
21660 +1:
21661 +
21662 + mov %rdi,%rbx
21663 +
21664 +#ifdef CONFIG_PAX_KERNEXEC
21665 + GET_CR0_INTO_RDI
21666 + btr $16,%rdi
21667 + jnc 3f
21668 + SET_RDI_INTO_CR0
21669 +#endif
21670 +
21671 + add $__START_KERNEL_map,%rbx
21672 + sub phys_base(%rip),%rbx
21673 +
21674 +#ifdef CONFIG_PARAVIRT
21675 + cmpl $0, pv_info+PARAVIRT_enabled
21676 + jz 1f
21677 + i = 0
21678 + .rept USER_PGD_PTRS
21679 + mov i*8(%rbx),%rsi
21680 + mov $0x67,%sil
21681 + lea i*8(%rbx),%rdi
21682 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21683 + i = i + 1
21684 + .endr
21685 + jmp 2f
21686 +1:
21687 +#endif
21688 +
21689 + i = 0
21690 + .rept USER_PGD_PTRS
21691 + movb $0x67,i*8(%rbx)
21692 + i = i + 1
21693 + .endr
21694 +2:
21695 +
21696 +#ifdef CONFIG_PARAVIRT
21697 + PV_RESTORE_REGS(CLBR_RDI)
21698 +#endif
21699 +
21700 + popq %rbx
21701 + popq %rdi
21702 + pax_force_retaddr
21703 + retq
21704 +3: ud2
21705 +ENDPROC(pax_exit_kernel_user)
21706 +#endif
21707 +
21708 + .macro pax_enter_kernel_nmi
21709 + pax_set_fptr_mask
21710 +
21711 +#ifdef CONFIG_PAX_KERNEXEC
21712 + GET_CR0_INTO_RDI
21713 + bts $16,%rdi
21714 + jc 110f
21715 + SET_RDI_INTO_CR0
21716 + or $2,%ebx
21717 +110:
21718 +#endif
21719 +
21720 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21721 + 661: jmp 111f
21722 + .pushsection .altinstr_replacement, "a"
21723 + 662: ASM_NOP2
21724 + .popsection
21725 + .pushsection .altinstructions, "a"
21726 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21727 + .popsection
21728 + GET_CR3_INTO_RDI
21729 + cmp $0,%dil
21730 + jz 111f
21731 + sub $4097,%rdi
21732 + or $4,%ebx
21733 + bts $63,%rdi
21734 + SET_RDI_INTO_CR3
21735 + mov $__UDEREF_KERNEL_DS,%edi
21736 + mov %edi,%ss
21737 +111:
21738 +#endif
21739 + .endm
21740 +
21741 + .macro pax_exit_kernel_nmi
21742 +#ifdef CONFIG_PAX_KERNEXEC
21743 + btr $1,%ebx
21744 + jnc 110f
21745 + GET_CR0_INTO_RDI
21746 + btr $16,%rdi
21747 + SET_RDI_INTO_CR0
21748 +110:
21749 +#endif
21750 +
21751 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21752 + btr $2,%ebx
21753 + jnc 111f
21754 + GET_CR3_INTO_RDI
21755 + add $4097,%rdi
21756 + bts $63,%rdi
21757 + SET_RDI_INTO_CR3
21758 + mov $__KERNEL_DS,%edi
21759 + mov %edi,%ss
21760 +111:
21761 +#endif
21762 + .endm
21763 +
21764 + .macro pax_erase_kstack
21765 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21766 + call pax_erase_kstack
21767 +#endif
21768 + .endm
21769 +
21770 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21771 +ENTRY(pax_erase_kstack)
21772 + pushq %rdi
21773 + pushq %rcx
21774 + pushq %rax
21775 + pushq %r11
21776 +
21777 + GET_THREAD_INFO(%r11)
21778 + mov TI_lowest_stack(%r11), %rdi
21779 + mov $-0xBEEF, %rax
21780 + std
21781 +
21782 +1: mov %edi, %ecx
21783 + and $THREAD_SIZE_asm - 1, %ecx
21784 + shr $3, %ecx
21785 + repne scasq
21786 + jecxz 2f
21787 +
21788 + cmp $2*8, %ecx
21789 + jc 2f
21790 +
21791 + mov $2*8, %ecx
21792 + repe scasq
21793 + jecxz 2f
21794 + jne 1b
21795 +
21796 +2: cld
21797 + mov %esp, %ecx
21798 + sub %edi, %ecx
21799 +
21800 + cmp $THREAD_SIZE_asm, %rcx
21801 + jb 3f
21802 + ud2
21803 +3:
21804 +
21805 + shr $3, %ecx
21806 + rep stosq
21807 +
21808 + mov TI_task_thread_sp0(%r11), %rdi
21809 + sub $256, %rdi
21810 + mov %rdi, TI_lowest_stack(%r11)
21811 +
21812 + popq %r11
21813 + popq %rax
21814 + popq %rcx
21815 + popq %rdi
21816 + pax_force_retaddr
21817 + ret
21818 +ENDPROC(pax_erase_kstack)
21819 +#endif
21820
21821 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21822 #ifdef CONFIG_TRACE_IRQFLAGS
21823 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21824 .endm
21825
21826 .macro UNFAKE_STACK_FRAME
21827 - addq $8*6, %rsp
21828 - CFI_ADJUST_CFA_OFFSET -(6*8)
21829 + addq $8*6 + ARG_SKIP, %rsp
21830 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21831 .endm
21832
21833 /*
21834 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21835 movq %rsp, %rsi
21836
21837 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21838 - testl $3, CS-RBP(%rsi)
21839 + testb $3, CS-RBP(%rsi)
21840 je 1f
21841 SWAPGS
21842 /*
21843 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21844 movq_cfi r15, R15+16
21845 movq %r11, 8(%rsp) /* return address */
21846 FIXUP_TOP_OF_STACK %r11, 16
21847 + pax_force_retaddr
21848 ret
21849 CFI_ENDPROC
21850 -END(save_rest)
21851 +ENDPROC(save_rest)
21852
21853 /* save complete stack frame */
21854 .pushsection .kprobes.text, "ax"
21855 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21856 js 1f /* negative -> in kernel */
21857 SWAPGS
21858 xorl %ebx,%ebx
21859 -1: ret
21860 +1: pax_force_retaddr_bts
21861 + ret
21862 CFI_ENDPROC
21863 -END(save_paranoid)
21864 +ENDPROC(save_paranoid)
21865 .popsection
21866
21867 /*
21868 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21869
21870 RESTORE_REST
21871
21872 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21873 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21874 jz 1f
21875
21876 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21877 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21878 RESTORE_REST
21879 jmp int_ret_from_sys_call
21880 CFI_ENDPROC
21881 -END(ret_from_fork)
21882 +ENDPROC(ret_from_fork)
21883
21884 /*
21885 * System call entry. Up to 6 arguments in registers are supported.
21886 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21887 ENTRY(system_call)
21888 CFI_STARTPROC simple
21889 CFI_SIGNAL_FRAME
21890 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21891 + CFI_DEF_CFA rsp,0
21892 CFI_REGISTER rip,rcx
21893 /*CFI_REGISTER rflags,r11*/
21894 SWAPGS_UNSAFE_STACK
21895 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21896
21897 movq %rsp,PER_CPU_VAR(old_rsp)
21898 movq PER_CPU_VAR(kernel_stack),%rsp
21899 + SAVE_ARGS 8*6,0
21900 + pax_enter_kernel_user
21901 +
21902 +#ifdef CONFIG_PAX_RANDKSTACK
21903 + pax_erase_kstack
21904 +#endif
21905 +
21906 /*
21907 * No need to follow this irqs off/on section - it's straight
21908 * and short:
21909 */
21910 ENABLE_INTERRUPTS(CLBR_NONE)
21911 - SAVE_ARGS 8,0
21912 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21913 movq %rcx,RIP-ARGOFFSET(%rsp)
21914 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21915 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21916 + GET_THREAD_INFO(%rcx)
21917 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21918 jnz tracesys
21919 system_call_fastpath:
21920 #if __SYSCALL_MASK == ~0
21921 @@ -640,7 +1082,7 @@ system_call_fastpath:
21922 cmpl $__NR_syscall_max,%eax
21923 #endif
21924 ja badsys
21925 - movq %r10,%rcx
21926 + movq R10-ARGOFFSET(%rsp),%rcx
21927 call *sys_call_table(,%rax,8) # XXX: rip relative
21928 movq %rax,RAX-ARGOFFSET(%rsp)
21929 /*
21930 @@ -654,10 +1096,13 @@ sysret_check:
21931 LOCKDEP_SYS_EXIT
21932 DISABLE_INTERRUPTS(CLBR_NONE)
21933 TRACE_IRQS_OFF
21934 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21935 + GET_THREAD_INFO(%rcx)
21936 + movl TI_flags(%rcx),%edx
21937 andl %edi,%edx
21938 jnz sysret_careful
21939 CFI_REMEMBER_STATE
21940 + pax_exit_kernel_user
21941 + pax_erase_kstack
21942 /*
21943 * sysretq will re-enable interrupts:
21944 */
21945 @@ -709,14 +1154,18 @@ badsys:
21946 * jump back to the normal fast path.
21947 */
21948 auditsys:
21949 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21950 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21951 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21952 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21953 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21954 movq %rax,%rsi /* 2nd arg: syscall number */
21955 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21956 call __audit_syscall_entry
21957 +
21958 + pax_erase_kstack
21959 +
21960 LOAD_ARGS 0 /* reload call-clobbered registers */
21961 + pax_set_fptr_mask
21962 jmp system_call_fastpath
21963
21964 /*
21965 @@ -737,7 +1186,7 @@ sysret_audit:
21966 /* Do syscall tracing */
21967 tracesys:
21968 #ifdef CONFIG_AUDITSYSCALL
21969 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21970 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21971 jz auditsys
21972 #endif
21973 SAVE_REST
21974 @@ -745,12 +1194,16 @@ tracesys:
21975 FIXUP_TOP_OF_STACK %rdi
21976 movq %rsp,%rdi
21977 call syscall_trace_enter
21978 +
21979 + pax_erase_kstack
21980 +
21981 /*
21982 * Reload arg registers from stack in case ptrace changed them.
21983 * We don't reload %rax because syscall_trace_enter() returned
21984 * the value it wants us to use in the table lookup.
21985 */
21986 LOAD_ARGS ARGOFFSET, 1
21987 + pax_set_fptr_mask
21988 RESTORE_REST
21989 #if __SYSCALL_MASK == ~0
21990 cmpq $__NR_syscall_max,%rax
21991 @@ -759,7 +1212,7 @@ tracesys:
21992 cmpl $__NR_syscall_max,%eax
21993 #endif
21994 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21995 - movq %r10,%rcx /* fixup for C */
21996 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21997 call *sys_call_table(,%rax,8)
21998 movq %rax,RAX-ARGOFFSET(%rsp)
21999 /* Use IRET because user could have changed frame */
22000 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
22001 andl %edi,%edx
22002 jnz int_careful
22003 andl $~TS_COMPAT,TI_status(%rcx)
22004 - jmp retint_swapgs
22005 + pax_exit_kernel_user
22006 + pax_erase_kstack
22007 + jmp retint_swapgs_pax
22008
22009 /* Either reschedule or signal or syscall exit tracking needed. */
22010 /* First do a reschedule test. */
22011 @@ -826,7 +1281,7 @@ int_restore_rest:
22012 TRACE_IRQS_OFF
22013 jmp int_with_check
22014 CFI_ENDPROC
22015 -END(system_call)
22016 +ENDPROC(system_call)
22017
22018 .macro FORK_LIKE func
22019 ENTRY(stub_\func)
22020 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22021 DEFAULT_FRAME 0 8 /* offset 8: return address */
22022 call sys_\func
22023 RESTORE_TOP_OF_STACK %r11, 8
22024 + pax_force_retaddr
22025 ret $REST_SKIP /* pop extended registers */
22026 CFI_ENDPROC
22027 -END(stub_\func)
22028 +ENDPROC(stub_\func)
22029 .endm
22030
22031 .macro FIXED_FRAME label,func
22032 @@ -851,9 +1307,10 @@ ENTRY(\label)
22033 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22034 call \func
22035 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22036 + pax_force_retaddr
22037 ret
22038 CFI_ENDPROC
22039 -END(\label)
22040 +ENDPROC(\label)
22041 .endm
22042
22043 FORK_LIKE clone
22044 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22045 movq_cfi_restore R12+8, r12
22046 movq_cfi_restore RBP+8, rbp
22047 movq_cfi_restore RBX+8, rbx
22048 + pax_force_retaddr
22049 ret $REST_SKIP /* pop extended registers */
22050 CFI_ENDPROC
22051 -END(ptregscall_common)
22052 +ENDPROC(ptregscall_common)
22053
22054 ENTRY(stub_execve)
22055 CFI_STARTPROC
22056 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22057 RESTORE_REST
22058 jmp int_ret_from_sys_call
22059 CFI_ENDPROC
22060 -END(stub_execve)
22061 +ENDPROC(stub_execve)
22062
22063 /*
22064 * sigreturn is special because it needs to restore all registers on return.
22065 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22066 RESTORE_REST
22067 jmp int_ret_from_sys_call
22068 CFI_ENDPROC
22069 -END(stub_rt_sigreturn)
22070 +ENDPROC(stub_rt_sigreturn)
22071
22072 #ifdef CONFIG_X86_X32_ABI
22073 ENTRY(stub_x32_rt_sigreturn)
22074 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22075 RESTORE_REST
22076 jmp int_ret_from_sys_call
22077 CFI_ENDPROC
22078 -END(stub_x32_rt_sigreturn)
22079 +ENDPROC(stub_x32_rt_sigreturn)
22080
22081 ENTRY(stub_x32_execve)
22082 CFI_STARTPROC
22083 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22084 RESTORE_REST
22085 jmp int_ret_from_sys_call
22086 CFI_ENDPROC
22087 -END(stub_x32_execve)
22088 +ENDPROC(stub_x32_execve)
22089
22090 #endif
22091
22092 @@ -967,7 +1425,7 @@ vector=vector+1
22093 2: jmp common_interrupt
22094 .endr
22095 CFI_ENDPROC
22096 -END(irq_entries_start)
22097 +ENDPROC(irq_entries_start)
22098
22099 .previous
22100 END(interrupt)
22101 @@ -987,6 +1445,16 @@ END(interrupt)
22102 subq $ORIG_RAX-RBP, %rsp
22103 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22104 SAVE_ARGS_IRQ
22105 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22106 + testb $3, CS(%rdi)
22107 + jnz 1f
22108 + pax_enter_kernel
22109 + jmp 2f
22110 +1: pax_enter_kernel_user
22111 +2:
22112 +#else
22113 + pax_enter_kernel
22114 +#endif
22115 call \func
22116 .endm
22117
22118 @@ -1019,7 +1487,7 @@ ret_from_intr:
22119
22120 exit_intr:
22121 GET_THREAD_INFO(%rcx)
22122 - testl $3,CS-ARGOFFSET(%rsp)
22123 + testb $3,CS-ARGOFFSET(%rsp)
22124 je retint_kernel
22125
22126 /* Interrupt came from user space */
22127 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22128 * The iretq could re-enable interrupts:
22129 */
22130 DISABLE_INTERRUPTS(CLBR_ANY)
22131 + pax_exit_kernel_user
22132 +retint_swapgs_pax:
22133 TRACE_IRQS_IRETQ
22134 SWAPGS
22135 jmp restore_args
22136
22137 retint_restore_args: /* return to kernel space */
22138 DISABLE_INTERRUPTS(CLBR_ANY)
22139 + pax_exit_kernel
22140 + pax_force_retaddr (RIP-ARGOFFSET)
22141 /*
22142 * The iretq could re-enable interrupts:
22143 */
22144 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22145 #endif
22146
22147 CFI_ENDPROC
22148 -END(common_interrupt)
22149 +ENDPROC(common_interrupt)
22150 /*
22151 * End of kprobes section
22152 */
22153 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22154 interrupt \do_sym
22155 jmp ret_from_intr
22156 CFI_ENDPROC
22157 -END(\sym)
22158 +ENDPROC(\sym)
22159 .endm
22160
22161 #ifdef CONFIG_TRACING
22162 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22163 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22164 call error_entry
22165 DEFAULT_FRAME 0
22166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22167 + testb $3, CS(%rsp)
22168 + jnz 1f
22169 + pax_enter_kernel
22170 + jmp 2f
22171 +1: pax_enter_kernel_user
22172 +2:
22173 +#else
22174 + pax_enter_kernel
22175 +#endif
22176 movq %rsp,%rdi /* pt_regs pointer */
22177 xorl %esi,%esi /* no error code */
22178 call \do_sym
22179 jmp error_exit /* %ebx: no swapgs flag */
22180 CFI_ENDPROC
22181 -END(\sym)
22182 +ENDPROC(\sym)
22183 .endm
22184
22185 .macro paranoidzeroentry sym do_sym
22186 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22187 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22188 call save_paranoid
22189 TRACE_IRQS_OFF
22190 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22191 + testb $3, CS(%rsp)
22192 + jnz 1f
22193 + pax_enter_kernel
22194 + jmp 2f
22195 +1: pax_enter_kernel_user
22196 +2:
22197 +#else
22198 + pax_enter_kernel
22199 +#endif
22200 movq %rsp,%rdi /* pt_regs pointer */
22201 xorl %esi,%esi /* no error code */
22202 call \do_sym
22203 jmp paranoid_exit /* %ebx: no swapgs flag */
22204 CFI_ENDPROC
22205 -END(\sym)
22206 +ENDPROC(\sym)
22207 .endm
22208
22209 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22210 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22211 .macro paranoidzeroentry_ist sym do_sym ist
22212 ENTRY(\sym)
22213 INTR_FRAME
22214 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22215 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22216 call save_paranoid
22217 TRACE_IRQS_OFF_DEBUG
22218 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22219 + testb $3, CS(%rsp)
22220 + jnz 1f
22221 + pax_enter_kernel
22222 + jmp 2f
22223 +1: pax_enter_kernel_user
22224 +2:
22225 +#else
22226 + pax_enter_kernel
22227 +#endif
22228 movq %rsp,%rdi /* pt_regs pointer */
22229 xorl %esi,%esi /* no error code */
22230 +#ifdef CONFIG_SMP
22231 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22232 + lea init_tss(%r12), %r12
22233 +#else
22234 + lea init_tss(%rip), %r12
22235 +#endif
22236 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22237 call \do_sym
22238 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22239 jmp paranoid_exit /* %ebx: no swapgs flag */
22240 CFI_ENDPROC
22241 -END(\sym)
22242 +ENDPROC(\sym)
22243 .endm
22244
22245 .macro errorentry sym do_sym
22246 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22247 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22248 call error_entry
22249 DEFAULT_FRAME 0
22250 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22251 + testb $3, CS(%rsp)
22252 + jnz 1f
22253 + pax_enter_kernel
22254 + jmp 2f
22255 +1: pax_enter_kernel_user
22256 +2:
22257 +#else
22258 + pax_enter_kernel
22259 +#endif
22260 movq %rsp,%rdi /* pt_regs pointer */
22261 movq ORIG_RAX(%rsp),%rsi /* get error code */
22262 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22263 call \do_sym
22264 jmp error_exit /* %ebx: no swapgs flag */
22265 CFI_ENDPROC
22266 -END(\sym)
22267 +ENDPROC(\sym)
22268 .endm
22269
22270 /* error code is on the stack already */
22271 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22272 call save_paranoid
22273 DEFAULT_FRAME 0
22274 TRACE_IRQS_OFF
22275 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22276 + testb $3, CS(%rsp)
22277 + jnz 1f
22278 + pax_enter_kernel
22279 + jmp 2f
22280 +1: pax_enter_kernel_user
22281 +2:
22282 +#else
22283 + pax_enter_kernel
22284 +#endif
22285 movq %rsp,%rdi /* pt_regs pointer */
22286 movq ORIG_RAX(%rsp),%rsi /* get error code */
22287 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22288 call \do_sym
22289 jmp paranoid_exit /* %ebx: no swapgs flag */
22290 CFI_ENDPROC
22291 -END(\sym)
22292 +ENDPROC(\sym)
22293 .endm
22294
22295 zeroentry divide_error do_divide_error
22296 @@ -1342,9 +1870,10 @@ gs_change:
22297 2: mfence /* workaround */
22298 SWAPGS
22299 popfq_cfi
22300 + pax_force_retaddr
22301 ret
22302 CFI_ENDPROC
22303 -END(native_load_gs_index)
22304 +ENDPROC(native_load_gs_index)
22305
22306 _ASM_EXTABLE(gs_change,bad_gs)
22307 .section .fixup,"ax"
22308 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22309 CFI_DEF_CFA_REGISTER rsp
22310 CFI_ADJUST_CFA_OFFSET -8
22311 decl PER_CPU_VAR(irq_count)
22312 + pax_force_retaddr
22313 ret
22314 CFI_ENDPROC
22315 -END(call_softirq)
22316 +ENDPROC(call_softirq)
22317
22318 #ifdef CONFIG_XEN
22319 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22320 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22321 decl PER_CPU_VAR(irq_count)
22322 jmp error_exit
22323 CFI_ENDPROC
22324 -END(xen_do_hypervisor_callback)
22325 +ENDPROC(xen_do_hypervisor_callback)
22326
22327 /*
22328 * Hypervisor uses this for application faults while it executes.
22329 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22330 SAVE_ALL
22331 jmp error_exit
22332 CFI_ENDPROC
22333 -END(xen_failsafe_callback)
22334 +ENDPROC(xen_failsafe_callback)
22335
22336 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22337 xen_hvm_callback_vector xen_evtchn_do_upcall
22338 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22339 DEFAULT_FRAME
22340 DISABLE_INTERRUPTS(CLBR_NONE)
22341 TRACE_IRQS_OFF_DEBUG
22342 - testl %ebx,%ebx /* swapgs needed? */
22343 + testl $1,%ebx /* swapgs needed? */
22344 jnz paranoid_restore
22345 - testl $3,CS(%rsp)
22346 + testb $3,CS(%rsp)
22347 jnz paranoid_userspace
22348 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22349 + pax_exit_kernel
22350 + TRACE_IRQS_IRETQ 0
22351 + SWAPGS_UNSAFE_STACK
22352 + RESTORE_ALL 8
22353 + pax_force_retaddr_bts
22354 + jmp irq_return
22355 +#endif
22356 paranoid_swapgs:
22357 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22358 + pax_exit_kernel_user
22359 +#else
22360 + pax_exit_kernel
22361 +#endif
22362 TRACE_IRQS_IRETQ 0
22363 SWAPGS_UNSAFE_STACK
22364 RESTORE_ALL 8
22365 jmp irq_return
22366 paranoid_restore:
22367 + pax_exit_kernel
22368 TRACE_IRQS_IRETQ_DEBUG 0
22369 RESTORE_ALL 8
22370 + pax_force_retaddr_bts
22371 jmp irq_return
22372 paranoid_userspace:
22373 GET_THREAD_INFO(%rcx)
22374 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22375 TRACE_IRQS_OFF
22376 jmp paranoid_userspace
22377 CFI_ENDPROC
22378 -END(paranoid_exit)
22379 +ENDPROC(paranoid_exit)
22380
22381 /*
22382 * Exception entry point. This expects an error code/orig_rax on the stack.
22383 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22384 movq_cfi r14, R14+8
22385 movq_cfi r15, R15+8
22386 xorl %ebx,%ebx
22387 - testl $3,CS+8(%rsp)
22388 + testb $3,CS+8(%rsp)
22389 je error_kernelspace
22390 error_swapgs:
22391 SWAPGS
22392 error_sti:
22393 TRACE_IRQS_OFF
22394 + pax_force_retaddr_bts
22395 ret
22396
22397 /*
22398 @@ -1622,7 +2168,7 @@ bstep_iret:
22399 movq %rcx,RIP+8(%rsp)
22400 jmp error_swapgs
22401 CFI_ENDPROC
22402 -END(error_entry)
22403 +ENDPROC(error_entry)
22404
22405
22406 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22407 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22408 DISABLE_INTERRUPTS(CLBR_NONE)
22409 TRACE_IRQS_OFF
22410 GET_THREAD_INFO(%rcx)
22411 - testl %eax,%eax
22412 + testl $1,%eax
22413 jne retint_kernel
22414 LOCKDEP_SYS_EXIT_IRQ
22415 movl TI_flags(%rcx),%edx
22416 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22417 jnz retint_careful
22418 jmp retint_swapgs
22419 CFI_ENDPROC
22420 -END(error_exit)
22421 +ENDPROC(error_exit)
22422
22423 /*
22424 * Test if a given stack is an NMI stack or not.
22425 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22426 * If %cs was not the kernel segment, then the NMI triggered in user
22427 * space, which means it is definitely not nested.
22428 */
22429 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22430 + je 1f
22431 cmpl $__KERNEL_CS, 16(%rsp)
22432 jne first_nmi
22433 -
22434 +1:
22435 /*
22436 * Check the special variable on the stack to see if NMIs are
22437 * executing.
22438 @@ -1736,8 +2284,7 @@ nested_nmi:
22439
22440 1:
22441 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22442 - leaq -1*8(%rsp), %rdx
22443 - movq %rdx, %rsp
22444 + subq $8, %rsp
22445 CFI_ADJUST_CFA_OFFSET 1*8
22446 leaq -10*8(%rsp), %rdx
22447 pushq_cfi $__KERNEL_DS
22448 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22449 CFI_RESTORE rdx
22450
22451 /* No need to check faults here */
22452 +# pax_force_retaddr_bts
22453 INTERRUPT_RETURN
22454
22455 CFI_RESTORE_STATE
22456 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22457 */
22458 movq %cr2, %r12
22459
22460 + pax_enter_kernel_nmi
22461 +
22462 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22463 movq %rsp,%rdi
22464 movq $-1,%rsi
22465 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22466 movq %r12, %cr2
22467 1:
22468
22469 - testl %ebx,%ebx /* swapgs needed? */
22470 + testl $1,%ebx /* swapgs needed? */
22471 jnz nmi_restore
22472 nmi_swapgs:
22473 SWAPGS_UNSAFE_STACK
22474 nmi_restore:
22475 + pax_exit_kernel_nmi
22476 /* Pop the extra iret frame at once */
22477 RESTORE_ALL 6*8
22478 + testb $3, 8(%rsp)
22479 + jnz 1f
22480 + pax_force_retaddr_bts
22481 +1:
22482
22483 /* Clear the NMI executing stack variable */
22484 movq $0, 5*8(%rsp)
22485 jmp irq_return
22486 CFI_ENDPROC
22487 -END(nmi)
22488 +ENDPROC(nmi)
22489
22490 ENTRY(ignore_sysret)
22491 CFI_STARTPROC
22492 mov $-ENOSYS,%eax
22493 sysret
22494 CFI_ENDPROC
22495 -END(ignore_sysret)
22496 +ENDPROC(ignore_sysret)
22497
22498 /*
22499 * End of kprobes section
22500 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22501 index 42a392a..fbbd930 100644
22502 --- a/arch/x86/kernel/ftrace.c
22503 +++ b/arch/x86/kernel/ftrace.c
22504 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22505 {
22506 unsigned char replaced[MCOUNT_INSN_SIZE];
22507
22508 + ip = ktla_ktva(ip);
22509 +
22510 /*
22511 * Note: Due to modules and __init, code can
22512 * disappear and change, we need to protect against faulting
22513 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22514 unsigned char old[MCOUNT_INSN_SIZE], *new;
22515 int ret;
22516
22517 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22518 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22519 new = ftrace_call_replace(ip, (unsigned long)func);
22520
22521 /* See comment above by declaration of modifying_ftrace_code */
22522 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22523 /* Also update the regs callback function */
22524 if (!ret) {
22525 ip = (unsigned long)(&ftrace_regs_call);
22526 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22527 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22528 new = ftrace_call_replace(ip, (unsigned long)func);
22529 ret = ftrace_modify_code(ip, old, new);
22530 }
22531 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22532 * kernel identity mapping to modify code.
22533 */
22534 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22535 - ip = (unsigned long)__va(__pa_symbol(ip));
22536 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22537
22538 return probe_kernel_write((void *)ip, val, size);
22539 }
22540 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22541 unsigned char replaced[MCOUNT_INSN_SIZE];
22542 unsigned char brk = BREAKPOINT_INSTRUCTION;
22543
22544 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22545 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22546 return -EFAULT;
22547
22548 /* Make sure it is what we expect it to be */
22549 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22550 return ret;
22551
22552 fail_update:
22553 - probe_kernel_write((void *)ip, &old_code[0], 1);
22554 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22555 goto out;
22556 }
22557
22558 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22559 {
22560 unsigned char code[MCOUNT_INSN_SIZE];
22561
22562 + ip = ktla_ktva(ip);
22563 +
22564 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22565 return -EFAULT;
22566
22567 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22568 index 55b6761..a6456fc 100644
22569 --- a/arch/x86/kernel/head64.c
22570 +++ b/arch/x86/kernel/head64.c
22571 @@ -67,12 +67,12 @@ again:
22572 pgd = *pgd_p;
22573
22574 /*
22575 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22576 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22577 + * The use of __early_va rather than __va here is critical:
22578 + * __va would point us back into the dynamic
22579 * range and we might end up looping forever...
22580 */
22581 if (pgd)
22582 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22583 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22584 else {
22585 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22586 reset_early_page_tables();
22587 @@ -82,13 +82,13 @@ again:
22588 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22589 for (i = 0; i < PTRS_PER_PUD; i++)
22590 pud_p[i] = 0;
22591 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22592 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22593 }
22594 pud_p += pud_index(address);
22595 pud = *pud_p;
22596
22597 if (pud)
22598 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22599 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22600 else {
22601 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22602 reset_early_page_tables();
22603 @@ -98,7 +98,7 @@ again:
22604 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22605 for (i = 0; i < PTRS_PER_PMD; i++)
22606 pmd_p[i] = 0;
22607 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22608 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22609 }
22610 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22611 pmd_p[pmd_index(address)] = pmd;
22612 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22613 if (console_loglevel == 10)
22614 early_printk("Kernel alive\n");
22615
22616 - clear_page(init_level4_pgt);
22617 /* set init_level4_pgt kernel high mapping*/
22618 init_level4_pgt[511] = early_level4_pgt[511];
22619
22620 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22621 index 5dd87a8..d68b3f4 100644
22622 --- a/arch/x86/kernel/head_32.S
22623 +++ b/arch/x86/kernel/head_32.S
22624 @@ -26,6 +26,12 @@
22625 /* Physical address */
22626 #define pa(X) ((X) - __PAGE_OFFSET)
22627
22628 +#ifdef CONFIG_PAX_KERNEXEC
22629 +#define ta(X) (X)
22630 +#else
22631 +#define ta(X) ((X) - __PAGE_OFFSET)
22632 +#endif
22633 +
22634 /*
22635 * References to members of the new_cpu_data structure.
22636 */
22637 @@ -55,11 +61,7 @@
22638 * and small than max_low_pfn, otherwise will waste some page table entries
22639 */
22640
22641 -#if PTRS_PER_PMD > 1
22642 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22643 -#else
22644 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22645 -#endif
22646 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22647
22648 /* Number of possible pages in the lowmem region */
22649 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22650 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22651 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22652
22653 /*
22654 + * Real beginning of normal "text" segment
22655 + */
22656 +ENTRY(stext)
22657 +ENTRY(_stext)
22658 +
22659 +/*
22660 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22661 * %esi points to the real-mode code as a 32-bit pointer.
22662 * CS and DS must be 4 GB flat segments, but we don't depend on
22663 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22664 * can.
22665 */
22666 __HEAD
22667 +
22668 +#ifdef CONFIG_PAX_KERNEXEC
22669 + jmp startup_32
22670 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22671 +.fill PAGE_SIZE-5,1,0xcc
22672 +#endif
22673 +
22674 ENTRY(startup_32)
22675 movl pa(stack_start),%ecx
22676
22677 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22678 2:
22679 leal -__PAGE_OFFSET(%ecx),%esp
22680
22681 +#ifdef CONFIG_SMP
22682 + movl $pa(cpu_gdt_table),%edi
22683 + movl $__per_cpu_load,%eax
22684 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22685 + rorl $16,%eax
22686 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22687 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22688 + movl $__per_cpu_end - 1,%eax
22689 + subl $__per_cpu_start,%eax
22690 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22691 +#endif
22692 +
22693 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22694 + movl $NR_CPUS,%ecx
22695 + movl $pa(cpu_gdt_table),%edi
22696 +1:
22697 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22698 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22699 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22700 + addl $PAGE_SIZE_asm,%edi
22701 + loop 1b
22702 +#endif
22703 +
22704 +#ifdef CONFIG_PAX_KERNEXEC
22705 + movl $pa(boot_gdt),%edi
22706 + movl $__LOAD_PHYSICAL_ADDR,%eax
22707 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22708 + rorl $16,%eax
22709 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22710 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22711 + rorl $16,%eax
22712 +
22713 + ljmp $(__BOOT_CS),$1f
22714 +1:
22715 +
22716 + movl $NR_CPUS,%ecx
22717 + movl $pa(cpu_gdt_table),%edi
22718 + addl $__PAGE_OFFSET,%eax
22719 +1:
22720 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22721 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22722 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22723 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22724 + rorl $16,%eax
22725 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22726 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22727 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22728 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22729 + rorl $16,%eax
22730 + addl $PAGE_SIZE_asm,%edi
22731 + loop 1b
22732 +#endif
22733 +
22734 /*
22735 * Clear BSS first so that there are no surprises...
22736 */
22737 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22738 movl %eax, pa(max_pfn_mapped)
22739
22740 /* Do early initialization of the fixmap area */
22741 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22742 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22743 +#ifdef CONFIG_COMPAT_VDSO
22744 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22745 +#else
22746 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22747 +#endif
22748 #else /* Not PAE */
22749
22750 page_pde_offset = (__PAGE_OFFSET >> 20);
22751 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22752 movl %eax, pa(max_pfn_mapped)
22753
22754 /* Do early initialization of the fixmap area */
22755 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22756 - movl %eax,pa(initial_page_table+0xffc)
22757 +#ifdef CONFIG_COMPAT_VDSO
22758 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22759 +#else
22760 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22761 +#endif
22762 #endif
22763
22764 #ifdef CONFIG_PARAVIRT
22765 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22766 cmpl $num_subarch_entries, %eax
22767 jae bad_subarch
22768
22769 - movl pa(subarch_entries)(,%eax,4), %eax
22770 - subl $__PAGE_OFFSET, %eax
22771 - jmp *%eax
22772 + jmp *pa(subarch_entries)(,%eax,4)
22773
22774 bad_subarch:
22775 WEAK(lguest_entry)
22776 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22777 __INITDATA
22778
22779 subarch_entries:
22780 - .long default_entry /* normal x86/PC */
22781 - .long lguest_entry /* lguest hypervisor */
22782 - .long xen_entry /* Xen hypervisor */
22783 - .long default_entry /* Moorestown MID */
22784 + .long ta(default_entry) /* normal x86/PC */
22785 + .long ta(lguest_entry) /* lguest hypervisor */
22786 + .long ta(xen_entry) /* Xen hypervisor */
22787 + .long ta(default_entry) /* Moorestown MID */
22788 num_subarch_entries = (. - subarch_entries) / 4
22789 .previous
22790 #else
22791 @@ -354,6 +426,7 @@ default_entry:
22792 movl pa(mmu_cr4_features),%eax
22793 movl %eax,%cr4
22794
22795 +#ifdef CONFIG_X86_PAE
22796 testb $X86_CR4_PAE, %al # check if PAE is enabled
22797 jz enable_paging
22798
22799 @@ -382,6 +455,9 @@ default_entry:
22800 /* Make changes effective */
22801 wrmsr
22802
22803 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22804 +#endif
22805 +
22806 enable_paging:
22807
22808 /*
22809 @@ -449,14 +525,20 @@ is486:
22810 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22811 movl %eax,%ss # after changing gdt.
22812
22813 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22814 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22815 movl %eax,%ds
22816 movl %eax,%es
22817
22818 movl $(__KERNEL_PERCPU), %eax
22819 movl %eax,%fs # set this cpu's percpu
22820
22821 +#ifdef CONFIG_CC_STACKPROTECTOR
22822 movl $(__KERNEL_STACK_CANARY),%eax
22823 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22824 + movl $(__USER_DS),%eax
22825 +#else
22826 + xorl %eax,%eax
22827 +#endif
22828 movl %eax,%gs
22829
22830 xorl %eax,%eax # Clear LDT
22831 @@ -512,8 +594,11 @@ setup_once:
22832 * relocation. Manually set base address in stack canary
22833 * segment descriptor.
22834 */
22835 - movl $gdt_page,%eax
22836 + movl $cpu_gdt_table,%eax
22837 movl $stack_canary,%ecx
22838 +#ifdef CONFIG_SMP
22839 + addl $__per_cpu_load,%ecx
22840 +#endif
22841 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22842 shrl $16, %ecx
22843 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22844 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22845 /* This is global to keep gas from relaxing the jumps */
22846 ENTRY(early_idt_handler)
22847 cld
22848 - cmpl $2,%ss:early_recursion_flag
22849 + cmpl $1,%ss:early_recursion_flag
22850 je hlt_loop
22851 incl %ss:early_recursion_flag
22852
22853 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22854 pushl (20+6*4)(%esp) /* trapno */
22855 pushl $fault_msg
22856 call printk
22857 -#endif
22858 call dump_stack
22859 +#endif
22860 hlt_loop:
22861 hlt
22862 jmp hlt_loop
22863 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22864 /* This is the default interrupt "handler" :-) */
22865 ALIGN
22866 ignore_int:
22867 - cld
22868 #ifdef CONFIG_PRINTK
22869 + cmpl $2,%ss:early_recursion_flag
22870 + je hlt_loop
22871 + incl %ss:early_recursion_flag
22872 + cld
22873 pushl %eax
22874 pushl %ecx
22875 pushl %edx
22876 @@ -612,9 +700,6 @@ ignore_int:
22877 movl $(__KERNEL_DS),%eax
22878 movl %eax,%ds
22879 movl %eax,%es
22880 - cmpl $2,early_recursion_flag
22881 - je hlt_loop
22882 - incl early_recursion_flag
22883 pushl 16(%esp)
22884 pushl 24(%esp)
22885 pushl 32(%esp)
22886 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22887 /*
22888 * BSS section
22889 */
22890 -__PAGE_ALIGNED_BSS
22891 - .align PAGE_SIZE
22892 #ifdef CONFIG_X86_PAE
22893 +.section .initial_pg_pmd,"a",@progbits
22894 initial_pg_pmd:
22895 .fill 1024*KPMDS,4,0
22896 #else
22897 +.section .initial_page_table,"a",@progbits
22898 ENTRY(initial_page_table)
22899 .fill 1024,4,0
22900 #endif
22901 +.section .initial_pg_fixmap,"a",@progbits
22902 initial_pg_fixmap:
22903 .fill 1024,4,0
22904 +.section .empty_zero_page,"a",@progbits
22905 ENTRY(empty_zero_page)
22906 .fill 4096,1,0
22907 +.section .swapper_pg_dir,"a",@progbits
22908 ENTRY(swapper_pg_dir)
22909 +#ifdef CONFIG_X86_PAE
22910 + .fill 4,8,0
22911 +#else
22912 .fill 1024,4,0
22913 +#endif
22914
22915 /*
22916 * This starts the data section.
22917 */
22918 #ifdef CONFIG_X86_PAE
22919 -__PAGE_ALIGNED_DATA
22920 - /* Page-aligned for the benefit of paravirt? */
22921 - .align PAGE_SIZE
22922 +.section .initial_page_table,"a",@progbits
22923 ENTRY(initial_page_table)
22924 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22925 # if KPMDS == 3
22926 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22927 # error "Kernel PMDs should be 1, 2 or 3"
22928 # endif
22929 .align PAGE_SIZE /* needs to be page-sized too */
22930 +
22931 +#ifdef CONFIG_PAX_PER_CPU_PGD
22932 +ENTRY(cpu_pgd)
22933 + .rept 2*NR_CPUS
22934 + .fill 4,8,0
22935 + .endr
22936 +#endif
22937 +
22938 #endif
22939
22940 .data
22941 .balign 4
22942 ENTRY(stack_start)
22943 - .long init_thread_union+THREAD_SIZE
22944 + .long init_thread_union+THREAD_SIZE-8
22945
22946 __INITRODATA
22947 int_msg:
22948 @@ -722,7 +820,7 @@ fault_msg:
22949 * segment size, and 32-bit linear address value:
22950 */
22951
22952 - .data
22953 +.section .rodata,"a",@progbits
22954 .globl boot_gdt_descr
22955 .globl idt_descr
22956
22957 @@ -731,7 +829,7 @@ fault_msg:
22958 .word 0 # 32 bit align gdt_desc.address
22959 boot_gdt_descr:
22960 .word __BOOT_DS+7
22961 - .long boot_gdt - __PAGE_OFFSET
22962 + .long pa(boot_gdt)
22963
22964 .word 0 # 32-bit align idt_desc.address
22965 idt_descr:
22966 @@ -742,7 +840,7 @@ idt_descr:
22967 .word 0 # 32 bit align gdt_desc.address
22968 ENTRY(early_gdt_descr)
22969 .word GDT_ENTRIES*8-1
22970 - .long gdt_page /* Overwritten for secondary CPUs */
22971 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22972
22973 /*
22974 * The boot_gdt must mirror the equivalent in setup.S and is
22975 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22976 .align L1_CACHE_BYTES
22977 ENTRY(boot_gdt)
22978 .fill GDT_ENTRY_BOOT_CS,8,0
22979 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22980 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22981 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22982 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22983 +
22984 + .align PAGE_SIZE_asm
22985 +ENTRY(cpu_gdt_table)
22986 + .rept NR_CPUS
22987 + .quad 0x0000000000000000 /* NULL descriptor */
22988 + .quad 0x0000000000000000 /* 0x0b reserved */
22989 + .quad 0x0000000000000000 /* 0x13 reserved */
22990 + .quad 0x0000000000000000 /* 0x1b reserved */
22991 +
22992 +#ifdef CONFIG_PAX_KERNEXEC
22993 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22994 +#else
22995 + .quad 0x0000000000000000 /* 0x20 unused */
22996 +#endif
22997 +
22998 + .quad 0x0000000000000000 /* 0x28 unused */
22999 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23000 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23001 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23002 + .quad 0x0000000000000000 /* 0x4b reserved */
23003 + .quad 0x0000000000000000 /* 0x53 reserved */
23004 + .quad 0x0000000000000000 /* 0x5b reserved */
23005 +
23006 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23007 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23008 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23009 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23010 +
23011 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23012 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23013 +
23014 + /*
23015 + * Segments used for calling PnP BIOS have byte granularity.
23016 + * The code segments and data segments have fixed 64k limits,
23017 + * the transfer segment sizes are set at run time.
23018 + */
23019 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23020 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23021 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23022 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23023 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23024 +
23025 + /*
23026 + * The APM segments have byte granularity and their bases
23027 + * are set at run time. All have 64k limits.
23028 + */
23029 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23030 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23031 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23032 +
23033 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23034 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23035 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23036 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23037 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23038 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23039 +
23040 + /* Be sure this is zeroed to avoid false validations in Xen */
23041 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23042 + .endr
23043 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23044 index e1aabdb..73dcad8 100644
23045 --- a/arch/x86/kernel/head_64.S
23046 +++ b/arch/x86/kernel/head_64.S
23047 @@ -20,6 +20,8 @@
23048 #include <asm/processor-flags.h>
23049 #include <asm/percpu.h>
23050 #include <asm/nops.h>
23051 +#include <asm/cpufeature.h>
23052 +#include <asm/alternative-asm.h>
23053
23054 #ifdef CONFIG_PARAVIRT
23055 #include <asm/asm-offsets.h>
23056 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23057 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23058 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23059 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23060 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23061 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23062 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23063 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23064 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23065 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23066
23067 .text
23068 __HEAD
23069 @@ -89,11 +97,23 @@ startup_64:
23070 * Fixup the physical addresses in the page table
23071 */
23072 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23073 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23074 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23075 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23076 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23077 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23078
23079 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23080 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23081 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23082 +#ifndef CONFIG_XEN
23083 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23084 +#endif
23085
23086 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23087 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23088 +
23089 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23090 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23091 +
23092 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23093
23094 /*
23095 * Set up the identity mapping for the switchover. These
23096 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23097 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23098 1:
23099
23100 - /* Enable PAE mode and PGE */
23101 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23102 + /* Enable PAE mode and PSE/PGE */
23103 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23104 movq %rcx, %cr4
23105
23106 /* Setup early boot stage 4 level pagetables. */
23107 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23108 movl $MSR_EFER, %ecx
23109 rdmsr
23110 btsl $_EFER_SCE, %eax /* Enable System Call */
23111 - btl $20,%edi /* No Execute supported? */
23112 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23113 jnc 1f
23114 btsl $_EFER_NX, %eax
23115 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23116 + leaq init_level4_pgt(%rip), %rdi
23117 +#ifndef CONFIG_EFI
23118 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23119 +#endif
23120 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23121 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23122 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23123 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23124 1: wrmsr /* Make changes effective */
23125
23126 /* Setup cr0 */
23127 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23128 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23129 * address given in m16:64.
23130 */
23131 + pax_set_fptr_mask
23132 movq initial_code(%rip),%rax
23133 pushq $0 # fake return address to stop unwinder
23134 pushq $__KERNEL_CS # set correct cs
23135 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23136 call dump_stack
23137 #ifdef CONFIG_KALLSYMS
23138 leaq early_idt_ripmsg(%rip),%rdi
23139 - movq 40(%rsp),%rsi # %rip again
23140 + movq 88(%rsp),%rsi # %rip again
23141 call __print_symbol
23142 #endif
23143 #endif /* EARLY_PRINTK */
23144 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23145 early_recursion_flag:
23146 .long 0
23147
23148 + .section .rodata,"a",@progbits
23149 #ifdef CONFIG_EARLY_PRINTK
23150 early_idt_msg:
23151 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23152 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23153 NEXT_PAGE(early_dynamic_pgts)
23154 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23155
23156 - .data
23157 + .section .rodata,"a",@progbits
23158
23159 -#ifndef CONFIG_XEN
23160 NEXT_PAGE(init_level4_pgt)
23161 - .fill 512,8,0
23162 -#else
23163 -NEXT_PAGE(init_level4_pgt)
23164 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23166 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23167 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23168 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23169 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23170 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23171 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23172 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23173 .org init_level4_pgt + L4_START_KERNEL*8, 0
23174 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23175 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23176
23177 +#ifdef CONFIG_PAX_PER_CPU_PGD
23178 +NEXT_PAGE(cpu_pgd)
23179 + .rept 2*NR_CPUS
23180 + .fill 512,8,0
23181 + .endr
23182 +#endif
23183 +
23184 NEXT_PAGE(level3_ident_pgt)
23185 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23186 +#ifdef CONFIG_XEN
23187 .fill 511, 8, 0
23188 +#else
23189 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23190 + .fill 510,8,0
23191 +#endif
23192 +
23193 +NEXT_PAGE(level3_vmalloc_start_pgt)
23194 + .fill 512,8,0
23195 +
23196 +NEXT_PAGE(level3_vmalloc_end_pgt)
23197 + .fill 512,8,0
23198 +
23199 +NEXT_PAGE(level3_vmemmap_pgt)
23200 + .fill L3_VMEMMAP_START,8,0
23201 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23202 +
23203 NEXT_PAGE(level2_ident_pgt)
23204 - /* Since I easily can, map the first 1G.
23205 + /* Since I easily can, map the first 2G.
23206 * Don't set NX because code runs from these pages.
23207 */
23208 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23209 -#endif
23210 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23211
23212 NEXT_PAGE(level3_kernel_pgt)
23213 .fill L3_START_KERNEL,8,0
23214 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23215 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23216 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23217
23218 +NEXT_PAGE(level2_vmemmap_pgt)
23219 + .fill 512,8,0
23220 +
23221 NEXT_PAGE(level2_kernel_pgt)
23222 /*
23223 * 512 MB kernel mapping. We spend a full page on this pagetable
23224 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23225 KERNEL_IMAGE_SIZE/PMD_SIZE)
23226
23227 NEXT_PAGE(level2_fixmap_pgt)
23228 - .fill 506,8,0
23229 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23230 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23231 - .fill 5,8,0
23232 + .fill 507,8,0
23233 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23234 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23235 + .fill 4,8,0
23236
23237 -NEXT_PAGE(level1_fixmap_pgt)
23238 +NEXT_PAGE(level1_vsyscall_pgt)
23239 .fill 512,8,0
23240
23241 #undef PMDS
23242
23243 - .data
23244 + .align PAGE_SIZE
23245 +ENTRY(cpu_gdt_table)
23246 + .rept NR_CPUS
23247 + .quad 0x0000000000000000 /* NULL descriptor */
23248 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23249 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23250 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23251 + .quad 0x00cffb000000ffff /* __USER32_CS */
23252 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23253 + .quad 0x00affb000000ffff /* __USER_CS */
23254 +
23255 +#ifdef CONFIG_PAX_KERNEXEC
23256 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23257 +#else
23258 + .quad 0x0 /* unused */
23259 +#endif
23260 +
23261 + .quad 0,0 /* TSS */
23262 + .quad 0,0 /* LDT */
23263 + .quad 0,0,0 /* three TLS descriptors */
23264 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23265 + /* asm/segment.h:GDT_ENTRIES must match this */
23266 +
23267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23268 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23269 +#else
23270 + .quad 0x0 /* unused */
23271 +#endif
23272 +
23273 + /* zero the remaining page */
23274 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23275 + .endr
23276 +
23277 .align 16
23278 .globl early_gdt_descr
23279 early_gdt_descr:
23280 .word GDT_ENTRIES*8-1
23281 early_gdt_descr_base:
23282 - .quad INIT_PER_CPU_VAR(gdt_page)
23283 + .quad cpu_gdt_table
23284
23285 ENTRY(phys_base)
23286 /* This must match the first entry in level2_kernel_pgt */
23287 .quad 0x0000000000000000
23288
23289 #include "../../x86/xen/xen-head.S"
23290 -
23291 - __PAGE_ALIGNED_BSS
23292 +
23293 + .section .rodata,"a",@progbits
23294 NEXT_PAGE(empty_zero_page)
23295 .skip PAGE_SIZE
23296 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23297 index 0fa6912..b37438b 100644
23298 --- a/arch/x86/kernel/i386_ksyms_32.c
23299 +++ b/arch/x86/kernel/i386_ksyms_32.c
23300 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23301 EXPORT_SYMBOL(cmpxchg8b_emu);
23302 #endif
23303
23304 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23305 +
23306 /* Networking helper routines. */
23307 EXPORT_SYMBOL(csum_partial_copy_generic);
23308 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23309 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23310
23311 EXPORT_SYMBOL(__get_user_1);
23312 EXPORT_SYMBOL(__get_user_2);
23313 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23314
23315 EXPORT_SYMBOL(csum_partial);
23316 EXPORT_SYMBOL(empty_zero_page);
23317 +
23318 +#ifdef CONFIG_PAX_KERNEXEC
23319 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23320 +#endif
23321 +
23322 +#ifdef CONFIG_PAX_PER_CPU_PGD
23323 +EXPORT_SYMBOL(cpu_pgd);
23324 +#endif
23325 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23326 index 5d576ab..1403a03 100644
23327 --- a/arch/x86/kernel/i387.c
23328 +++ b/arch/x86/kernel/i387.c
23329 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23330 static inline bool interrupted_user_mode(void)
23331 {
23332 struct pt_regs *regs = get_irq_regs();
23333 - return regs && user_mode_vm(regs);
23334 + return regs && user_mode(regs);
23335 }
23336
23337 /*
23338 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23339 index 9a5c460..84868423 100644
23340 --- a/arch/x86/kernel/i8259.c
23341 +++ b/arch/x86/kernel/i8259.c
23342 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23343 static void make_8259A_irq(unsigned int irq)
23344 {
23345 disable_irq_nosync(irq);
23346 - io_apic_irqs &= ~(1<<irq);
23347 + io_apic_irqs &= ~(1UL<<irq);
23348 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23349 i8259A_chip.name);
23350 enable_irq(irq);
23351 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23352 "spurious 8259A interrupt: IRQ%d.\n", irq);
23353 spurious_irq_mask |= irqmask;
23354 }
23355 - atomic_inc(&irq_err_count);
23356 + atomic_inc_unchecked(&irq_err_count);
23357 /*
23358 * Theoretically we do not have to handle this IRQ,
23359 * but in Linux this does not cause problems and is
23360 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23361 /* (slave's support for AEOI in flat mode is to be investigated) */
23362 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23363
23364 + pax_open_kernel();
23365 if (auto_eoi)
23366 /*
23367 * In AEOI mode we just have to mask the interrupt
23368 * when acking.
23369 */
23370 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23371 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23372 else
23373 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23374 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23375 + pax_close_kernel();
23376
23377 udelay(100); /* wait for 8259A to initialize */
23378
23379 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23380 index a979b5b..1d6db75 100644
23381 --- a/arch/x86/kernel/io_delay.c
23382 +++ b/arch/x86/kernel/io_delay.c
23383 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23384 * Quirk table for systems that misbehave (lock up, etc.) if port
23385 * 0x80 is used:
23386 */
23387 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23388 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23389 {
23390 .callback = dmi_io_delay_0xed_port,
23391 .ident = "Compaq Presario V6000",
23392 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23393 index 4ddaf66..6292f4e 100644
23394 --- a/arch/x86/kernel/ioport.c
23395 +++ b/arch/x86/kernel/ioport.c
23396 @@ -6,6 +6,7 @@
23397 #include <linux/sched.h>
23398 #include <linux/kernel.h>
23399 #include <linux/capability.h>
23400 +#include <linux/security.h>
23401 #include <linux/errno.h>
23402 #include <linux/types.h>
23403 #include <linux/ioport.h>
23404 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23405
23406 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23407 return -EINVAL;
23408 +#ifdef CONFIG_GRKERNSEC_IO
23409 + if (turn_on && grsec_disable_privio) {
23410 + gr_handle_ioperm();
23411 + return -EPERM;
23412 + }
23413 +#endif
23414 if (turn_on && !capable(CAP_SYS_RAWIO))
23415 return -EPERM;
23416
23417 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23418 * because the ->io_bitmap_max value must match the bitmap
23419 * contents:
23420 */
23421 - tss = &per_cpu(init_tss, get_cpu());
23422 + tss = init_tss + get_cpu();
23423
23424 if (turn_on)
23425 bitmap_clear(t->io_bitmap_ptr, from, num);
23426 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23427 return -EINVAL;
23428 /* Trying to gain more privileges? */
23429 if (level > old) {
23430 +#ifdef CONFIG_GRKERNSEC_IO
23431 + if (grsec_disable_privio) {
23432 + gr_handle_iopl();
23433 + return -EPERM;
23434 + }
23435 +#endif
23436 if (!capable(CAP_SYS_RAWIO))
23437 return -EPERM;
23438 }
23439 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23440 index 3a8185c..3c042ee 100644
23441 --- a/arch/x86/kernel/irq.c
23442 +++ b/arch/x86/kernel/irq.c
23443 @@ -21,7 +21,7 @@
23444 #define CREATE_TRACE_POINTS
23445 #include <asm/trace/irq_vectors.h>
23446
23447 -atomic_t irq_err_count;
23448 +atomic_unchecked_t irq_err_count;
23449
23450 /* Function pointer for generic interrupt vector handling */
23451 void (*x86_platform_ipi_callback)(void) = NULL;
23452 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23453 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23454 seq_printf(p, " Machine check polls\n");
23455 #endif
23456 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23457 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23458 #if defined(CONFIG_X86_IO_APIC)
23459 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23460 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23461 #endif
23462 return 0;
23463 }
23464 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23465
23466 u64 arch_irq_stat(void)
23467 {
23468 - u64 sum = atomic_read(&irq_err_count);
23469 + u64 sum = atomic_read_unchecked(&irq_err_count);
23470 return sum;
23471 }
23472
23473 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23474 index 4186755..784efa0 100644
23475 --- a/arch/x86/kernel/irq_32.c
23476 +++ b/arch/x86/kernel/irq_32.c
23477 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23478 __asm__ __volatile__("andl %%esp,%0" :
23479 "=r" (sp) : "0" (THREAD_SIZE - 1));
23480
23481 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23482 + return sp < STACK_WARN;
23483 }
23484
23485 static void print_stack_overflow(void)
23486 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23487 * per-CPU IRQ handling contexts (thread information and stack)
23488 */
23489 union irq_ctx {
23490 - struct thread_info tinfo;
23491 - u32 stack[THREAD_SIZE/sizeof(u32)];
23492 + unsigned long previous_esp;
23493 + u32 stack[THREAD_SIZE/sizeof(u32)];
23494 } __attribute__((aligned(THREAD_SIZE)));
23495
23496 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23497 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23498 static inline int
23499 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23500 {
23501 - union irq_ctx *curctx, *irqctx;
23502 + union irq_ctx *irqctx;
23503 u32 *isp, arg1, arg2;
23504
23505 - curctx = (union irq_ctx *) current_thread_info();
23506 irqctx = __this_cpu_read(hardirq_ctx);
23507
23508 /*
23509 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23510 * handler) we can't do that and just have to keep using the
23511 * current stack (which is the irq stack already after all)
23512 */
23513 - if (unlikely(curctx == irqctx))
23514 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23515 return 0;
23516
23517 /* build the stack frame on the IRQ stack */
23518 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23519 - irqctx->tinfo.task = curctx->tinfo.task;
23520 - irqctx->tinfo.previous_esp = current_stack_pointer;
23521 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23522 + irqctx->previous_esp = current_stack_pointer;
23523
23524 - /* Copy the preempt_count so that the [soft]irq checks work. */
23525 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23526 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23527 + __set_fs(MAKE_MM_SEG(0));
23528 +#endif
23529
23530 if (unlikely(overflow))
23531 call_on_stack(print_stack_overflow, isp);
23532 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23533 : "0" (irq), "1" (desc), "2" (isp),
23534 "D" (desc->handle_irq)
23535 : "memory", "cc", "ecx");
23536 +
23537 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23538 + __set_fs(current_thread_info()->addr_limit);
23539 +#endif
23540 +
23541 return 1;
23542 }
23543
23544 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23545 */
23546 void irq_ctx_init(int cpu)
23547 {
23548 - union irq_ctx *irqctx;
23549 -
23550 if (per_cpu(hardirq_ctx, cpu))
23551 return;
23552
23553 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23554 - THREADINFO_GFP,
23555 - THREAD_SIZE_ORDER));
23556 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23557 - irqctx->tinfo.cpu = cpu;
23558 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23559 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23560 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23561 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23562
23563 - per_cpu(hardirq_ctx, cpu) = irqctx;
23564 -
23565 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23566 - THREADINFO_GFP,
23567 - THREAD_SIZE_ORDER));
23568 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23569 - irqctx->tinfo.cpu = cpu;
23570 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23571 -
23572 - per_cpu(softirq_ctx, cpu) = irqctx;
23573 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23574 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23575
23576 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23577 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23578 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23579 asmlinkage void do_softirq(void)
23580 {
23581 unsigned long flags;
23582 - struct thread_info *curctx;
23583 union irq_ctx *irqctx;
23584 u32 *isp;
23585
23586 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23587 local_irq_save(flags);
23588
23589 if (local_softirq_pending()) {
23590 - curctx = current_thread_info();
23591 irqctx = __this_cpu_read(softirq_ctx);
23592 - irqctx->tinfo.task = curctx->task;
23593 - irqctx->tinfo.previous_esp = current_stack_pointer;
23594 + irqctx->previous_esp = current_stack_pointer;
23595
23596 /* build the stack frame on the softirq stack */
23597 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23598 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23599 +
23600 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23601 + __set_fs(MAKE_MM_SEG(0));
23602 +#endif
23603
23604 call_on_stack(__do_softirq, isp);
23605 +
23606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23607 + __set_fs(current_thread_info()->addr_limit);
23608 +#endif
23609 +
23610 /*
23611 * Shouldn't happen, we returned above if in_interrupt():
23612 */
23613 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23614 if (unlikely(!desc))
23615 return false;
23616
23617 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23618 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23619 if (unlikely(overflow))
23620 print_stack_overflow();
23621 desc->handle_irq(irq, desc);
23622 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23623 index d04d3ec..ea4b374 100644
23624 --- a/arch/x86/kernel/irq_64.c
23625 +++ b/arch/x86/kernel/irq_64.c
23626 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23627 u64 estack_top, estack_bottom;
23628 u64 curbase = (u64)task_stack_page(current);
23629
23630 - if (user_mode_vm(regs))
23631 + if (user_mode(regs))
23632 return;
23633
23634 if (regs->sp >= curbase + sizeof(struct thread_info) +
23635 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23636 index dc1404b..bbc43e7 100644
23637 --- a/arch/x86/kernel/kdebugfs.c
23638 +++ b/arch/x86/kernel/kdebugfs.c
23639 @@ -27,7 +27,7 @@ struct setup_data_node {
23640 u32 len;
23641 };
23642
23643 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23644 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23645 size_t count, loff_t *ppos)
23646 {
23647 struct setup_data_node *node = file->private_data;
23648 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23649 index 836f832..a8bda67 100644
23650 --- a/arch/x86/kernel/kgdb.c
23651 +++ b/arch/x86/kernel/kgdb.c
23652 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23653 #ifdef CONFIG_X86_32
23654 switch (regno) {
23655 case GDB_SS:
23656 - if (!user_mode_vm(regs))
23657 + if (!user_mode(regs))
23658 *(unsigned long *)mem = __KERNEL_DS;
23659 break;
23660 case GDB_SP:
23661 - if (!user_mode_vm(regs))
23662 + if (!user_mode(regs))
23663 *(unsigned long *)mem = kernel_stack_pointer(regs);
23664 break;
23665 case GDB_GS:
23666 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23667 bp->attr.bp_addr = breakinfo[breakno].addr;
23668 bp->attr.bp_len = breakinfo[breakno].len;
23669 bp->attr.bp_type = breakinfo[breakno].type;
23670 - info->address = breakinfo[breakno].addr;
23671 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23672 + info->address = ktla_ktva(breakinfo[breakno].addr);
23673 + else
23674 + info->address = breakinfo[breakno].addr;
23675 info->len = breakinfo[breakno].len;
23676 info->type = breakinfo[breakno].type;
23677 val = arch_install_hw_breakpoint(bp);
23678 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23679 case 'k':
23680 /* clear the trace bit */
23681 linux_regs->flags &= ~X86_EFLAGS_TF;
23682 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23683 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23684
23685 /* set the trace bit if we're stepping */
23686 if (remcomInBuffer[0] == 's') {
23687 linux_regs->flags |= X86_EFLAGS_TF;
23688 - atomic_set(&kgdb_cpu_doing_single_step,
23689 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23690 raw_smp_processor_id());
23691 }
23692
23693 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23694
23695 switch (cmd) {
23696 case DIE_DEBUG:
23697 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23698 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23699 if (user_mode(regs))
23700 return single_step_cont(regs, args);
23701 break;
23702 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23703 #endif /* CONFIG_DEBUG_RODATA */
23704
23705 bpt->type = BP_BREAKPOINT;
23706 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23707 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23708 BREAK_INSTR_SIZE);
23709 if (err)
23710 return err;
23711 - err = probe_kernel_write((char *)bpt->bpt_addr,
23712 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23713 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23714 #ifdef CONFIG_DEBUG_RODATA
23715 if (!err)
23716 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23717 return -EBUSY;
23718 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23719 BREAK_INSTR_SIZE);
23720 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23721 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23722 if (err)
23723 return err;
23724 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23725 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23726 if (mutex_is_locked(&text_mutex))
23727 goto knl_write;
23728 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23729 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23730 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23731 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23732 goto knl_write;
23733 return err;
23734 knl_write:
23735 #endif /* CONFIG_DEBUG_RODATA */
23736 - return probe_kernel_write((char *)bpt->bpt_addr,
23737 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23738 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23739 }
23740
23741 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23742 index 211bce4..6e2580a 100644
23743 --- a/arch/x86/kernel/kprobes/core.c
23744 +++ b/arch/x86/kernel/kprobes/core.c
23745 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23746 s32 raddr;
23747 } __packed *insn;
23748
23749 - insn = (struct __arch_relative_insn *)from;
23750 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23751 +
23752 + pax_open_kernel();
23753 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23754 insn->op = op;
23755 + pax_close_kernel();
23756 }
23757
23758 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23759 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23760 kprobe_opcode_t opcode;
23761 kprobe_opcode_t *orig_opcodes = opcodes;
23762
23763 - if (search_exception_tables((unsigned long)opcodes))
23764 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23765 return 0; /* Page fault may occur on this address. */
23766
23767 retry:
23768 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23769 * for the first byte, we can recover the original instruction
23770 * from it and kp->opcode.
23771 */
23772 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23773 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23774 buf[0] = kp->opcode;
23775 - return (unsigned long)buf;
23776 + return ktva_ktla((unsigned long)buf);
23777 }
23778
23779 /*
23780 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23781 /* Another subsystem puts a breakpoint, failed to recover */
23782 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23783 return 0;
23784 + pax_open_kernel();
23785 memcpy(dest, insn.kaddr, insn.length);
23786 + pax_close_kernel();
23787
23788 #ifdef CONFIG_X86_64
23789 if (insn_rip_relative(&insn)) {
23790 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23791 return 0;
23792 }
23793 disp = (u8 *) dest + insn_offset_displacement(&insn);
23794 + pax_open_kernel();
23795 *(s32 *) disp = (s32) newdisp;
23796 + pax_close_kernel();
23797 }
23798 #endif
23799 return insn.length;
23800 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23801 * nor set current_kprobe, because it doesn't use single
23802 * stepping.
23803 */
23804 - regs->ip = (unsigned long)p->ainsn.insn;
23805 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23806 preempt_enable_no_resched();
23807 return;
23808 }
23809 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23810 regs->flags &= ~X86_EFLAGS_IF;
23811 /* single step inline if the instruction is an int3 */
23812 if (p->opcode == BREAKPOINT_INSTRUCTION)
23813 - regs->ip = (unsigned long)p->addr;
23814 + regs->ip = ktla_ktva((unsigned long)p->addr);
23815 else
23816 - regs->ip = (unsigned long)p->ainsn.insn;
23817 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23818 }
23819
23820 /*
23821 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23822 setup_singlestep(p, regs, kcb, 0);
23823 return 1;
23824 }
23825 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23826 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23827 /*
23828 * The breakpoint instruction was removed right
23829 * after we hit it. Another cpu has removed
23830 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23831 " movq %rax, 152(%rsp)\n"
23832 RESTORE_REGS_STRING
23833 " popfq\n"
23834 +#ifdef KERNEXEC_PLUGIN
23835 + " btsq $63,(%rsp)\n"
23836 +#endif
23837 #else
23838 " pushf\n"
23839 SAVE_REGS_STRING
23840 @@ -779,7 +789,7 @@ static void __kprobes
23841 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23842 {
23843 unsigned long *tos = stack_addr(regs);
23844 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23845 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23846 unsigned long orig_ip = (unsigned long)p->addr;
23847 kprobe_opcode_t *insn = p->ainsn.insn;
23848
23849 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23850 struct die_args *args = data;
23851 int ret = NOTIFY_DONE;
23852
23853 - if (args->regs && user_mode_vm(args->regs))
23854 + if (args->regs && user_mode(args->regs))
23855 return ret;
23856
23857 switch (val) {
23858 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23859 index 76dc6f0..66bdfc3 100644
23860 --- a/arch/x86/kernel/kprobes/opt.c
23861 +++ b/arch/x86/kernel/kprobes/opt.c
23862 @@ -79,6 +79,7 @@ found:
23863 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23864 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23865 {
23866 + pax_open_kernel();
23867 #ifdef CONFIG_X86_64
23868 *addr++ = 0x48;
23869 *addr++ = 0xbf;
23870 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23871 *addr++ = 0xb8;
23872 #endif
23873 *(unsigned long *)addr = val;
23874 + pax_close_kernel();
23875 }
23876
23877 static void __used __kprobes kprobes_optinsn_template_holder(void)
23878 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23879 * Verify if the address gap is in 2GB range, because this uses
23880 * a relative jump.
23881 */
23882 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23883 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23884 if (abs(rel) > 0x7fffffff)
23885 return -ERANGE;
23886
23887 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23888 op->optinsn.size = ret;
23889
23890 /* Copy arch-dep-instance from template */
23891 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23892 + pax_open_kernel();
23893 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23894 + pax_close_kernel();
23895
23896 /* Set probe information */
23897 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23898
23899 /* Set probe function call */
23900 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23901 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23902
23903 /* Set returning jmp instruction at the tail of out-of-line buffer */
23904 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23905 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23906 (u8 *)op->kp.addr + op->optinsn.size);
23907
23908 flush_icache_range((unsigned long) buf,
23909 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23910 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23911
23912 /* Backup instructions which will be replaced by jump address */
23913 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23914 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23915 RELATIVE_ADDR_SIZE);
23916
23917 insn_buf[0] = RELATIVEJUMP_OPCODE;
23918 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23919 /* This kprobe is really able to run optimized path. */
23920 op = container_of(p, struct optimized_kprobe, kp);
23921 /* Detour through copied instructions */
23922 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23923 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23924 if (!reenter)
23925 reset_current_kprobe();
23926 preempt_enable_no_resched();
23927 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23928 index ebc9873..1b9724b 100644
23929 --- a/arch/x86/kernel/ldt.c
23930 +++ b/arch/x86/kernel/ldt.c
23931 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23932 if (reload) {
23933 #ifdef CONFIG_SMP
23934 preempt_disable();
23935 - load_LDT(pc);
23936 + load_LDT_nolock(pc);
23937 if (!cpumask_equal(mm_cpumask(current->mm),
23938 cpumask_of(smp_processor_id())))
23939 smp_call_function(flush_ldt, current->mm, 1);
23940 preempt_enable();
23941 #else
23942 - load_LDT(pc);
23943 + load_LDT_nolock(pc);
23944 #endif
23945 }
23946 if (oldsize) {
23947 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23948 return err;
23949
23950 for (i = 0; i < old->size; i++)
23951 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23952 + write_ldt_entry(new->ldt, i, old->ldt + i);
23953 return 0;
23954 }
23955
23956 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23957 retval = copy_ldt(&mm->context, &old_mm->context);
23958 mutex_unlock(&old_mm->context.lock);
23959 }
23960 +
23961 + if (tsk == current) {
23962 + mm->context.vdso = 0;
23963 +
23964 +#ifdef CONFIG_X86_32
23965 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23966 + mm->context.user_cs_base = 0UL;
23967 + mm->context.user_cs_limit = ~0UL;
23968 +
23969 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23970 + cpus_clear(mm->context.cpu_user_cs_mask);
23971 +#endif
23972 +
23973 +#endif
23974 +#endif
23975 +
23976 + }
23977 +
23978 return retval;
23979 }
23980
23981 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23982 }
23983 }
23984
23985 +#ifdef CONFIG_PAX_SEGMEXEC
23986 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23987 + error = -EINVAL;
23988 + goto out_unlock;
23989 + }
23990 +#endif
23991 +
23992 fill_ldt(&ldt, &ldt_info);
23993 if (oldmode)
23994 ldt.avl = 0;
23995 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23996 index 5b19e4d..6476a76 100644
23997 --- a/arch/x86/kernel/machine_kexec_32.c
23998 +++ b/arch/x86/kernel/machine_kexec_32.c
23999 @@ -26,7 +26,7 @@
24000 #include <asm/cacheflush.h>
24001 #include <asm/debugreg.h>
24002
24003 -static void set_idt(void *newidt, __u16 limit)
24004 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24005 {
24006 struct desc_ptr curidt;
24007
24008 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24009 }
24010
24011
24012 -static void set_gdt(void *newgdt, __u16 limit)
24013 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24014 {
24015 struct desc_ptr curgdt;
24016
24017 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24018 }
24019
24020 control_page = page_address(image->control_code_page);
24021 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24022 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24023
24024 relocate_kernel_ptr = control_page;
24025 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24026 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24027 index 15c9876..0a43909 100644
24028 --- a/arch/x86/kernel/microcode_core.c
24029 +++ b/arch/x86/kernel/microcode_core.c
24030 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24031 return NOTIFY_OK;
24032 }
24033
24034 -static struct notifier_block __refdata mc_cpu_notifier = {
24035 +static struct notifier_block mc_cpu_notifier = {
24036 .notifier_call = mc_cpu_callback,
24037 };
24038
24039 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24040 index 5fb2ceb..3ae90bb 100644
24041 --- a/arch/x86/kernel/microcode_intel.c
24042 +++ b/arch/x86/kernel/microcode_intel.c
24043 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24044
24045 static int get_ucode_user(void *to, const void *from, size_t n)
24046 {
24047 - return copy_from_user(to, from, n);
24048 + return copy_from_user(to, (const void __force_user *)from, n);
24049 }
24050
24051 static enum ucode_state
24052 request_microcode_user(int cpu, const void __user *buf, size_t size)
24053 {
24054 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24055 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24056 }
24057
24058 static void microcode_fini_cpu(int cpu)
24059 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24060 index 216a4d7..228255a 100644
24061 --- a/arch/x86/kernel/module.c
24062 +++ b/arch/x86/kernel/module.c
24063 @@ -43,15 +43,60 @@ do { \
24064 } while (0)
24065 #endif
24066
24067 -void *module_alloc(unsigned long size)
24068 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24069 {
24070 - if (PAGE_ALIGN(size) > MODULES_LEN)
24071 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24072 return NULL;
24073 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24074 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24075 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24076 -1, __builtin_return_address(0));
24077 }
24078
24079 +void *module_alloc(unsigned long size)
24080 +{
24081 +
24082 +#ifdef CONFIG_PAX_KERNEXEC
24083 + return __module_alloc(size, PAGE_KERNEL);
24084 +#else
24085 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24086 +#endif
24087 +
24088 +}
24089 +
24090 +#ifdef CONFIG_PAX_KERNEXEC
24091 +#ifdef CONFIG_X86_32
24092 +void *module_alloc_exec(unsigned long size)
24093 +{
24094 + struct vm_struct *area;
24095 +
24096 + if (size == 0)
24097 + return NULL;
24098 +
24099 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24100 + return area ? area->addr : NULL;
24101 +}
24102 +EXPORT_SYMBOL(module_alloc_exec);
24103 +
24104 +void module_free_exec(struct module *mod, void *module_region)
24105 +{
24106 + vunmap(module_region);
24107 +}
24108 +EXPORT_SYMBOL(module_free_exec);
24109 +#else
24110 +void module_free_exec(struct module *mod, void *module_region)
24111 +{
24112 + module_free(mod, module_region);
24113 +}
24114 +EXPORT_SYMBOL(module_free_exec);
24115 +
24116 +void *module_alloc_exec(unsigned long size)
24117 +{
24118 + return __module_alloc(size, PAGE_KERNEL_RX);
24119 +}
24120 +EXPORT_SYMBOL(module_alloc_exec);
24121 +#endif
24122 +#endif
24123 +
24124 #ifdef CONFIG_X86_32
24125 int apply_relocate(Elf32_Shdr *sechdrs,
24126 const char *strtab,
24127 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24128 unsigned int i;
24129 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24130 Elf32_Sym *sym;
24131 - uint32_t *location;
24132 + uint32_t *plocation, location;
24133
24134 DEBUGP("Applying relocate section %u to %u\n",
24135 relsec, sechdrs[relsec].sh_info);
24136 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24137 /* This is where to make the change */
24138 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24139 - + rel[i].r_offset;
24140 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24141 + location = (uint32_t)plocation;
24142 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24143 + plocation = ktla_ktva((void *)plocation);
24144 /* This is the symbol it is referring to. Note that all
24145 undefined symbols have been resolved. */
24146 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24147 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24148 switch (ELF32_R_TYPE(rel[i].r_info)) {
24149 case R_386_32:
24150 /* We add the value into the location given */
24151 - *location += sym->st_value;
24152 + pax_open_kernel();
24153 + *plocation += sym->st_value;
24154 + pax_close_kernel();
24155 break;
24156 case R_386_PC32:
24157 /* Add the value, subtract its position */
24158 - *location += sym->st_value - (uint32_t)location;
24159 + pax_open_kernel();
24160 + *plocation += sym->st_value - location;
24161 + pax_close_kernel();
24162 break;
24163 default:
24164 pr_err("%s: Unknown relocation: %u\n",
24165 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24166 case R_X86_64_NONE:
24167 break;
24168 case R_X86_64_64:
24169 + pax_open_kernel();
24170 *(u64 *)loc = val;
24171 + pax_close_kernel();
24172 break;
24173 case R_X86_64_32:
24174 + pax_open_kernel();
24175 *(u32 *)loc = val;
24176 + pax_close_kernel();
24177 if (val != *(u32 *)loc)
24178 goto overflow;
24179 break;
24180 case R_X86_64_32S:
24181 + pax_open_kernel();
24182 *(s32 *)loc = val;
24183 + pax_close_kernel();
24184 if ((s64)val != *(s32 *)loc)
24185 goto overflow;
24186 break;
24187 case R_X86_64_PC32:
24188 val -= (u64)loc;
24189 + pax_open_kernel();
24190 *(u32 *)loc = val;
24191 + pax_close_kernel();
24192 +
24193 #if 0
24194 if ((s64)val != *(s32 *)loc)
24195 goto overflow;
24196 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24197 index 88458fa..349f7a4 100644
24198 --- a/arch/x86/kernel/msr.c
24199 +++ b/arch/x86/kernel/msr.c
24200 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24201 return notifier_from_errno(err);
24202 }
24203
24204 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24205 +static struct notifier_block msr_class_cpu_notifier = {
24206 .notifier_call = msr_class_cpu_callback,
24207 };
24208
24209 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24210 index ba77ebc..65da999 100644
24211 --- a/arch/x86/kernel/nmi.c
24212 +++ b/arch/x86/kernel/nmi.c
24213 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24214 return handled;
24215 }
24216
24217 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24218 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24219 {
24220 struct nmi_desc *desc = nmi_to_desc(type);
24221 unsigned long flags;
24222 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24223 * event confuses some handlers (kdump uses this flag)
24224 */
24225 if (action->flags & NMI_FLAG_FIRST)
24226 - list_add_rcu(&action->list, &desc->head);
24227 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24228 else
24229 - list_add_tail_rcu(&action->list, &desc->head);
24230 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24231
24232 spin_unlock_irqrestore(&desc->lock, flags);
24233 return 0;
24234 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24235 if (!strcmp(n->name, name)) {
24236 WARN(in_nmi(),
24237 "Trying to free NMI (%s) from NMI context!\n", n->name);
24238 - list_del_rcu(&n->list);
24239 + pax_list_del_rcu((struct list_head *)&n->list);
24240 break;
24241 }
24242 }
24243 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24244 dotraplinkage notrace __kprobes void
24245 do_nmi(struct pt_regs *regs, long error_code)
24246 {
24247 +
24248 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24249 + if (!user_mode(regs)) {
24250 + unsigned long cs = regs->cs & 0xFFFF;
24251 + unsigned long ip = ktva_ktla(regs->ip);
24252 +
24253 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24254 + regs->ip = ip;
24255 + }
24256 +#endif
24257 +
24258 nmi_nesting_preprocess(regs);
24259
24260 nmi_enter();
24261 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24262 index 6d9582e..f746287 100644
24263 --- a/arch/x86/kernel/nmi_selftest.c
24264 +++ b/arch/x86/kernel/nmi_selftest.c
24265 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24266 {
24267 /* trap all the unknown NMIs we may generate */
24268 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24269 - __initdata);
24270 + __initconst);
24271 }
24272
24273 static void __init cleanup_nmi_testsuite(void)
24274 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24275 unsigned long timeout;
24276
24277 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24278 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24279 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24280 nmi_fail = FAILURE;
24281 return;
24282 }
24283 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24284 index 676b8c7..870ba04 100644
24285 --- a/arch/x86/kernel/paravirt-spinlocks.c
24286 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24287 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24288 arch_spin_lock(lock);
24289 }
24290
24291 -struct pv_lock_ops pv_lock_ops = {
24292 +struct pv_lock_ops pv_lock_ops __read_only = {
24293 #ifdef CONFIG_SMP
24294 .spin_is_locked = __ticket_spin_is_locked,
24295 .spin_is_contended = __ticket_spin_is_contended,
24296 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24297 index cd6de64..27c6af0 100644
24298 --- a/arch/x86/kernel/paravirt.c
24299 +++ b/arch/x86/kernel/paravirt.c
24300 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24301 {
24302 return x;
24303 }
24304 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24305 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24306 +#endif
24307
24308 void __init default_banner(void)
24309 {
24310 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24311 if (opfunc == NULL)
24312 /* If there's no function, patch it with a ud2a (BUG) */
24313 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24314 - else if (opfunc == _paravirt_nop)
24315 + else if (opfunc == (void *)_paravirt_nop)
24316 /* If the operation is a nop, then nop the callsite */
24317 ret = paravirt_patch_nop();
24318
24319 /* identity functions just return their single argument */
24320 - else if (opfunc == _paravirt_ident_32)
24321 + else if (opfunc == (void *)_paravirt_ident_32)
24322 ret = paravirt_patch_ident_32(insnbuf, len);
24323 - else if (opfunc == _paravirt_ident_64)
24324 + else if (opfunc == (void *)_paravirt_ident_64)
24325 ret = paravirt_patch_ident_64(insnbuf, len);
24326 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24327 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24328 + ret = paravirt_patch_ident_64(insnbuf, len);
24329 +#endif
24330
24331 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24332 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24333 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24334 if (insn_len > len || start == NULL)
24335 insn_len = len;
24336 else
24337 - memcpy(insnbuf, start, insn_len);
24338 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24339
24340 return insn_len;
24341 }
24342 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24343 return this_cpu_read(paravirt_lazy_mode);
24344 }
24345
24346 -struct pv_info pv_info = {
24347 +struct pv_info pv_info __read_only = {
24348 .name = "bare hardware",
24349 .paravirt_enabled = 0,
24350 .kernel_rpl = 0,
24351 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24352 #endif
24353 };
24354
24355 -struct pv_init_ops pv_init_ops = {
24356 +struct pv_init_ops pv_init_ops __read_only = {
24357 .patch = native_patch,
24358 };
24359
24360 -struct pv_time_ops pv_time_ops = {
24361 +struct pv_time_ops pv_time_ops __read_only = {
24362 .sched_clock = native_sched_clock,
24363 .steal_clock = native_steal_clock,
24364 };
24365
24366 -struct pv_irq_ops pv_irq_ops = {
24367 +struct pv_irq_ops pv_irq_ops __read_only = {
24368 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24369 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24370 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24371 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24372 #endif
24373 };
24374
24375 -struct pv_cpu_ops pv_cpu_ops = {
24376 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24377 .cpuid = native_cpuid,
24378 .get_debugreg = native_get_debugreg,
24379 .set_debugreg = native_set_debugreg,
24380 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24381 .end_context_switch = paravirt_nop,
24382 };
24383
24384 -struct pv_apic_ops pv_apic_ops = {
24385 +struct pv_apic_ops pv_apic_ops __read_only= {
24386 #ifdef CONFIG_X86_LOCAL_APIC
24387 .startup_ipi_hook = paravirt_nop,
24388 #endif
24389 };
24390
24391 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24392 +#ifdef CONFIG_X86_32
24393 +#ifdef CONFIG_X86_PAE
24394 +/* 64-bit pagetable entries */
24395 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24396 +#else
24397 /* 32-bit pagetable entries */
24398 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24399 +#endif
24400 #else
24401 /* 64-bit pagetable entries */
24402 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24403 #endif
24404
24405 -struct pv_mmu_ops pv_mmu_ops = {
24406 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24407
24408 .read_cr2 = native_read_cr2,
24409 .write_cr2 = native_write_cr2,
24410 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24411 .make_pud = PTE_IDENT,
24412
24413 .set_pgd = native_set_pgd,
24414 + .set_pgd_batched = native_set_pgd_batched,
24415 #endif
24416 #endif /* PAGETABLE_LEVELS >= 3 */
24417
24418 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24419 },
24420
24421 .set_fixmap = native_set_fixmap,
24422 +
24423 +#ifdef CONFIG_PAX_KERNEXEC
24424 + .pax_open_kernel = native_pax_open_kernel,
24425 + .pax_close_kernel = native_pax_close_kernel,
24426 +#endif
24427 +
24428 };
24429
24430 EXPORT_SYMBOL_GPL(pv_time_ops);
24431 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24432 index 299d493..2ccb0ee 100644
24433 --- a/arch/x86/kernel/pci-calgary_64.c
24434 +++ b/arch/x86/kernel/pci-calgary_64.c
24435 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24436 tce_space = be64_to_cpu(readq(target));
24437 tce_space = tce_space & TAR_SW_BITS;
24438
24439 - tce_space = tce_space & (~specified_table_size);
24440 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24441 info->tce_space = (u64 *)__va(tce_space);
24442 }
24443 }
24444 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24445 index 35ccf75..7a15747 100644
24446 --- a/arch/x86/kernel/pci-iommu_table.c
24447 +++ b/arch/x86/kernel/pci-iommu_table.c
24448 @@ -2,7 +2,7 @@
24449 #include <asm/iommu_table.h>
24450 #include <linux/string.h>
24451 #include <linux/kallsyms.h>
24452 -
24453 +#include <linux/sched.h>
24454
24455 #define DEBUG 1
24456
24457 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24458 index 6c483ba..d10ce2f 100644
24459 --- a/arch/x86/kernel/pci-swiotlb.c
24460 +++ b/arch/x86/kernel/pci-swiotlb.c
24461 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24462 void *vaddr, dma_addr_t dma_addr,
24463 struct dma_attrs *attrs)
24464 {
24465 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24466 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24467 }
24468
24469 static struct dma_map_ops swiotlb_dma_ops = {
24470 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24471 index 83369e5..52b93f0 100644
24472 --- a/arch/x86/kernel/process.c
24473 +++ b/arch/x86/kernel/process.c
24474 @@ -36,7 +36,8 @@
24475 * section. Since TSS's are completely CPU-local, we want them
24476 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24477 */
24478 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24479 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24480 +EXPORT_SYMBOL(init_tss);
24481
24482 #ifdef CONFIG_X86_64
24483 static DEFINE_PER_CPU(unsigned char, is_idle);
24484 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24485 task_xstate_cachep =
24486 kmem_cache_create("task_xstate", xstate_size,
24487 __alignof__(union thread_xstate),
24488 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24489 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24490 }
24491
24492 /*
24493 @@ -105,7 +106,7 @@ void exit_thread(void)
24494 unsigned long *bp = t->io_bitmap_ptr;
24495
24496 if (bp) {
24497 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24498 + struct tss_struct *tss = init_tss + get_cpu();
24499
24500 t->io_bitmap_ptr = NULL;
24501 clear_thread_flag(TIF_IO_BITMAP);
24502 @@ -125,6 +126,9 @@ void flush_thread(void)
24503 {
24504 struct task_struct *tsk = current;
24505
24506 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24507 + loadsegment(gs, 0);
24508 +#endif
24509 flush_ptrace_hw_breakpoint(tsk);
24510 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24511 drop_init_fpu(tsk);
24512 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24513 void exit_idle(void)
24514 {
24515 /* idle loop has pid 0 */
24516 - if (current->pid)
24517 + if (task_pid_nr(current))
24518 return;
24519 __exit_idle();
24520 }
24521 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24522 return ret;
24523 }
24524 #endif
24525 -void stop_this_cpu(void *dummy)
24526 +__noreturn void stop_this_cpu(void *dummy)
24527 {
24528 local_irq_disable();
24529 /*
24530 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24531 }
24532 early_param("idle", idle_setup);
24533
24534 -unsigned long arch_align_stack(unsigned long sp)
24535 +#ifdef CONFIG_PAX_RANDKSTACK
24536 +void pax_randomize_kstack(struct pt_regs *regs)
24537 {
24538 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24539 - sp -= get_random_int() % 8192;
24540 - return sp & ~0xf;
24541 -}
24542 + struct thread_struct *thread = &current->thread;
24543 + unsigned long time;
24544
24545 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24546 -{
24547 - unsigned long range_end = mm->brk + 0x02000000;
24548 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24549 -}
24550 + if (!randomize_va_space)
24551 + return;
24552 +
24553 + if (v8086_mode(regs))
24554 + return;
24555
24556 + rdtscl(time);
24557 +
24558 + /* P4 seems to return a 0 LSB, ignore it */
24559 +#ifdef CONFIG_MPENTIUM4
24560 + time &= 0x3EUL;
24561 + time <<= 2;
24562 +#elif defined(CONFIG_X86_64)
24563 + time &= 0xFUL;
24564 + time <<= 4;
24565 +#else
24566 + time &= 0x1FUL;
24567 + time <<= 3;
24568 +#endif
24569 +
24570 + thread->sp0 ^= time;
24571 + load_sp0(init_tss + smp_processor_id(), thread);
24572 +
24573 +#ifdef CONFIG_X86_64
24574 + this_cpu_write(kernel_stack, thread->sp0);
24575 +#endif
24576 +}
24577 +#endif
24578 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24579 index f8adefc..4bce3d6 100644
24580 --- a/arch/x86/kernel/process_32.c
24581 +++ b/arch/x86/kernel/process_32.c
24582 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24583 unsigned long thread_saved_pc(struct task_struct *tsk)
24584 {
24585 return ((unsigned long *)tsk->thread.sp)[3];
24586 +//XXX return tsk->thread.eip;
24587 }
24588
24589 void __show_regs(struct pt_regs *regs, int all)
24590 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24591 unsigned long sp;
24592 unsigned short ss, gs;
24593
24594 - if (user_mode_vm(regs)) {
24595 + if (user_mode(regs)) {
24596 sp = regs->sp;
24597 ss = regs->ss & 0xffff;
24598 - gs = get_user_gs(regs);
24599 } else {
24600 sp = kernel_stack_pointer(regs);
24601 savesegment(ss, ss);
24602 - savesegment(gs, gs);
24603 }
24604 + gs = get_user_gs(regs);
24605
24606 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24607 (u16)regs->cs, regs->ip, regs->flags,
24608 - smp_processor_id());
24609 + raw_smp_processor_id());
24610 print_symbol("EIP is at %s\n", regs->ip);
24611
24612 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24613 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24614 int copy_thread(unsigned long clone_flags, unsigned long sp,
24615 unsigned long arg, struct task_struct *p)
24616 {
24617 - struct pt_regs *childregs = task_pt_regs(p);
24618 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24619 struct task_struct *tsk;
24620 int err;
24621
24622 p->thread.sp = (unsigned long) childregs;
24623 p->thread.sp0 = (unsigned long) (childregs+1);
24624 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24625
24626 if (unlikely(p->flags & PF_KTHREAD)) {
24627 /* kernel thread */
24628 memset(childregs, 0, sizeof(struct pt_regs));
24629 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24630 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24631 - childregs->ds = __USER_DS;
24632 - childregs->es = __USER_DS;
24633 + savesegment(gs, childregs->gs);
24634 + childregs->ds = __KERNEL_DS;
24635 + childregs->es = __KERNEL_DS;
24636 childregs->fs = __KERNEL_PERCPU;
24637 childregs->bx = sp; /* function */
24638 childregs->bp = arg;
24639 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24640 struct thread_struct *prev = &prev_p->thread,
24641 *next = &next_p->thread;
24642 int cpu = smp_processor_id();
24643 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24644 + struct tss_struct *tss = init_tss + cpu;
24645 fpu_switch_t fpu;
24646
24647 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24648 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24649 */
24650 lazy_save_gs(prev->gs);
24651
24652 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24653 + __set_fs(task_thread_info(next_p)->addr_limit);
24654 +#endif
24655 +
24656 /*
24657 * Load the per-thread Thread-Local Storage descriptor.
24658 */
24659 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24660 */
24661 arch_end_context_switch(next_p);
24662
24663 + this_cpu_write(current_task, next_p);
24664 + this_cpu_write(current_tinfo, &next_p->tinfo);
24665 +
24666 /*
24667 * Restore %gs if needed (which is common)
24668 */
24669 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24670
24671 switch_fpu_finish(next_p, fpu);
24672
24673 - this_cpu_write(current_task, next_p);
24674 -
24675 return prev_p;
24676 }
24677
24678 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24679 } while (count++ < 16);
24680 return 0;
24681 }
24682 -
24683 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24684 index 05646ba..0c2906d 100644
24685 --- a/arch/x86/kernel/process_64.c
24686 +++ b/arch/x86/kernel/process_64.c
24687 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24688 struct pt_regs *childregs;
24689 struct task_struct *me = current;
24690
24691 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24692 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24693 childregs = task_pt_regs(p);
24694 p->thread.sp = (unsigned long) childregs;
24695 p->thread.usersp = me->thread.usersp;
24696 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24697 set_tsk_thread_flag(p, TIF_FORK);
24698 p->fpu_counter = 0;
24699 p->thread.io_bitmap_ptr = NULL;
24700 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24701 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24702 savesegment(es, p->thread.es);
24703 savesegment(ds, p->thread.ds);
24704 + savesegment(ss, p->thread.ss);
24705 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24706 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24707
24708 if (unlikely(p->flags & PF_KTHREAD)) {
24709 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24710 struct thread_struct *prev = &prev_p->thread;
24711 struct thread_struct *next = &next_p->thread;
24712 int cpu = smp_processor_id();
24713 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24714 + struct tss_struct *tss = init_tss + cpu;
24715 unsigned fsindex, gsindex;
24716 fpu_switch_t fpu;
24717
24718 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24719 if (unlikely(next->ds | prev->ds))
24720 loadsegment(ds, next->ds);
24721
24722 + savesegment(ss, prev->ss);
24723 + if (unlikely(next->ss != prev->ss))
24724 + loadsegment(ss, next->ss);
24725
24726 /* We must save %fs and %gs before load_TLS() because
24727 * %fs and %gs may be cleared by load_TLS().
24728 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24729 prev->usersp = this_cpu_read(old_rsp);
24730 this_cpu_write(old_rsp, next->usersp);
24731 this_cpu_write(current_task, next_p);
24732 + this_cpu_write(current_tinfo, &next_p->tinfo);
24733
24734 - this_cpu_write(kernel_stack,
24735 - (unsigned long)task_stack_page(next_p) +
24736 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24737 + this_cpu_write(kernel_stack, next->sp0);
24738
24739 /*
24740 * Now maybe reload the debug registers and handle I/O bitmaps
24741 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24742 if (!p || p == current || p->state == TASK_RUNNING)
24743 return 0;
24744 stack = (unsigned long)task_stack_page(p);
24745 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24746 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24747 return 0;
24748 fp = *(u64 *)(p->thread.sp);
24749 do {
24750 - if (fp < (unsigned long)stack ||
24751 - fp >= (unsigned long)stack+THREAD_SIZE)
24752 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24753 return 0;
24754 ip = *(u64 *)(fp+8);
24755 if (!in_sched_functions(ip))
24756 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24757 index 7461f50..1334029 100644
24758 --- a/arch/x86/kernel/ptrace.c
24759 +++ b/arch/x86/kernel/ptrace.c
24760 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24761 {
24762 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24763 unsigned long sp = (unsigned long)&regs->sp;
24764 - struct thread_info *tinfo;
24765
24766 - if (context == (sp & ~(THREAD_SIZE - 1)))
24767 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24768 return sp;
24769
24770 - tinfo = (struct thread_info *)context;
24771 - if (tinfo->previous_esp)
24772 - return tinfo->previous_esp;
24773 + sp = *(unsigned long *)context;
24774 + if (sp)
24775 + return sp;
24776
24777 return (unsigned long)regs;
24778 }
24779 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24780 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24781 {
24782 int i;
24783 - int dr7 = 0;
24784 + unsigned long dr7 = 0;
24785 struct arch_hw_breakpoint *info;
24786
24787 for (i = 0; i < HBP_NUM; i++) {
24788 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24789 unsigned long addr, unsigned long data)
24790 {
24791 int ret;
24792 - unsigned long __user *datap = (unsigned long __user *)data;
24793 + unsigned long __user *datap = (__force unsigned long __user *)data;
24794
24795 switch (request) {
24796 /* read the word at location addr in the USER area. */
24797 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24798 if ((int) addr < 0)
24799 return -EIO;
24800 ret = do_get_thread_area(child, addr,
24801 - (struct user_desc __user *)data);
24802 + (__force struct user_desc __user *) data);
24803 break;
24804
24805 case PTRACE_SET_THREAD_AREA:
24806 if ((int) addr < 0)
24807 return -EIO;
24808 ret = do_set_thread_area(child, addr,
24809 - (struct user_desc __user *)data, 0);
24810 + (__force struct user_desc __user *) data, 0);
24811 break;
24812 #endif
24813
24814 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24815
24816 #ifdef CONFIG_X86_64
24817
24818 -static struct user_regset x86_64_regsets[] __read_mostly = {
24819 +static user_regset_no_const x86_64_regsets[] __read_only = {
24820 [REGSET_GENERAL] = {
24821 .core_note_type = NT_PRSTATUS,
24822 .n = sizeof(struct user_regs_struct) / sizeof(long),
24823 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24824 #endif /* CONFIG_X86_64 */
24825
24826 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24827 -static struct user_regset x86_32_regsets[] __read_mostly = {
24828 +static user_regset_no_const x86_32_regsets[] __read_only = {
24829 [REGSET_GENERAL] = {
24830 .core_note_type = NT_PRSTATUS,
24831 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24832 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24833 */
24834 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24835
24836 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24837 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24838 {
24839 #ifdef CONFIG_X86_64
24840 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24841 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24842 memset(info, 0, sizeof(*info));
24843 info->si_signo = SIGTRAP;
24844 info->si_code = si_code;
24845 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24846 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24847 }
24848
24849 void user_single_step_siginfo(struct task_struct *tsk,
24850 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24851 # define IS_IA32 0
24852 #endif
24853
24854 +#ifdef CONFIG_GRKERNSEC_SETXID
24855 +extern void gr_delayed_cred_worker(void);
24856 +#endif
24857 +
24858 /*
24859 * We must return the syscall number to actually look up in the table.
24860 * This can be -1L to skip running any syscall at all.
24861 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24862
24863 user_exit();
24864
24865 +#ifdef CONFIG_GRKERNSEC_SETXID
24866 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24867 + gr_delayed_cred_worker();
24868 +#endif
24869 +
24870 /*
24871 * If we stepped into a sysenter/syscall insn, it trapped in
24872 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24873 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24874 */
24875 user_exit();
24876
24877 +#ifdef CONFIG_GRKERNSEC_SETXID
24878 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24879 + gr_delayed_cred_worker();
24880 +#endif
24881 +
24882 audit_syscall_exit(regs);
24883
24884 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24885 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24886 index 2cb9470..ff1fd80 100644
24887 --- a/arch/x86/kernel/pvclock.c
24888 +++ b/arch/x86/kernel/pvclock.c
24889 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24890 return pv_tsc_khz;
24891 }
24892
24893 -static atomic64_t last_value = ATOMIC64_INIT(0);
24894 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24895
24896 void pvclock_resume(void)
24897 {
24898 - atomic64_set(&last_value, 0);
24899 + atomic64_set_unchecked(&last_value, 0);
24900 }
24901
24902 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24903 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24904 * updating at the same time, and one of them could be slightly behind,
24905 * making the assumption that last_value always go forward fail to hold.
24906 */
24907 - last = atomic64_read(&last_value);
24908 + last = atomic64_read_unchecked(&last_value);
24909 do {
24910 if (ret < last)
24911 return last;
24912 - last = atomic64_cmpxchg(&last_value, last, ret);
24913 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24914 } while (unlikely(last != ret));
24915
24916 return ret;
24917 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24918 index 5f4ad27..9d96c99 100644
24919 --- a/arch/x86/kernel/reboot.c
24920 +++ b/arch/x86/kernel/reboot.c
24921 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24922
24923 void __noreturn machine_real_restart(unsigned int type)
24924 {
24925 +
24926 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24927 + struct desc_struct *gdt;
24928 +#endif
24929 +
24930 local_irq_disable();
24931
24932 /*
24933 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24934
24935 /* Jump to the identity-mapped low memory code */
24936 #ifdef CONFIG_X86_32
24937 - asm volatile("jmpl *%0" : :
24938 +
24939 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24940 + gdt = get_cpu_gdt_table(smp_processor_id());
24941 + pax_open_kernel();
24942 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24943 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24944 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24945 + loadsegment(ds, __KERNEL_DS);
24946 + loadsegment(es, __KERNEL_DS);
24947 + loadsegment(ss, __KERNEL_DS);
24948 +#endif
24949 +#ifdef CONFIG_PAX_KERNEXEC
24950 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24951 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24952 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24953 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24954 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24955 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24956 +#endif
24957 + pax_close_kernel();
24958 +#endif
24959 +
24960 + asm volatile("ljmpl *%0" : :
24961 "rm" (real_mode_header->machine_real_restart_asm),
24962 "a" (type));
24963 #else
24964 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24965 * try to force a triple fault and then cycle between hitting the keyboard
24966 * controller and doing that
24967 */
24968 -static void native_machine_emergency_restart(void)
24969 +static void __noreturn native_machine_emergency_restart(void)
24970 {
24971 int i;
24972 int attempt = 0;
24973 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
24974 #endif
24975 }
24976
24977 -static void __machine_emergency_restart(int emergency)
24978 +static void __noreturn __machine_emergency_restart(int emergency)
24979 {
24980 reboot_emergency = emergency;
24981 machine_ops.emergency_restart();
24982 }
24983
24984 -static void native_machine_restart(char *__unused)
24985 +static void __noreturn native_machine_restart(char *__unused)
24986 {
24987 pr_notice("machine restart\n");
24988
24989 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
24990 __machine_emergency_restart(0);
24991 }
24992
24993 -static void native_machine_halt(void)
24994 +static void __noreturn native_machine_halt(void)
24995 {
24996 /* Stop other cpus and apics */
24997 machine_shutdown();
24998 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
24999 stop_this_cpu(NULL);
25000 }
25001
25002 -static void native_machine_power_off(void)
25003 +static void __noreturn native_machine_power_off(void)
25004 {
25005 if (pm_power_off) {
25006 if (!reboot_force)
25007 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
25008 }
25009 /* A fallback in case there is no PM info available */
25010 tboot_shutdown(TB_SHUTDOWN_HALT);
25011 + unreachable();
25012 }
25013
25014 -struct machine_ops machine_ops = {
25015 +struct machine_ops machine_ops __read_only = {
25016 .power_off = native_machine_power_off,
25017 .shutdown = native_machine_shutdown,
25018 .emergency_restart = native_machine_emergency_restart,
25019 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25020 index c8e41e9..64049ef 100644
25021 --- a/arch/x86/kernel/reboot_fixups_32.c
25022 +++ b/arch/x86/kernel/reboot_fixups_32.c
25023 @@ -57,7 +57,7 @@ struct device_fixup {
25024 unsigned int vendor;
25025 unsigned int device;
25026 void (*reboot_fixup)(struct pci_dev *);
25027 -};
25028 +} __do_const;
25029
25030 /*
25031 * PCI ids solely used for fixups_table go here
25032 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25033 index 3fd2c69..16ef367 100644
25034 --- a/arch/x86/kernel/relocate_kernel_64.S
25035 +++ b/arch/x86/kernel/relocate_kernel_64.S
25036 @@ -11,6 +11,7 @@
25037 #include <asm/kexec.h>
25038 #include <asm/processor-flags.h>
25039 #include <asm/pgtable_types.h>
25040 +#include <asm/alternative-asm.h>
25041
25042 /*
25043 * Must be relocatable PIC code callable as a C function
25044 @@ -96,8 +97,7 @@ relocate_kernel:
25045
25046 /* jump to identity mapped page */
25047 addq $(identity_mapped - relocate_kernel), %r8
25048 - pushq %r8
25049 - ret
25050 + jmp *%r8
25051
25052 identity_mapped:
25053 /* set return address to 0 if not preserving context */
25054 @@ -167,6 +167,7 @@ identity_mapped:
25055 xorl %r14d, %r14d
25056 xorl %r15d, %r15d
25057
25058 + pax_force_retaddr 0, 1
25059 ret
25060
25061 1:
25062 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25063 index 234e1e3..1246d05 100644
25064 --- a/arch/x86/kernel/setup.c
25065 +++ b/arch/x86/kernel/setup.c
25066 @@ -110,6 +110,7 @@
25067 #include <asm/mce.h>
25068 #include <asm/alternative.h>
25069 #include <asm/prom.h>
25070 +#include <asm/boot.h>
25071
25072 /*
25073 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25074 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25075 #endif
25076
25077
25078 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25079 -unsigned long mmu_cr4_features;
25080 +#ifdef CONFIG_X86_64
25081 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25082 +#elif defined(CONFIG_X86_PAE)
25083 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25084 #else
25085 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25086 +unsigned long mmu_cr4_features __read_only;
25087 #endif
25088
25089 +void set_in_cr4(unsigned long mask)
25090 +{
25091 + unsigned long cr4 = read_cr4();
25092 +
25093 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25094 + return;
25095 +
25096 + pax_open_kernel();
25097 + mmu_cr4_features |= mask;
25098 + pax_close_kernel();
25099 +
25100 + if (trampoline_cr4_features)
25101 + *trampoline_cr4_features = mmu_cr4_features;
25102 + cr4 |= mask;
25103 + write_cr4(cr4);
25104 +}
25105 +EXPORT_SYMBOL(set_in_cr4);
25106 +
25107 +void clear_in_cr4(unsigned long mask)
25108 +{
25109 + unsigned long cr4 = read_cr4();
25110 +
25111 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25112 + return;
25113 +
25114 + pax_open_kernel();
25115 + mmu_cr4_features &= ~mask;
25116 + pax_close_kernel();
25117 +
25118 + if (trampoline_cr4_features)
25119 + *trampoline_cr4_features = mmu_cr4_features;
25120 + cr4 &= ~mask;
25121 + write_cr4(cr4);
25122 +}
25123 +EXPORT_SYMBOL(clear_in_cr4);
25124 +
25125 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25126 int bootloader_type, bootloader_version;
25127
25128 @@ -442,7 +481,7 @@ static void __init parse_setup_data(void)
25129
25130 switch (data_type) {
25131 case SETUP_E820_EXT:
25132 - parse_e820_ext(pa_data, data_len);
25133 + parse_e820_ext((struct setup_data __force_kernel *)pa_data, data_len);
25134 break;
25135 case SETUP_DTB:
25136 add_dtb(pa_data);
25137 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25138 * area (640->1Mb) as ram even though it is not.
25139 * take them out.
25140 */
25141 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25142 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25143
25144 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25145 }
25146 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25147 /* called before trim_bios_range() to spare extra sanitize */
25148 static void __init e820_add_kernel_range(void)
25149 {
25150 - u64 start = __pa_symbol(_text);
25151 + u64 start = __pa_symbol(ktla_ktva(_text));
25152 u64 size = __pa_symbol(_end) - start;
25153
25154 /*
25155 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25156
25157 void __init setup_arch(char **cmdline_p)
25158 {
25159 +#ifdef CONFIG_X86_32
25160 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25161 +#else
25162 memblock_reserve(__pa_symbol(_text),
25163 (unsigned long)__bss_stop - (unsigned long)_text);
25164 +#endif
25165
25166 early_reserve_initrd();
25167
25168 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25169
25170 if (!boot_params.hdr.root_flags)
25171 root_mountflags &= ~MS_RDONLY;
25172 - init_mm.start_code = (unsigned long) _text;
25173 - init_mm.end_code = (unsigned long) _etext;
25174 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25175 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25176 init_mm.end_data = (unsigned long) _edata;
25177 init_mm.brk = _brk_end;
25178
25179 - code_resource.start = __pa_symbol(_text);
25180 - code_resource.end = __pa_symbol(_etext)-1;
25181 - data_resource.start = __pa_symbol(_etext);
25182 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25183 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25184 + data_resource.start = __pa_symbol(_sdata);
25185 data_resource.end = __pa_symbol(_edata)-1;
25186 bss_resource.start = __pa_symbol(__bss_start);
25187 bss_resource.end = __pa_symbol(__bss_stop)-1;
25188 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25189 index 5cdff03..80fa283 100644
25190 --- a/arch/x86/kernel/setup_percpu.c
25191 +++ b/arch/x86/kernel/setup_percpu.c
25192 @@ -21,19 +21,17 @@
25193 #include <asm/cpu.h>
25194 #include <asm/stackprotector.h>
25195
25196 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25197 +#ifdef CONFIG_SMP
25198 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25199 EXPORT_PER_CPU_SYMBOL(cpu_number);
25200 +#endif
25201
25202 -#ifdef CONFIG_X86_64
25203 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25204 -#else
25205 -#define BOOT_PERCPU_OFFSET 0
25206 -#endif
25207
25208 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25209 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25210
25211 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25212 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25213 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25214 };
25215 EXPORT_SYMBOL(__per_cpu_offset);
25216 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25217 {
25218 #ifdef CONFIG_NEED_MULTIPLE_NODES
25219 pg_data_t *last = NULL;
25220 - unsigned int cpu;
25221 + int cpu;
25222
25223 for_each_possible_cpu(cpu) {
25224 int node = early_cpu_to_node(cpu);
25225 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25226 {
25227 #ifdef CONFIG_X86_32
25228 struct desc_struct gdt;
25229 + unsigned long base = per_cpu_offset(cpu);
25230
25231 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25232 - 0x2 | DESCTYPE_S, 0x8);
25233 - gdt.s = 1;
25234 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25235 + 0x83 | DESCTYPE_S, 0xC);
25236 write_gdt_entry(get_cpu_gdt_table(cpu),
25237 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25238 #endif
25239 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25240 /* alrighty, percpu areas up and running */
25241 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25242 for_each_possible_cpu(cpu) {
25243 +#ifdef CONFIG_CC_STACKPROTECTOR
25244 +#ifdef CONFIG_X86_32
25245 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25246 +#endif
25247 +#endif
25248 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25249 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25250 per_cpu(cpu_number, cpu) = cpu;
25251 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25252 */
25253 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25254 #endif
25255 +#ifdef CONFIG_CC_STACKPROTECTOR
25256 +#ifdef CONFIG_X86_32
25257 + if (!cpu)
25258 + per_cpu(stack_canary.canary, cpu) = canary;
25259 +#endif
25260 +#endif
25261 /*
25262 * Up to this point, the boot CPU has been using .init.data
25263 * area. Reload any changed state for the boot CPU.
25264 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25265 index d859eea..44e17c4 100644
25266 --- a/arch/x86/kernel/signal.c
25267 +++ b/arch/x86/kernel/signal.c
25268 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25269 * Align the stack pointer according to the i386 ABI,
25270 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25271 */
25272 - sp = ((sp + 4) & -16ul) - 4;
25273 + sp = ((sp - 12) & -16ul) - 4;
25274 #else /* !CONFIG_X86_32 */
25275 sp = round_down(sp, 16) - 8;
25276 #endif
25277 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25278 }
25279
25280 if (current->mm->context.vdso)
25281 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25282 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25283 else
25284 - restorer = &frame->retcode;
25285 + restorer = (void __user *)&frame->retcode;
25286 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25287 restorer = ksig->ka.sa.sa_restorer;
25288
25289 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25290 * reasons and because gdb uses it as a signature to notice
25291 * signal handler stack frames.
25292 */
25293 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25294 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25295
25296 if (err)
25297 return -EFAULT;
25298 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25299 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25300
25301 /* Set up to return from userspace. */
25302 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25303 + if (current->mm->context.vdso)
25304 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25305 + else
25306 + restorer = (void __user *)&frame->retcode;
25307 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25308 restorer = ksig->ka.sa.sa_restorer;
25309 put_user_ex(restorer, &frame->pretcode);
25310 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25311 * reasons and because gdb uses it as a signature to notice
25312 * signal handler stack frames.
25313 */
25314 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25315 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25316 } put_user_catch(err);
25317
25318 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25319 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25320 {
25321 int usig = signr_convert(ksig->sig);
25322 sigset_t *set = sigmask_to_save();
25323 - compat_sigset_t *cset = (compat_sigset_t *) set;
25324 + sigset_t sigcopy;
25325 + compat_sigset_t *cset;
25326 +
25327 + sigcopy = *set;
25328 +
25329 + cset = (compat_sigset_t *) &sigcopy;
25330
25331 /* Set up the stack frame */
25332 if (is_ia32_frame()) {
25333 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25334 } else if (is_x32_frame()) {
25335 return x32_setup_rt_frame(ksig, cset, regs);
25336 } else {
25337 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25338 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25339 }
25340 }
25341
25342 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25343 index cdaa347..f5af55d 100644
25344 --- a/arch/x86/kernel/smp.c
25345 +++ b/arch/x86/kernel/smp.c
25346 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25347
25348 __setup("nonmi_ipi", nonmi_ipi_setup);
25349
25350 -struct smp_ops smp_ops = {
25351 +struct smp_ops smp_ops __read_only = {
25352 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25353 .smp_prepare_cpus = native_smp_prepare_cpus,
25354 .smp_cpus_done = native_smp_cpus_done,
25355 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25356 index aecc98a..0244a53 100644
25357 --- a/arch/x86/kernel/smpboot.c
25358 +++ b/arch/x86/kernel/smpboot.c
25359 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25360
25361 enable_start_cpu0 = 0;
25362
25363 -#ifdef CONFIG_X86_32
25364 - /* switch away from the initial page table */
25365 - load_cr3(swapper_pg_dir);
25366 - __flush_tlb_all();
25367 -#endif
25368 -
25369 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25370 barrier();
25371 +
25372 + /* switch away from the initial page table */
25373 +#ifdef CONFIG_PAX_PER_CPU_PGD
25374 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25375 + __flush_tlb_all();
25376 +#elif defined(CONFIG_X86_32)
25377 + load_cr3(swapper_pg_dir);
25378 + __flush_tlb_all();
25379 +#endif
25380 +
25381 /*
25382 * Check TSC synchronization with the BP:
25383 */
25384 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25385 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25386 (THREAD_SIZE + task_stack_page(idle))) - 1);
25387 per_cpu(current_task, cpu) = idle;
25388 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25389
25390 #ifdef CONFIG_X86_32
25391 /* Stack for startup_32 can be just as for start_secondary onwards */
25392 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25393 #else
25394 clear_tsk_thread_flag(idle, TIF_FORK);
25395 initial_gs = per_cpu_offset(cpu);
25396 - per_cpu(kernel_stack, cpu) =
25397 - (unsigned long)task_stack_page(idle) -
25398 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25399 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25400 #endif
25401 +
25402 + pax_open_kernel();
25403 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25404 + pax_close_kernel();
25405 +
25406 initial_code = (unsigned long)start_secondary;
25407 stack_start = idle->thread.sp;
25408
25409 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25410 /* the FPU context is blank, nobody can own it */
25411 __cpu_disable_lazy_restore(cpu);
25412
25413 +#ifdef CONFIG_PAX_PER_CPU_PGD
25414 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25415 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25416 + KERNEL_PGD_PTRS);
25417 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25418 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25419 + KERNEL_PGD_PTRS);
25420 +#endif
25421 +
25422 err = do_boot_cpu(apicid, cpu, tidle);
25423 if (err) {
25424 pr_debug("do_boot_cpu failed %d\n", err);
25425 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25426 index 9b4d51d..5d28b58 100644
25427 --- a/arch/x86/kernel/step.c
25428 +++ b/arch/x86/kernel/step.c
25429 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25430 struct desc_struct *desc;
25431 unsigned long base;
25432
25433 - seg &= ~7UL;
25434 + seg >>= 3;
25435
25436 mutex_lock(&child->mm->context.lock);
25437 - if (unlikely((seg >> 3) >= child->mm->context.size))
25438 + if (unlikely(seg >= child->mm->context.size))
25439 addr = -1L; /* bogus selector, access would fault */
25440 else {
25441 desc = child->mm->context.ldt + seg;
25442 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25443 addr += base;
25444 }
25445 mutex_unlock(&child->mm->context.lock);
25446 - }
25447 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25448 + addr = ktla_ktva(addr);
25449
25450 return addr;
25451 }
25452 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25453 unsigned char opcode[15];
25454 unsigned long addr = convert_ip_to_linear(child, regs);
25455
25456 + if (addr == -EINVAL)
25457 + return 0;
25458 +
25459 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25460 for (i = 0; i < copied; i++) {
25461 switch (opcode[i]) {
25462 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25463 new file mode 100644
25464 index 0000000..5877189
25465 --- /dev/null
25466 +++ b/arch/x86/kernel/sys_i386_32.c
25467 @@ -0,0 +1,189 @@
25468 +/*
25469 + * This file contains various random system calls that
25470 + * have a non-standard calling sequence on the Linux/i386
25471 + * platform.
25472 + */
25473 +
25474 +#include <linux/errno.h>
25475 +#include <linux/sched.h>
25476 +#include <linux/mm.h>
25477 +#include <linux/fs.h>
25478 +#include <linux/smp.h>
25479 +#include <linux/sem.h>
25480 +#include <linux/msg.h>
25481 +#include <linux/shm.h>
25482 +#include <linux/stat.h>
25483 +#include <linux/syscalls.h>
25484 +#include <linux/mman.h>
25485 +#include <linux/file.h>
25486 +#include <linux/utsname.h>
25487 +#include <linux/ipc.h>
25488 +#include <linux/elf.h>
25489 +
25490 +#include <linux/uaccess.h>
25491 +#include <linux/unistd.h>
25492 +
25493 +#include <asm/syscalls.h>
25494 +
25495 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25496 +{
25497 + unsigned long pax_task_size = TASK_SIZE;
25498 +
25499 +#ifdef CONFIG_PAX_SEGMEXEC
25500 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25501 + pax_task_size = SEGMEXEC_TASK_SIZE;
25502 +#endif
25503 +
25504 + if (flags & MAP_FIXED)
25505 + if (len > pax_task_size || addr > pax_task_size - len)
25506 + return -EINVAL;
25507 +
25508 + return 0;
25509 +}
25510 +
25511 +/*
25512 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25513 + */
25514 +static unsigned long get_align_mask(void)
25515 +{
25516 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25517 + return 0;
25518 +
25519 + if (!(current->flags & PF_RANDOMIZE))
25520 + return 0;
25521 +
25522 + return va_align.mask;
25523 +}
25524 +
25525 +unsigned long
25526 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25527 + unsigned long len, unsigned long pgoff, unsigned long flags)
25528 +{
25529 + struct mm_struct *mm = current->mm;
25530 + struct vm_area_struct *vma;
25531 + unsigned long pax_task_size = TASK_SIZE;
25532 + struct vm_unmapped_area_info info;
25533 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25534 +
25535 +#ifdef CONFIG_PAX_SEGMEXEC
25536 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25537 + pax_task_size = SEGMEXEC_TASK_SIZE;
25538 +#endif
25539 +
25540 + pax_task_size -= PAGE_SIZE;
25541 +
25542 + if (len > pax_task_size)
25543 + return -ENOMEM;
25544 +
25545 + if (flags & MAP_FIXED)
25546 + return addr;
25547 +
25548 +#ifdef CONFIG_PAX_RANDMMAP
25549 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25550 +#endif
25551 +
25552 + if (addr) {
25553 + addr = PAGE_ALIGN(addr);
25554 + if (pax_task_size - len >= addr) {
25555 + vma = find_vma(mm, addr);
25556 + if (check_heap_stack_gap(vma, addr, len, offset))
25557 + return addr;
25558 + }
25559 + }
25560 +
25561 + info.flags = 0;
25562 + info.length = len;
25563 + info.align_mask = filp ? get_align_mask() : 0;
25564 + info.align_offset = pgoff << PAGE_SHIFT;
25565 + info.threadstack_offset = offset;
25566 +
25567 +#ifdef CONFIG_PAX_PAGEEXEC
25568 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25569 + info.low_limit = 0x00110000UL;
25570 + info.high_limit = mm->start_code;
25571 +
25572 +#ifdef CONFIG_PAX_RANDMMAP
25573 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25574 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25575 +#endif
25576 +
25577 + if (info.low_limit < info.high_limit) {
25578 + addr = vm_unmapped_area(&info);
25579 + if (!IS_ERR_VALUE(addr))
25580 + return addr;
25581 + }
25582 + } else
25583 +#endif
25584 +
25585 + info.low_limit = mm->mmap_base;
25586 + info.high_limit = pax_task_size;
25587 +
25588 + return vm_unmapped_area(&info);
25589 +}
25590 +
25591 +unsigned long
25592 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25593 + const unsigned long len, const unsigned long pgoff,
25594 + const unsigned long flags)
25595 +{
25596 + struct vm_area_struct *vma;
25597 + struct mm_struct *mm = current->mm;
25598 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25599 + struct vm_unmapped_area_info info;
25600 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25601 +
25602 +#ifdef CONFIG_PAX_SEGMEXEC
25603 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25604 + pax_task_size = SEGMEXEC_TASK_SIZE;
25605 +#endif
25606 +
25607 + pax_task_size -= PAGE_SIZE;
25608 +
25609 + /* requested length too big for entire address space */
25610 + if (len > pax_task_size)
25611 + return -ENOMEM;
25612 +
25613 + if (flags & MAP_FIXED)
25614 + return addr;
25615 +
25616 +#ifdef CONFIG_PAX_PAGEEXEC
25617 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25618 + goto bottomup;
25619 +#endif
25620 +
25621 +#ifdef CONFIG_PAX_RANDMMAP
25622 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25623 +#endif
25624 +
25625 + /* requesting a specific address */
25626 + if (addr) {
25627 + addr = PAGE_ALIGN(addr);
25628 + if (pax_task_size - len >= addr) {
25629 + vma = find_vma(mm, addr);
25630 + if (check_heap_stack_gap(vma, addr, len, offset))
25631 + return addr;
25632 + }
25633 + }
25634 +
25635 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25636 + info.length = len;
25637 + info.low_limit = PAGE_SIZE;
25638 + info.high_limit = mm->mmap_base;
25639 + info.align_mask = filp ? get_align_mask() : 0;
25640 + info.align_offset = pgoff << PAGE_SHIFT;
25641 + info.threadstack_offset = offset;
25642 +
25643 + addr = vm_unmapped_area(&info);
25644 + if (!(addr & ~PAGE_MASK))
25645 + return addr;
25646 + VM_BUG_ON(addr != -ENOMEM);
25647 +
25648 +bottomup:
25649 + /*
25650 + * A failed mmap() very likely causes application failure,
25651 + * so fall back to the bottom-up function here. This scenario
25652 + * can happen with large stack limits and large mmap()
25653 + * allocations.
25654 + */
25655 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25656 +}
25657 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25658 index 30277e2..5664a29 100644
25659 --- a/arch/x86/kernel/sys_x86_64.c
25660 +++ b/arch/x86/kernel/sys_x86_64.c
25661 @@ -81,8 +81,8 @@ out:
25662 return error;
25663 }
25664
25665 -static void find_start_end(unsigned long flags, unsigned long *begin,
25666 - unsigned long *end)
25667 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25668 + unsigned long *begin, unsigned long *end)
25669 {
25670 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25671 unsigned long new_begin;
25672 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25673 *begin = new_begin;
25674 }
25675 } else {
25676 - *begin = current->mm->mmap_legacy_base;
25677 + *begin = mm->mmap_legacy_base;
25678 *end = TASK_SIZE;
25679 }
25680 }
25681 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25682 struct vm_area_struct *vma;
25683 struct vm_unmapped_area_info info;
25684 unsigned long begin, end;
25685 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25686
25687 if (flags & MAP_FIXED)
25688 return addr;
25689
25690 - find_start_end(flags, &begin, &end);
25691 + find_start_end(mm, flags, &begin, &end);
25692
25693 if (len > end)
25694 return -ENOMEM;
25695
25696 +#ifdef CONFIG_PAX_RANDMMAP
25697 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25698 +#endif
25699 +
25700 if (addr) {
25701 addr = PAGE_ALIGN(addr);
25702 vma = find_vma(mm, addr);
25703 - if (end - len >= addr &&
25704 - (!vma || addr + len <= vma->vm_start))
25705 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25706 return addr;
25707 }
25708
25709 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25710 info.high_limit = end;
25711 info.align_mask = filp ? get_align_mask() : 0;
25712 info.align_offset = pgoff << PAGE_SHIFT;
25713 + info.threadstack_offset = offset;
25714 return vm_unmapped_area(&info);
25715 }
25716
25717 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25718 struct mm_struct *mm = current->mm;
25719 unsigned long addr = addr0;
25720 struct vm_unmapped_area_info info;
25721 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25722
25723 /* requested length too big for entire address space */
25724 if (len > TASK_SIZE)
25725 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25726 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25727 goto bottomup;
25728
25729 +#ifdef CONFIG_PAX_RANDMMAP
25730 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25731 +#endif
25732 +
25733 /* requesting a specific address */
25734 if (addr) {
25735 addr = PAGE_ALIGN(addr);
25736 vma = find_vma(mm, addr);
25737 - if (TASK_SIZE - len >= addr &&
25738 - (!vma || addr + len <= vma->vm_start))
25739 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25740 return addr;
25741 }
25742
25743 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25744 info.high_limit = mm->mmap_base;
25745 info.align_mask = filp ? get_align_mask() : 0;
25746 info.align_offset = pgoff << PAGE_SHIFT;
25747 + info.threadstack_offset = offset;
25748 addr = vm_unmapped_area(&info);
25749 if (!(addr & ~PAGE_MASK))
25750 return addr;
25751 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25752 index addf7b5..f960685 100644
25753 --- a/arch/x86/kernel/tboot.c
25754 +++ b/arch/x86/kernel/tboot.c
25755 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25756
25757 void tboot_shutdown(u32 shutdown_type)
25758 {
25759 - void (*shutdown)(void);
25760 + void (* __noreturn shutdown)(void);
25761
25762 if (!tboot_enabled())
25763 return;
25764 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25765
25766 switch_to_tboot_pt();
25767
25768 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25769 + shutdown = (void *)tboot->shutdown_entry;
25770 shutdown();
25771
25772 /* should not reach here */
25773 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25774 return 0;
25775 }
25776
25777 -static atomic_t ap_wfs_count;
25778 +static atomic_unchecked_t ap_wfs_count;
25779
25780 static int tboot_wait_for_aps(int num_aps)
25781 {
25782 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25783 {
25784 switch (action) {
25785 case CPU_DYING:
25786 - atomic_inc(&ap_wfs_count);
25787 + atomic_inc_unchecked(&ap_wfs_count);
25788 if (num_online_cpus() == 1)
25789 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25790 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25791 return NOTIFY_BAD;
25792 break;
25793 }
25794 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25795
25796 tboot_create_trampoline();
25797
25798 - atomic_set(&ap_wfs_count, 0);
25799 + atomic_set_unchecked(&ap_wfs_count, 0);
25800 register_hotcpu_notifier(&tboot_cpu_notifier);
25801
25802 #ifdef CONFIG_DEBUG_FS
25803 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25804 index 24d3c91..d06b473 100644
25805 --- a/arch/x86/kernel/time.c
25806 +++ b/arch/x86/kernel/time.c
25807 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25808 {
25809 unsigned long pc = instruction_pointer(regs);
25810
25811 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25812 + if (!user_mode(regs) && in_lock_functions(pc)) {
25813 #ifdef CONFIG_FRAME_POINTER
25814 - return *(unsigned long *)(regs->bp + sizeof(long));
25815 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25816 #else
25817 unsigned long *sp =
25818 (unsigned long *)kernel_stack_pointer(regs);
25819 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25820 * or above a saved flags. Eflags has bits 22-31 zero,
25821 * kernel addresses don't.
25822 */
25823 +
25824 +#ifdef CONFIG_PAX_KERNEXEC
25825 + return ktla_ktva(sp[0]);
25826 +#else
25827 if (sp[0] >> 22)
25828 return sp[0];
25829 if (sp[1] >> 22)
25830 return sp[1];
25831 #endif
25832 +
25833 +#endif
25834 }
25835 return pc;
25836 }
25837 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25838 index f7fec09..9991981 100644
25839 --- a/arch/x86/kernel/tls.c
25840 +++ b/arch/x86/kernel/tls.c
25841 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25842 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25843 return -EINVAL;
25844
25845 +#ifdef CONFIG_PAX_SEGMEXEC
25846 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25847 + return -EINVAL;
25848 +#endif
25849 +
25850 set_tls_desc(p, idx, &info, 1);
25851
25852 return 0;
25853 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25854
25855 if (kbuf)
25856 info = kbuf;
25857 - else if (__copy_from_user(infobuf, ubuf, count))
25858 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25859 return -EFAULT;
25860 else
25861 info = infobuf;
25862 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25863 index 1c113db..287b42e 100644
25864 --- a/arch/x86/kernel/tracepoint.c
25865 +++ b/arch/x86/kernel/tracepoint.c
25866 @@ -9,11 +9,11 @@
25867 #include <linux/atomic.h>
25868
25869 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25870 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25871 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25872 (unsigned long) trace_idt_table };
25873
25874 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25875 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25876 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25877
25878 static int trace_irq_vector_refcount;
25879 static DEFINE_MUTEX(irq_vector_mutex);
25880 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25881 index 1b23a1c..910de0d 100644
25882 --- a/arch/x86/kernel/traps.c
25883 +++ b/arch/x86/kernel/traps.c
25884 @@ -65,7 +65,7 @@
25885 #include <asm/proto.h>
25886
25887 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25888 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25889 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25890 #else
25891 #include <asm/processor-flags.h>
25892 #include <asm/setup.h>
25893 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25894 #endif
25895
25896 /* Must be page-aligned because the real IDT is used in a fixmap. */
25897 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25898 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25899
25900 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25901 EXPORT_SYMBOL_GPL(used_vectors);
25902 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25903 }
25904
25905 static int __kprobes
25906 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25907 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25908 struct pt_regs *regs, long error_code)
25909 {
25910 #ifdef CONFIG_X86_32
25911 - if (regs->flags & X86_VM_MASK) {
25912 + if (v8086_mode(regs)) {
25913 /*
25914 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25915 * On nmi (interrupt 2), do_trap should not be called.
25916 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25917 return -1;
25918 }
25919 #endif
25920 - if (!user_mode(regs)) {
25921 + if (!user_mode_novm(regs)) {
25922 if (!fixup_exception(regs)) {
25923 tsk->thread.error_code = error_code;
25924 tsk->thread.trap_nr = trapnr;
25925 +
25926 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25927 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25928 + str = "PAX: suspicious stack segment fault";
25929 +#endif
25930 +
25931 die(str, regs, error_code);
25932 }
25933 +
25934 +#ifdef CONFIG_PAX_REFCOUNT
25935 + if (trapnr == 4)
25936 + pax_report_refcount_overflow(regs);
25937 +#endif
25938 +
25939 return 0;
25940 }
25941
25942 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25943 }
25944
25945 static void __kprobes
25946 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25947 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25948 long error_code, siginfo_t *info)
25949 {
25950 struct task_struct *tsk = current;
25951 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25952 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25953 printk_ratelimit()) {
25954 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25955 - tsk->comm, tsk->pid, str,
25956 + tsk->comm, task_pid_nr(tsk), str,
25957 regs->ip, regs->sp, error_code);
25958 print_vma_addr(" in ", regs->ip);
25959 pr_cont("\n");
25960 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25961 conditional_sti(regs);
25962
25963 #ifdef CONFIG_X86_32
25964 - if (regs->flags & X86_VM_MASK) {
25965 + if (v8086_mode(regs)) {
25966 local_irq_enable();
25967 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25968 goto exit;
25969 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25970 #endif
25971
25972 tsk = current;
25973 - if (!user_mode(regs)) {
25974 + if (!user_mode_novm(regs)) {
25975 if (fixup_exception(regs))
25976 goto exit;
25977
25978 tsk->thread.error_code = error_code;
25979 tsk->thread.trap_nr = X86_TRAP_GP;
25980 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25981 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25982 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25983 +
25984 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25985 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25986 + die("PAX: suspicious general protection fault", regs, error_code);
25987 + else
25988 +#endif
25989 +
25990 die("general protection fault", regs, error_code);
25991 + }
25992 goto exit;
25993 }
25994
25995 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25996 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25997 + struct mm_struct *mm = tsk->mm;
25998 + unsigned long limit;
25999 +
26000 + down_write(&mm->mmap_sem);
26001 + limit = mm->context.user_cs_limit;
26002 + if (limit < TASK_SIZE) {
26003 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26004 + up_write(&mm->mmap_sem);
26005 + return;
26006 + }
26007 + up_write(&mm->mmap_sem);
26008 + }
26009 +#endif
26010 +
26011 tsk->thread.error_code = error_code;
26012 tsk->thread.trap_nr = X86_TRAP_GP;
26013
26014 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26015 /* It's safe to allow irq's after DR6 has been saved */
26016 preempt_conditional_sti(regs);
26017
26018 - if (regs->flags & X86_VM_MASK) {
26019 + if (v8086_mode(regs)) {
26020 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26021 X86_TRAP_DB);
26022 preempt_conditional_cli(regs);
26023 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26024 * We already checked v86 mode above, so we can check for kernel mode
26025 * by just checking the CPL of CS.
26026 */
26027 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26028 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26029 tsk->thread.debugreg6 &= ~DR_STEP;
26030 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26031 regs->flags &= ~X86_EFLAGS_TF;
26032 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26033 return;
26034 conditional_sti(regs);
26035
26036 - if (!user_mode_vm(regs))
26037 + if (!user_mode(regs))
26038 {
26039 if (!fixup_exception(regs)) {
26040 task->thread.error_code = error_code;
26041 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26042 index 2ed8459..7cf329f 100644
26043 --- a/arch/x86/kernel/uprobes.c
26044 +++ b/arch/x86/kernel/uprobes.c
26045 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26046 int ret = NOTIFY_DONE;
26047
26048 /* We are only interested in userspace traps */
26049 - if (regs && !user_mode_vm(regs))
26050 + if (regs && !user_mode(regs))
26051 return NOTIFY_DONE;
26052
26053 switch (val) {
26054 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26055
26056 if (ncopied != rasize) {
26057 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26058 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26059 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26060
26061 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26062 }
26063 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26064 index b9242ba..50c5edd 100644
26065 --- a/arch/x86/kernel/verify_cpu.S
26066 +++ b/arch/x86/kernel/verify_cpu.S
26067 @@ -20,6 +20,7 @@
26068 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26069 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26070 * arch/x86/kernel/head_32.S: processor startup
26071 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26072 *
26073 * verify_cpu, returns the status of longmode and SSE in register %eax.
26074 * 0: Success 1: Failure
26075 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26076 index e8edcf5..27f9344 100644
26077 --- a/arch/x86/kernel/vm86_32.c
26078 +++ b/arch/x86/kernel/vm86_32.c
26079 @@ -44,6 +44,7 @@
26080 #include <linux/ptrace.h>
26081 #include <linux/audit.h>
26082 #include <linux/stddef.h>
26083 +#include <linux/grsecurity.h>
26084
26085 #include <asm/uaccess.h>
26086 #include <asm/io.h>
26087 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26088 do_exit(SIGSEGV);
26089 }
26090
26091 - tss = &per_cpu(init_tss, get_cpu());
26092 + tss = init_tss + get_cpu();
26093 current->thread.sp0 = current->thread.saved_sp0;
26094 current->thread.sysenter_cs = __KERNEL_CS;
26095 load_sp0(tss, &current->thread);
26096 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26097
26098 if (tsk->thread.saved_sp0)
26099 return -EPERM;
26100 +
26101 +#ifdef CONFIG_GRKERNSEC_VM86
26102 + if (!capable(CAP_SYS_RAWIO)) {
26103 + gr_handle_vm86();
26104 + return -EPERM;
26105 + }
26106 +#endif
26107 +
26108 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26109 offsetof(struct kernel_vm86_struct, vm86plus) -
26110 sizeof(info.regs));
26111 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26112 int tmp;
26113 struct vm86plus_struct __user *v86;
26114
26115 +#ifdef CONFIG_GRKERNSEC_VM86
26116 + if (!capable(CAP_SYS_RAWIO)) {
26117 + gr_handle_vm86();
26118 + return -EPERM;
26119 + }
26120 +#endif
26121 +
26122 tsk = current;
26123 switch (cmd) {
26124 case VM86_REQUEST_IRQ:
26125 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26126 tsk->thread.saved_fs = info->regs32->fs;
26127 tsk->thread.saved_gs = get_user_gs(info->regs32);
26128
26129 - tss = &per_cpu(init_tss, get_cpu());
26130 + tss = init_tss + get_cpu();
26131 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26132 if (cpu_has_sep)
26133 tsk->thread.sysenter_cs = 0;
26134 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26135 goto cannot_handle;
26136 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26137 goto cannot_handle;
26138 - intr_ptr = (unsigned long __user *) (i << 2);
26139 + intr_ptr = (__force unsigned long __user *) (i << 2);
26140 if (get_user(segoffs, intr_ptr))
26141 goto cannot_handle;
26142 if ((segoffs >> 16) == BIOSSEG)
26143 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26144 index 10c4f30..65408b9 100644
26145 --- a/arch/x86/kernel/vmlinux.lds.S
26146 +++ b/arch/x86/kernel/vmlinux.lds.S
26147 @@ -26,6 +26,13 @@
26148 #include <asm/page_types.h>
26149 #include <asm/cache.h>
26150 #include <asm/boot.h>
26151 +#include <asm/segment.h>
26152 +
26153 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26154 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26155 +#else
26156 +#define __KERNEL_TEXT_OFFSET 0
26157 +#endif
26158
26159 #undef i386 /* in case the preprocessor is a 32bit one */
26160
26161 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26162
26163 PHDRS {
26164 text PT_LOAD FLAGS(5); /* R_E */
26165 +#ifdef CONFIG_X86_32
26166 + module PT_LOAD FLAGS(5); /* R_E */
26167 +#endif
26168 +#ifdef CONFIG_XEN
26169 + rodata PT_LOAD FLAGS(5); /* R_E */
26170 +#else
26171 + rodata PT_LOAD FLAGS(4); /* R__ */
26172 +#endif
26173 data PT_LOAD FLAGS(6); /* RW_ */
26174 -#ifdef CONFIG_X86_64
26175 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26176 #ifdef CONFIG_SMP
26177 percpu PT_LOAD FLAGS(6); /* RW_ */
26178 #endif
26179 + text.init PT_LOAD FLAGS(5); /* R_E */
26180 + text.exit PT_LOAD FLAGS(5); /* R_E */
26181 init PT_LOAD FLAGS(7); /* RWE */
26182 -#endif
26183 note PT_NOTE FLAGS(0); /* ___ */
26184 }
26185
26186 SECTIONS
26187 {
26188 #ifdef CONFIG_X86_32
26189 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26190 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26191 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26192 #else
26193 - . = __START_KERNEL;
26194 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26195 + . = __START_KERNEL;
26196 #endif
26197
26198 /* Text and read-only data */
26199 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26200 - _text = .;
26201 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26202 /* bootstrapping code */
26203 +#ifdef CONFIG_X86_32
26204 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26205 +#else
26206 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26207 +#endif
26208 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26209 + _text = .;
26210 HEAD_TEXT
26211 . = ALIGN(8);
26212 _stext = .;
26213 @@ -104,13 +124,47 @@ SECTIONS
26214 IRQENTRY_TEXT
26215 *(.fixup)
26216 *(.gnu.warning)
26217 - /* End of text section */
26218 - _etext = .;
26219 } :text = 0x9090
26220
26221 - NOTES :text :note
26222 + . += __KERNEL_TEXT_OFFSET;
26223
26224 - EXCEPTION_TABLE(16) :text = 0x9090
26225 +#ifdef CONFIG_X86_32
26226 + . = ALIGN(PAGE_SIZE);
26227 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26228 +
26229 +#ifdef CONFIG_PAX_KERNEXEC
26230 + MODULES_EXEC_VADDR = .;
26231 + BYTE(0)
26232 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26233 + . = ALIGN(HPAGE_SIZE) - 1;
26234 + MODULES_EXEC_END = .;
26235 +#endif
26236 +
26237 + } :module
26238 +#endif
26239 +
26240 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26241 + /* End of text section */
26242 + BYTE(0)
26243 + _etext = . - __KERNEL_TEXT_OFFSET;
26244 + }
26245 +
26246 +#ifdef CONFIG_X86_32
26247 + . = ALIGN(PAGE_SIZE);
26248 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26249 + . = ALIGN(PAGE_SIZE);
26250 + *(.empty_zero_page)
26251 + *(.initial_pg_fixmap)
26252 + *(.initial_pg_pmd)
26253 + *(.initial_page_table)
26254 + *(.swapper_pg_dir)
26255 + } :rodata
26256 +#endif
26257 +
26258 + . = ALIGN(PAGE_SIZE);
26259 + NOTES :rodata :note
26260 +
26261 + EXCEPTION_TABLE(16) :rodata
26262
26263 #if defined(CONFIG_DEBUG_RODATA)
26264 /* .text should occupy whole number of pages */
26265 @@ -122,16 +176,20 @@ SECTIONS
26266
26267 /* Data */
26268 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26269 +
26270 +#ifdef CONFIG_PAX_KERNEXEC
26271 + . = ALIGN(HPAGE_SIZE);
26272 +#else
26273 + . = ALIGN(PAGE_SIZE);
26274 +#endif
26275 +
26276 /* Start of data section */
26277 _sdata = .;
26278
26279 /* init_task */
26280 INIT_TASK_DATA(THREAD_SIZE)
26281
26282 -#ifdef CONFIG_X86_32
26283 - /* 32 bit has nosave before _edata */
26284 NOSAVE_DATA
26285 -#endif
26286
26287 PAGE_ALIGNED_DATA(PAGE_SIZE)
26288
26289 @@ -172,12 +230,19 @@ SECTIONS
26290 #endif /* CONFIG_X86_64 */
26291
26292 /* Init code and data - will be freed after init */
26293 - . = ALIGN(PAGE_SIZE);
26294 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26295 + BYTE(0)
26296 +
26297 +#ifdef CONFIG_PAX_KERNEXEC
26298 + . = ALIGN(HPAGE_SIZE);
26299 +#else
26300 + . = ALIGN(PAGE_SIZE);
26301 +#endif
26302 +
26303 __init_begin = .; /* paired with __init_end */
26304 - }
26305 + } :init.begin
26306
26307 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26308 +#ifdef CONFIG_SMP
26309 /*
26310 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26311 * output PHDR, so the next output section - .init.text - should
26312 @@ -186,12 +251,27 @@ SECTIONS
26313 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26314 #endif
26315
26316 - INIT_TEXT_SECTION(PAGE_SIZE)
26317 -#ifdef CONFIG_X86_64
26318 - :init
26319 -#endif
26320 + . = ALIGN(PAGE_SIZE);
26321 + init_begin = .;
26322 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26323 + VMLINUX_SYMBOL(_sinittext) = .;
26324 + INIT_TEXT
26325 + VMLINUX_SYMBOL(_einittext) = .;
26326 + . = ALIGN(PAGE_SIZE);
26327 + } :text.init
26328
26329 - INIT_DATA_SECTION(16)
26330 + /*
26331 + * .exit.text is discard at runtime, not link time, to deal with
26332 + * references from .altinstructions and .eh_frame
26333 + */
26334 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26335 + EXIT_TEXT
26336 + . = ALIGN(16);
26337 + } :text.exit
26338 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26339 +
26340 + . = ALIGN(PAGE_SIZE);
26341 + INIT_DATA_SECTION(16) :init
26342
26343 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26344 __x86_cpu_dev_start = .;
26345 @@ -253,19 +333,12 @@ SECTIONS
26346 }
26347
26348 . = ALIGN(8);
26349 - /*
26350 - * .exit.text is discard at runtime, not link time, to deal with
26351 - * references from .altinstructions and .eh_frame
26352 - */
26353 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26354 - EXIT_TEXT
26355 - }
26356
26357 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26358 EXIT_DATA
26359 }
26360
26361 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26362 +#ifndef CONFIG_SMP
26363 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26364 #endif
26365
26366 @@ -284,16 +357,10 @@ SECTIONS
26367 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26368 __smp_locks = .;
26369 *(.smp_locks)
26370 - . = ALIGN(PAGE_SIZE);
26371 __smp_locks_end = .;
26372 + . = ALIGN(PAGE_SIZE);
26373 }
26374
26375 -#ifdef CONFIG_X86_64
26376 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26377 - NOSAVE_DATA
26378 - }
26379 -#endif
26380 -
26381 /* BSS */
26382 . = ALIGN(PAGE_SIZE);
26383 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26384 @@ -309,6 +376,7 @@ SECTIONS
26385 __brk_base = .;
26386 . += 64 * 1024; /* 64k alignment slop space */
26387 *(.brk_reservation) /* areas brk users have reserved */
26388 + . = ALIGN(HPAGE_SIZE);
26389 __brk_limit = .;
26390 }
26391
26392 @@ -335,13 +403,12 @@ SECTIONS
26393 * for the boot processor.
26394 */
26395 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26396 -INIT_PER_CPU(gdt_page);
26397 INIT_PER_CPU(irq_stack_union);
26398
26399 /*
26400 * Build-time check on the image size:
26401 */
26402 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26403 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26404 "kernel image bigger than KERNEL_IMAGE_SIZE");
26405
26406 #ifdef CONFIG_SMP
26407 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26408 index 1f96f93..d5c8f7a 100644
26409 --- a/arch/x86/kernel/vsyscall_64.c
26410 +++ b/arch/x86/kernel/vsyscall_64.c
26411 @@ -56,15 +56,13 @@
26412 DEFINE_VVAR(int, vgetcpu_mode);
26413 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26414
26415 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26416 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26417
26418 static int __init vsyscall_setup(char *str)
26419 {
26420 if (str) {
26421 if (!strcmp("emulate", str))
26422 vsyscall_mode = EMULATE;
26423 - else if (!strcmp("native", str))
26424 - vsyscall_mode = NATIVE;
26425 else if (!strcmp("none", str))
26426 vsyscall_mode = NONE;
26427 else
26428 @@ -323,8 +321,7 @@ do_ret:
26429 return true;
26430
26431 sigsegv:
26432 - force_sig(SIGSEGV, current);
26433 - return true;
26434 + do_group_exit(SIGKILL);
26435 }
26436
26437 /*
26438 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26439 extern char __vvar_page;
26440 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26441
26442 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26443 - vsyscall_mode == NATIVE
26444 - ? PAGE_KERNEL_VSYSCALL
26445 - : PAGE_KERNEL_VVAR);
26446 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26447 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26448 (unsigned long)VSYSCALL_START);
26449
26450 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26451 index b014d94..e775258 100644
26452 --- a/arch/x86/kernel/x8664_ksyms_64.c
26453 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26454 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26455 EXPORT_SYMBOL(copy_user_generic_unrolled);
26456 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26457 EXPORT_SYMBOL(__copy_user_nocache);
26458 -EXPORT_SYMBOL(_copy_from_user);
26459 -EXPORT_SYMBOL(_copy_to_user);
26460
26461 EXPORT_SYMBOL(copy_page);
26462 EXPORT_SYMBOL(clear_page);
26463 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26464 #ifndef CONFIG_PARAVIRT
26465 EXPORT_SYMBOL(native_load_gs_index);
26466 #endif
26467 +
26468 +#ifdef CONFIG_PAX_PER_CPU_PGD
26469 +EXPORT_SYMBOL(cpu_pgd);
26470 +#endif
26471 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26472 index 5f24c71..1dadf09 100644
26473 --- a/arch/x86/kernel/x86_init.c
26474 +++ b/arch/x86/kernel/x86_init.c
26475 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26476 static void default_nmi_init(void) { };
26477 static int default_i8042_detect(void) { return 1; };
26478
26479 -struct x86_platform_ops x86_platform = {
26480 +struct x86_platform_ops x86_platform __read_only = {
26481 .calibrate_tsc = native_calibrate_tsc,
26482 .get_wallclock = mach_get_cmos_time,
26483 .set_wallclock = mach_set_rtc_mmss,
26484 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26485 };
26486
26487 EXPORT_SYMBOL_GPL(x86_platform);
26488 -struct x86_msi_ops x86_msi = {
26489 +struct x86_msi_ops x86_msi __read_only = {
26490 .setup_msi_irqs = native_setup_msi_irqs,
26491 .compose_msi_msg = native_compose_msi_msg,
26492 .teardown_msi_irq = native_teardown_msi_irq,
26493 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26494 .setup_hpet_msi = default_setup_hpet_msi,
26495 };
26496
26497 -struct x86_io_apic_ops x86_io_apic_ops = {
26498 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26499 .init = native_io_apic_init_mappings,
26500 .read = native_io_apic_read,
26501 .write = native_io_apic_write,
26502 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26503 index 422fd82..c3687ca 100644
26504 --- a/arch/x86/kernel/xsave.c
26505 +++ b/arch/x86/kernel/xsave.c
26506 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26507 {
26508 int err;
26509
26510 + buf = (struct xsave_struct __user *)____m(buf);
26511 if (use_xsave())
26512 err = xsave_user(buf);
26513 else if (use_fxsr())
26514 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26515 */
26516 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26517 {
26518 + buf = (void __user *)____m(buf);
26519 if (use_xsave()) {
26520 if ((unsigned long)buf % 64 || fx_only) {
26521 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26522 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26523 index a20ecb5..d0e2194 100644
26524 --- a/arch/x86/kvm/cpuid.c
26525 +++ b/arch/x86/kvm/cpuid.c
26526 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26527 struct kvm_cpuid2 *cpuid,
26528 struct kvm_cpuid_entry2 __user *entries)
26529 {
26530 - int r;
26531 + int r, i;
26532
26533 r = -E2BIG;
26534 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26535 goto out;
26536 r = -EFAULT;
26537 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26538 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26539 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26540 goto out;
26541 + for (i = 0; i < cpuid->nent; ++i) {
26542 + struct kvm_cpuid_entry2 cpuid_entry;
26543 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26544 + goto out;
26545 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26546 + }
26547 vcpu->arch.cpuid_nent = cpuid->nent;
26548 kvm_apic_set_version(vcpu);
26549 kvm_x86_ops->cpuid_update(vcpu);
26550 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26551 struct kvm_cpuid2 *cpuid,
26552 struct kvm_cpuid_entry2 __user *entries)
26553 {
26554 - int r;
26555 + int r, i;
26556
26557 r = -E2BIG;
26558 if (cpuid->nent < vcpu->arch.cpuid_nent)
26559 goto out;
26560 r = -EFAULT;
26561 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26562 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26563 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26564 goto out;
26565 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26566 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26567 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26568 + goto out;
26569 + }
26570 return 0;
26571
26572 out:
26573 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26574 index afc1124..3e431f2 100644
26575 --- a/arch/x86/kvm/lapic.c
26576 +++ b/arch/x86/kvm/lapic.c
26577 @@ -55,7 +55,7 @@
26578 #define APIC_BUS_CYCLE_NS 1
26579
26580 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26581 -#define apic_debug(fmt, arg...)
26582 +#define apic_debug(fmt, arg...) do {} while (0)
26583
26584 #define APIC_LVT_NUM 6
26585 /* 14 is the version for Xeon and Pentium 8.4.8*/
26586 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26587 index 7769699..c8aca4a7f 100644
26588 --- a/arch/x86/kvm/paging_tmpl.h
26589 +++ b/arch/x86/kvm/paging_tmpl.h
26590 @@ -208,7 +208,7 @@ retry_walk:
26591 if (unlikely(kvm_is_error_hva(host_addr)))
26592 goto error;
26593
26594 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26595 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26596 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26597 goto error;
26598 walker->ptep_user[walker->level - 1] = ptep_user;
26599 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26600 index c0bc803..6837a50 100644
26601 --- a/arch/x86/kvm/svm.c
26602 +++ b/arch/x86/kvm/svm.c
26603 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26604 int cpu = raw_smp_processor_id();
26605
26606 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26607 +
26608 + pax_open_kernel();
26609 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26610 + pax_close_kernel();
26611 +
26612 load_TR_desc();
26613 }
26614
26615 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26616 #endif
26617 #endif
26618
26619 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26620 + __set_fs(current_thread_info()->addr_limit);
26621 +#endif
26622 +
26623 reload_tss(vcpu);
26624
26625 local_irq_disable();
26626 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26627 index 064d0be..f5f758e 100644
26628 --- a/arch/x86/kvm/vmx.c
26629 +++ b/arch/x86/kvm/vmx.c
26630 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26631 #endif
26632 }
26633
26634 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26635 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26636 {
26637 vmcs_writel(field, vmcs_readl(field) & ~mask);
26638 }
26639
26640 -static void vmcs_set_bits(unsigned long field, u32 mask)
26641 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26642 {
26643 vmcs_writel(field, vmcs_readl(field) | mask);
26644 }
26645 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26646 struct desc_struct *descs;
26647
26648 descs = (void *)gdt->address;
26649 +
26650 + pax_open_kernel();
26651 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26652 + pax_close_kernel();
26653 +
26654 load_TR_desc();
26655 }
26656
26657 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26658 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26659 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26660
26661 +#ifdef CONFIG_PAX_PER_CPU_PGD
26662 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26663 +#endif
26664 +
26665 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26666 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26667 vmx->loaded_vmcs->cpu = cpu;
26668 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26669 if (!cpu_has_vmx_flexpriority())
26670 flexpriority_enabled = 0;
26671
26672 - if (!cpu_has_vmx_tpr_shadow())
26673 - kvm_x86_ops->update_cr8_intercept = NULL;
26674 + if (!cpu_has_vmx_tpr_shadow()) {
26675 + pax_open_kernel();
26676 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26677 + pax_close_kernel();
26678 + }
26679
26680 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26681 kvm_disable_largepages();
26682 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26683 if (!cpu_has_vmx_apicv())
26684 enable_apicv = 0;
26685
26686 + pax_open_kernel();
26687 if (enable_apicv)
26688 - kvm_x86_ops->update_cr8_intercept = NULL;
26689 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26690 else {
26691 - kvm_x86_ops->hwapic_irr_update = NULL;
26692 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26693 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26694 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26695 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26696 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26697 }
26698 + pax_close_kernel();
26699
26700 if (nested)
26701 nested_vmx_setup_ctls_msrs();
26702 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26703
26704 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26705 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26706 +
26707 +#ifndef CONFIG_PAX_PER_CPU_PGD
26708 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26709 +#endif
26710
26711 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26712 #ifdef CONFIG_X86_64
26713 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26714 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26715 vmx->host_idt_base = dt.address;
26716
26717 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26718 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26719
26720 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26721 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26722 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26723 "jmp 2f \n\t"
26724 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26725 "2: "
26726 +
26727 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26728 + "ljmp %[cs],$3f\n\t"
26729 + "3: "
26730 +#endif
26731 +
26732 /* Save guest registers, load host registers, keep flags */
26733 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26734 "pop %0 \n\t"
26735 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26736 #endif
26737 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26738 [wordsize]"i"(sizeof(ulong))
26739 +
26740 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26741 + ,[cs]"i"(__KERNEL_CS)
26742 +#endif
26743 +
26744 : "cc", "memory"
26745 #ifdef CONFIG_X86_64
26746 , "rax", "rbx", "rdi", "rsi"
26747 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26748 if (debugctlmsr)
26749 update_debugctlmsr(debugctlmsr);
26750
26751 -#ifndef CONFIG_X86_64
26752 +#ifdef CONFIG_X86_32
26753 /*
26754 * The sysexit path does not restore ds/es, so we must set them to
26755 * a reasonable value ourselves.
26756 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26757 * may be executed in interrupt context, which saves and restore segments
26758 * around it, nullifying its effect.
26759 */
26760 - loadsegment(ds, __USER_DS);
26761 - loadsegment(es, __USER_DS);
26762 + loadsegment(ds, __KERNEL_DS);
26763 + loadsegment(es, __KERNEL_DS);
26764 + loadsegment(ss, __KERNEL_DS);
26765 +
26766 +#ifdef CONFIG_PAX_KERNEXEC
26767 + loadsegment(fs, __KERNEL_PERCPU);
26768 +#endif
26769 +
26770 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26771 + __set_fs(current_thread_info()->addr_limit);
26772 +#endif
26773 +
26774 #endif
26775
26776 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26777 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26778 index d21bce5..fdae9f1 100644
26779 --- a/arch/x86/kvm/x86.c
26780 +++ b/arch/x86/kvm/x86.c
26781 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26782 {
26783 struct kvm *kvm = vcpu->kvm;
26784 int lm = is_long_mode(vcpu);
26785 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26786 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26787 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26788 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26789 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26790 : kvm->arch.xen_hvm_config.blob_size_32;
26791 u32 page_num = data & ~PAGE_MASK;
26792 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26793 if (n < msr_list.nmsrs)
26794 goto out;
26795 r = -EFAULT;
26796 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26797 + goto out;
26798 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26799 num_msrs_to_save * sizeof(u32)))
26800 goto out;
26801 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26802 };
26803 #endif
26804
26805 -int kvm_arch_init(void *opaque)
26806 +int kvm_arch_init(const void *opaque)
26807 {
26808 int r;
26809 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26810 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26811 index 6a22c19..1763f04 100644
26812 --- a/arch/x86/lguest/boot.c
26813 +++ b/arch/x86/lguest/boot.c
26814 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26815 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26816 * Launcher to reboot us.
26817 */
26818 -static void lguest_restart(char *reason)
26819 +static __noreturn void lguest_restart(char *reason)
26820 {
26821 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26822 + BUG();
26823 }
26824
26825 /*G:050
26826 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26827 index 00933d5..3a64af9 100644
26828 --- a/arch/x86/lib/atomic64_386_32.S
26829 +++ b/arch/x86/lib/atomic64_386_32.S
26830 @@ -48,6 +48,10 @@ BEGIN(read)
26831 movl (v), %eax
26832 movl 4(v), %edx
26833 RET_ENDP
26834 +BEGIN(read_unchecked)
26835 + movl (v), %eax
26836 + movl 4(v), %edx
26837 +RET_ENDP
26838 #undef v
26839
26840 #define v %esi
26841 @@ -55,6 +59,10 @@ BEGIN(set)
26842 movl %ebx, (v)
26843 movl %ecx, 4(v)
26844 RET_ENDP
26845 +BEGIN(set_unchecked)
26846 + movl %ebx, (v)
26847 + movl %ecx, 4(v)
26848 +RET_ENDP
26849 #undef v
26850
26851 #define v %esi
26852 @@ -70,6 +78,20 @@ RET_ENDP
26853 BEGIN(add)
26854 addl %eax, (v)
26855 adcl %edx, 4(v)
26856 +
26857 +#ifdef CONFIG_PAX_REFCOUNT
26858 + jno 0f
26859 + subl %eax, (v)
26860 + sbbl %edx, 4(v)
26861 + int $4
26862 +0:
26863 + _ASM_EXTABLE(0b, 0b)
26864 +#endif
26865 +
26866 +RET_ENDP
26867 +BEGIN(add_unchecked)
26868 + addl %eax, (v)
26869 + adcl %edx, 4(v)
26870 RET_ENDP
26871 #undef v
26872
26873 @@ -77,6 +99,24 @@ RET_ENDP
26874 BEGIN(add_return)
26875 addl (v), %eax
26876 adcl 4(v), %edx
26877 +
26878 +#ifdef CONFIG_PAX_REFCOUNT
26879 + into
26880 +1234:
26881 + _ASM_EXTABLE(1234b, 2f)
26882 +#endif
26883 +
26884 + movl %eax, (v)
26885 + movl %edx, 4(v)
26886 +
26887 +#ifdef CONFIG_PAX_REFCOUNT
26888 +2:
26889 +#endif
26890 +
26891 +RET_ENDP
26892 +BEGIN(add_return_unchecked)
26893 + addl (v), %eax
26894 + adcl 4(v), %edx
26895 movl %eax, (v)
26896 movl %edx, 4(v)
26897 RET_ENDP
26898 @@ -86,6 +126,20 @@ RET_ENDP
26899 BEGIN(sub)
26900 subl %eax, (v)
26901 sbbl %edx, 4(v)
26902 +
26903 +#ifdef CONFIG_PAX_REFCOUNT
26904 + jno 0f
26905 + addl %eax, (v)
26906 + adcl %edx, 4(v)
26907 + int $4
26908 +0:
26909 + _ASM_EXTABLE(0b, 0b)
26910 +#endif
26911 +
26912 +RET_ENDP
26913 +BEGIN(sub_unchecked)
26914 + subl %eax, (v)
26915 + sbbl %edx, 4(v)
26916 RET_ENDP
26917 #undef v
26918
26919 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26920 sbbl $0, %edx
26921 addl (v), %eax
26922 adcl 4(v), %edx
26923 +
26924 +#ifdef CONFIG_PAX_REFCOUNT
26925 + into
26926 +1234:
26927 + _ASM_EXTABLE(1234b, 2f)
26928 +#endif
26929 +
26930 + movl %eax, (v)
26931 + movl %edx, 4(v)
26932 +
26933 +#ifdef CONFIG_PAX_REFCOUNT
26934 +2:
26935 +#endif
26936 +
26937 +RET_ENDP
26938 +BEGIN(sub_return_unchecked)
26939 + negl %edx
26940 + negl %eax
26941 + sbbl $0, %edx
26942 + addl (v), %eax
26943 + adcl 4(v), %edx
26944 movl %eax, (v)
26945 movl %edx, 4(v)
26946 RET_ENDP
26947 @@ -105,6 +180,20 @@ RET_ENDP
26948 BEGIN(inc)
26949 addl $1, (v)
26950 adcl $0, 4(v)
26951 +
26952 +#ifdef CONFIG_PAX_REFCOUNT
26953 + jno 0f
26954 + subl $1, (v)
26955 + sbbl $0, 4(v)
26956 + int $4
26957 +0:
26958 + _ASM_EXTABLE(0b, 0b)
26959 +#endif
26960 +
26961 +RET_ENDP
26962 +BEGIN(inc_unchecked)
26963 + addl $1, (v)
26964 + adcl $0, 4(v)
26965 RET_ENDP
26966 #undef v
26967
26968 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26969 movl 4(v), %edx
26970 addl $1, %eax
26971 adcl $0, %edx
26972 +
26973 +#ifdef CONFIG_PAX_REFCOUNT
26974 + into
26975 +1234:
26976 + _ASM_EXTABLE(1234b, 2f)
26977 +#endif
26978 +
26979 + movl %eax, (v)
26980 + movl %edx, 4(v)
26981 +
26982 +#ifdef CONFIG_PAX_REFCOUNT
26983 +2:
26984 +#endif
26985 +
26986 +RET_ENDP
26987 +BEGIN(inc_return_unchecked)
26988 + movl (v), %eax
26989 + movl 4(v), %edx
26990 + addl $1, %eax
26991 + adcl $0, %edx
26992 movl %eax, (v)
26993 movl %edx, 4(v)
26994 RET_ENDP
26995 @@ -123,6 +232,20 @@ RET_ENDP
26996 BEGIN(dec)
26997 subl $1, (v)
26998 sbbl $0, 4(v)
26999 +
27000 +#ifdef CONFIG_PAX_REFCOUNT
27001 + jno 0f
27002 + addl $1, (v)
27003 + adcl $0, 4(v)
27004 + int $4
27005 +0:
27006 + _ASM_EXTABLE(0b, 0b)
27007 +#endif
27008 +
27009 +RET_ENDP
27010 +BEGIN(dec_unchecked)
27011 + subl $1, (v)
27012 + sbbl $0, 4(v)
27013 RET_ENDP
27014 #undef v
27015
27016 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27017 movl 4(v), %edx
27018 subl $1, %eax
27019 sbbl $0, %edx
27020 +
27021 +#ifdef CONFIG_PAX_REFCOUNT
27022 + into
27023 +1234:
27024 + _ASM_EXTABLE(1234b, 2f)
27025 +#endif
27026 +
27027 + movl %eax, (v)
27028 + movl %edx, 4(v)
27029 +
27030 +#ifdef CONFIG_PAX_REFCOUNT
27031 +2:
27032 +#endif
27033 +
27034 +RET_ENDP
27035 +BEGIN(dec_return_unchecked)
27036 + movl (v), %eax
27037 + movl 4(v), %edx
27038 + subl $1, %eax
27039 + sbbl $0, %edx
27040 movl %eax, (v)
27041 movl %edx, 4(v)
27042 RET_ENDP
27043 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27044 adcl %edx, %edi
27045 addl (v), %eax
27046 adcl 4(v), %edx
27047 +
27048 +#ifdef CONFIG_PAX_REFCOUNT
27049 + into
27050 +1234:
27051 + _ASM_EXTABLE(1234b, 2f)
27052 +#endif
27053 +
27054 cmpl %eax, %ecx
27055 je 3f
27056 1:
27057 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27058 1:
27059 addl $1, %eax
27060 adcl $0, %edx
27061 +
27062 +#ifdef CONFIG_PAX_REFCOUNT
27063 + into
27064 +1234:
27065 + _ASM_EXTABLE(1234b, 2f)
27066 +#endif
27067 +
27068 movl %eax, (v)
27069 movl %edx, 4(v)
27070 movl $1, %eax
27071 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27072 movl 4(v), %edx
27073 subl $1, %eax
27074 sbbl $0, %edx
27075 +
27076 +#ifdef CONFIG_PAX_REFCOUNT
27077 + into
27078 +1234:
27079 + _ASM_EXTABLE(1234b, 1f)
27080 +#endif
27081 +
27082 js 1f
27083 movl %eax, (v)
27084 movl %edx, 4(v)
27085 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27086 index f5cc9eb..51fa319 100644
27087 --- a/arch/x86/lib/atomic64_cx8_32.S
27088 +++ b/arch/x86/lib/atomic64_cx8_32.S
27089 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27090 CFI_STARTPROC
27091
27092 read64 %ecx
27093 + pax_force_retaddr
27094 ret
27095 CFI_ENDPROC
27096 ENDPROC(atomic64_read_cx8)
27097
27098 +ENTRY(atomic64_read_unchecked_cx8)
27099 + CFI_STARTPROC
27100 +
27101 + read64 %ecx
27102 + pax_force_retaddr
27103 + ret
27104 + CFI_ENDPROC
27105 +ENDPROC(atomic64_read_unchecked_cx8)
27106 +
27107 ENTRY(atomic64_set_cx8)
27108 CFI_STARTPROC
27109
27110 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27111 cmpxchg8b (%esi)
27112 jne 1b
27113
27114 + pax_force_retaddr
27115 ret
27116 CFI_ENDPROC
27117 ENDPROC(atomic64_set_cx8)
27118
27119 +ENTRY(atomic64_set_unchecked_cx8)
27120 + CFI_STARTPROC
27121 +
27122 +1:
27123 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27124 + * are atomic on 586 and newer */
27125 + cmpxchg8b (%esi)
27126 + jne 1b
27127 +
27128 + pax_force_retaddr
27129 + ret
27130 + CFI_ENDPROC
27131 +ENDPROC(atomic64_set_unchecked_cx8)
27132 +
27133 ENTRY(atomic64_xchg_cx8)
27134 CFI_STARTPROC
27135
27136 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27137 cmpxchg8b (%esi)
27138 jne 1b
27139
27140 + pax_force_retaddr
27141 ret
27142 CFI_ENDPROC
27143 ENDPROC(atomic64_xchg_cx8)
27144
27145 -.macro addsub_return func ins insc
27146 -ENTRY(atomic64_\func\()_return_cx8)
27147 +.macro addsub_return func ins insc unchecked=""
27148 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27149 CFI_STARTPROC
27150 SAVE ebp
27151 SAVE ebx
27152 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27153 movl %edx, %ecx
27154 \ins\()l %esi, %ebx
27155 \insc\()l %edi, %ecx
27156 +
27157 +.ifb \unchecked
27158 +#ifdef CONFIG_PAX_REFCOUNT
27159 + into
27160 +2:
27161 + _ASM_EXTABLE(2b, 3f)
27162 +#endif
27163 +.endif
27164 +
27165 LOCK_PREFIX
27166 cmpxchg8b (%ebp)
27167 jne 1b
27168 -
27169 -10:
27170 movl %ebx, %eax
27171 movl %ecx, %edx
27172 +
27173 +.ifb \unchecked
27174 +#ifdef CONFIG_PAX_REFCOUNT
27175 +3:
27176 +#endif
27177 +.endif
27178 +
27179 RESTORE edi
27180 RESTORE esi
27181 RESTORE ebx
27182 RESTORE ebp
27183 + pax_force_retaddr
27184 ret
27185 CFI_ENDPROC
27186 -ENDPROC(atomic64_\func\()_return_cx8)
27187 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27188 .endm
27189
27190 addsub_return add add adc
27191 addsub_return sub sub sbb
27192 +addsub_return add add adc _unchecked
27193 +addsub_return sub sub sbb _unchecked
27194
27195 -.macro incdec_return func ins insc
27196 -ENTRY(atomic64_\func\()_return_cx8)
27197 +.macro incdec_return func ins insc unchecked=""
27198 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27199 CFI_STARTPROC
27200 SAVE ebx
27201
27202 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27203 movl %edx, %ecx
27204 \ins\()l $1, %ebx
27205 \insc\()l $0, %ecx
27206 +
27207 +.ifb \unchecked
27208 +#ifdef CONFIG_PAX_REFCOUNT
27209 + into
27210 +2:
27211 + _ASM_EXTABLE(2b, 3f)
27212 +#endif
27213 +.endif
27214 +
27215 LOCK_PREFIX
27216 cmpxchg8b (%esi)
27217 jne 1b
27218
27219 -10:
27220 movl %ebx, %eax
27221 movl %ecx, %edx
27222 +
27223 +.ifb \unchecked
27224 +#ifdef CONFIG_PAX_REFCOUNT
27225 +3:
27226 +#endif
27227 +.endif
27228 +
27229 RESTORE ebx
27230 + pax_force_retaddr
27231 ret
27232 CFI_ENDPROC
27233 -ENDPROC(atomic64_\func\()_return_cx8)
27234 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27235 .endm
27236
27237 incdec_return inc add adc
27238 incdec_return dec sub sbb
27239 +incdec_return inc add adc _unchecked
27240 +incdec_return dec sub sbb _unchecked
27241
27242 ENTRY(atomic64_dec_if_positive_cx8)
27243 CFI_STARTPROC
27244 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27245 movl %edx, %ecx
27246 subl $1, %ebx
27247 sbb $0, %ecx
27248 +
27249 +#ifdef CONFIG_PAX_REFCOUNT
27250 + into
27251 +1234:
27252 + _ASM_EXTABLE(1234b, 2f)
27253 +#endif
27254 +
27255 js 2f
27256 LOCK_PREFIX
27257 cmpxchg8b (%esi)
27258 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27259 movl %ebx, %eax
27260 movl %ecx, %edx
27261 RESTORE ebx
27262 + pax_force_retaddr
27263 ret
27264 CFI_ENDPROC
27265 ENDPROC(atomic64_dec_if_positive_cx8)
27266 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27267 movl %edx, %ecx
27268 addl %ebp, %ebx
27269 adcl %edi, %ecx
27270 +
27271 +#ifdef CONFIG_PAX_REFCOUNT
27272 + into
27273 +1234:
27274 + _ASM_EXTABLE(1234b, 3f)
27275 +#endif
27276 +
27277 LOCK_PREFIX
27278 cmpxchg8b (%esi)
27279 jne 1b
27280 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27281 CFI_ADJUST_CFA_OFFSET -8
27282 RESTORE ebx
27283 RESTORE ebp
27284 + pax_force_retaddr
27285 ret
27286 4:
27287 cmpl %edx, 4(%esp)
27288 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27289 xorl %ecx, %ecx
27290 addl $1, %ebx
27291 adcl %edx, %ecx
27292 +
27293 +#ifdef CONFIG_PAX_REFCOUNT
27294 + into
27295 +1234:
27296 + _ASM_EXTABLE(1234b, 3f)
27297 +#endif
27298 +
27299 LOCK_PREFIX
27300 cmpxchg8b (%esi)
27301 jne 1b
27302 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27303 movl $1, %eax
27304 3:
27305 RESTORE ebx
27306 + pax_force_retaddr
27307 ret
27308 CFI_ENDPROC
27309 ENDPROC(atomic64_inc_not_zero_cx8)
27310 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27311 index e78b8ee..7e173a8 100644
27312 --- a/arch/x86/lib/checksum_32.S
27313 +++ b/arch/x86/lib/checksum_32.S
27314 @@ -29,7 +29,8 @@
27315 #include <asm/dwarf2.h>
27316 #include <asm/errno.h>
27317 #include <asm/asm.h>
27318 -
27319 +#include <asm/segment.h>
27320 +
27321 /*
27322 * computes a partial checksum, e.g. for TCP/UDP fragments
27323 */
27324 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27325
27326 #define ARGBASE 16
27327 #define FP 12
27328 -
27329 -ENTRY(csum_partial_copy_generic)
27330 +
27331 +ENTRY(csum_partial_copy_generic_to_user)
27332 CFI_STARTPROC
27333 +
27334 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27335 + pushl_cfi %gs
27336 + popl_cfi %es
27337 + jmp csum_partial_copy_generic
27338 +#endif
27339 +
27340 +ENTRY(csum_partial_copy_generic_from_user)
27341 +
27342 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27343 + pushl_cfi %gs
27344 + popl_cfi %ds
27345 +#endif
27346 +
27347 +ENTRY(csum_partial_copy_generic)
27348 subl $4,%esp
27349 CFI_ADJUST_CFA_OFFSET 4
27350 pushl_cfi %edi
27351 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27352 jmp 4f
27353 SRC(1: movw (%esi), %bx )
27354 addl $2, %esi
27355 -DST( movw %bx, (%edi) )
27356 +DST( movw %bx, %es:(%edi) )
27357 addl $2, %edi
27358 addw %bx, %ax
27359 adcl $0, %eax
27360 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27361 SRC(1: movl (%esi), %ebx )
27362 SRC( movl 4(%esi), %edx )
27363 adcl %ebx, %eax
27364 -DST( movl %ebx, (%edi) )
27365 +DST( movl %ebx, %es:(%edi) )
27366 adcl %edx, %eax
27367 -DST( movl %edx, 4(%edi) )
27368 +DST( movl %edx, %es:4(%edi) )
27369
27370 SRC( movl 8(%esi), %ebx )
27371 SRC( movl 12(%esi), %edx )
27372 adcl %ebx, %eax
27373 -DST( movl %ebx, 8(%edi) )
27374 +DST( movl %ebx, %es:8(%edi) )
27375 adcl %edx, %eax
27376 -DST( movl %edx, 12(%edi) )
27377 +DST( movl %edx, %es:12(%edi) )
27378
27379 SRC( movl 16(%esi), %ebx )
27380 SRC( movl 20(%esi), %edx )
27381 adcl %ebx, %eax
27382 -DST( movl %ebx, 16(%edi) )
27383 +DST( movl %ebx, %es:16(%edi) )
27384 adcl %edx, %eax
27385 -DST( movl %edx, 20(%edi) )
27386 +DST( movl %edx, %es:20(%edi) )
27387
27388 SRC( movl 24(%esi), %ebx )
27389 SRC( movl 28(%esi), %edx )
27390 adcl %ebx, %eax
27391 -DST( movl %ebx, 24(%edi) )
27392 +DST( movl %ebx, %es:24(%edi) )
27393 adcl %edx, %eax
27394 -DST( movl %edx, 28(%edi) )
27395 +DST( movl %edx, %es:28(%edi) )
27396
27397 lea 32(%esi), %esi
27398 lea 32(%edi), %edi
27399 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27400 shrl $2, %edx # This clears CF
27401 SRC(3: movl (%esi), %ebx )
27402 adcl %ebx, %eax
27403 -DST( movl %ebx, (%edi) )
27404 +DST( movl %ebx, %es:(%edi) )
27405 lea 4(%esi), %esi
27406 lea 4(%edi), %edi
27407 dec %edx
27408 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27409 jb 5f
27410 SRC( movw (%esi), %cx )
27411 leal 2(%esi), %esi
27412 -DST( movw %cx, (%edi) )
27413 +DST( movw %cx, %es:(%edi) )
27414 leal 2(%edi), %edi
27415 je 6f
27416 shll $16,%ecx
27417 SRC(5: movb (%esi), %cl )
27418 -DST( movb %cl, (%edi) )
27419 +DST( movb %cl, %es:(%edi) )
27420 6: addl %ecx, %eax
27421 adcl $0, %eax
27422 7:
27423 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27424
27425 6001:
27426 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27427 - movl $-EFAULT, (%ebx)
27428 + movl $-EFAULT, %ss:(%ebx)
27429
27430 # zero the complete destination - computing the rest
27431 # is too much work
27432 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27433
27434 6002:
27435 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27436 - movl $-EFAULT,(%ebx)
27437 + movl $-EFAULT,%ss:(%ebx)
27438 jmp 5000b
27439
27440 .previous
27441
27442 + pushl_cfi %ss
27443 + popl_cfi %ds
27444 + pushl_cfi %ss
27445 + popl_cfi %es
27446 popl_cfi %ebx
27447 CFI_RESTORE ebx
27448 popl_cfi %esi
27449 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27450 popl_cfi %ecx # equivalent to addl $4,%esp
27451 ret
27452 CFI_ENDPROC
27453 -ENDPROC(csum_partial_copy_generic)
27454 +ENDPROC(csum_partial_copy_generic_to_user)
27455
27456 #else
27457
27458 /* Version for PentiumII/PPro */
27459
27460 #define ROUND1(x) \
27461 + nop; nop; nop; \
27462 SRC(movl x(%esi), %ebx ) ; \
27463 addl %ebx, %eax ; \
27464 - DST(movl %ebx, x(%edi) ) ;
27465 + DST(movl %ebx, %es:x(%edi)) ;
27466
27467 #define ROUND(x) \
27468 + nop; nop; nop; \
27469 SRC(movl x(%esi), %ebx ) ; \
27470 adcl %ebx, %eax ; \
27471 - DST(movl %ebx, x(%edi) ) ;
27472 + DST(movl %ebx, %es:x(%edi)) ;
27473
27474 #define ARGBASE 12
27475 -
27476 -ENTRY(csum_partial_copy_generic)
27477 +
27478 +ENTRY(csum_partial_copy_generic_to_user)
27479 CFI_STARTPROC
27480 +
27481 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27482 + pushl_cfi %gs
27483 + popl_cfi %es
27484 + jmp csum_partial_copy_generic
27485 +#endif
27486 +
27487 +ENTRY(csum_partial_copy_generic_from_user)
27488 +
27489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27490 + pushl_cfi %gs
27491 + popl_cfi %ds
27492 +#endif
27493 +
27494 +ENTRY(csum_partial_copy_generic)
27495 pushl_cfi %ebx
27496 CFI_REL_OFFSET ebx, 0
27497 pushl_cfi %edi
27498 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27499 subl %ebx, %edi
27500 lea -1(%esi),%edx
27501 andl $-32,%edx
27502 - lea 3f(%ebx,%ebx), %ebx
27503 + lea 3f(%ebx,%ebx,2), %ebx
27504 testl %esi, %esi
27505 jmp *%ebx
27506 1: addl $64,%esi
27507 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27508 jb 5f
27509 SRC( movw (%esi), %dx )
27510 leal 2(%esi), %esi
27511 -DST( movw %dx, (%edi) )
27512 +DST( movw %dx, %es:(%edi) )
27513 leal 2(%edi), %edi
27514 je 6f
27515 shll $16,%edx
27516 5:
27517 SRC( movb (%esi), %dl )
27518 -DST( movb %dl, (%edi) )
27519 +DST( movb %dl, %es:(%edi) )
27520 6: addl %edx, %eax
27521 adcl $0, %eax
27522 7:
27523 .section .fixup, "ax"
27524 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27525 - movl $-EFAULT, (%ebx)
27526 + movl $-EFAULT, %ss:(%ebx)
27527 # zero the complete destination (computing the rest is too much work)
27528 movl ARGBASE+8(%esp),%edi # dst
27529 movl ARGBASE+12(%esp),%ecx # len
27530 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27531 rep; stosb
27532 jmp 7b
27533 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27534 - movl $-EFAULT, (%ebx)
27535 + movl $-EFAULT, %ss:(%ebx)
27536 jmp 7b
27537 .previous
27538
27539 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27540 + pushl_cfi %ss
27541 + popl_cfi %ds
27542 + pushl_cfi %ss
27543 + popl_cfi %es
27544 +#endif
27545 +
27546 popl_cfi %esi
27547 CFI_RESTORE esi
27548 popl_cfi %edi
27549 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27550 CFI_RESTORE ebx
27551 ret
27552 CFI_ENDPROC
27553 -ENDPROC(csum_partial_copy_generic)
27554 +ENDPROC(csum_partial_copy_generic_to_user)
27555
27556 #undef ROUND
27557 #undef ROUND1
27558 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27559 index f2145cf..cea889d 100644
27560 --- a/arch/x86/lib/clear_page_64.S
27561 +++ b/arch/x86/lib/clear_page_64.S
27562 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27563 movl $4096/8,%ecx
27564 xorl %eax,%eax
27565 rep stosq
27566 + pax_force_retaddr
27567 ret
27568 CFI_ENDPROC
27569 ENDPROC(clear_page_c)
27570 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27571 movl $4096,%ecx
27572 xorl %eax,%eax
27573 rep stosb
27574 + pax_force_retaddr
27575 ret
27576 CFI_ENDPROC
27577 ENDPROC(clear_page_c_e)
27578 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27579 leaq 64(%rdi),%rdi
27580 jnz .Lloop
27581 nop
27582 + pax_force_retaddr
27583 ret
27584 CFI_ENDPROC
27585 .Lclear_page_end:
27586 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27587
27588 #include <asm/cpufeature.h>
27589
27590 - .section .altinstr_replacement,"ax"
27591 + .section .altinstr_replacement,"a"
27592 1: .byte 0xeb /* jmp <disp8> */
27593 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27594 2: .byte 0xeb /* jmp <disp8> */
27595 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27596 index 1e572c5..2a162cd 100644
27597 --- a/arch/x86/lib/cmpxchg16b_emu.S
27598 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27599 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27600
27601 popf
27602 mov $1, %al
27603 + pax_force_retaddr
27604 ret
27605
27606 not_same:
27607 popf
27608 xor %al,%al
27609 + pax_force_retaddr
27610 ret
27611
27612 CFI_ENDPROC
27613 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27614 index 176cca6..1166c50 100644
27615 --- a/arch/x86/lib/copy_page_64.S
27616 +++ b/arch/x86/lib/copy_page_64.S
27617 @@ -9,6 +9,7 @@ copy_page_rep:
27618 CFI_STARTPROC
27619 movl $4096/8, %ecx
27620 rep movsq
27621 + pax_force_retaddr
27622 ret
27623 CFI_ENDPROC
27624 ENDPROC(copy_page_rep)
27625 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27626
27627 ENTRY(copy_page)
27628 CFI_STARTPROC
27629 - subq $2*8, %rsp
27630 - CFI_ADJUST_CFA_OFFSET 2*8
27631 + subq $3*8, %rsp
27632 + CFI_ADJUST_CFA_OFFSET 3*8
27633 movq %rbx, (%rsp)
27634 CFI_REL_OFFSET rbx, 0
27635 movq %r12, 1*8(%rsp)
27636 CFI_REL_OFFSET r12, 1*8
27637 + movq %r13, 2*8(%rsp)
27638 + CFI_REL_OFFSET r13, 2*8
27639
27640 movl $(4096/64)-5, %ecx
27641 .p2align 4
27642 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27643 movq 0x8*2(%rsi), %rdx
27644 movq 0x8*3(%rsi), %r8
27645 movq 0x8*4(%rsi), %r9
27646 - movq 0x8*5(%rsi), %r10
27647 + movq 0x8*5(%rsi), %r13
27648 movq 0x8*6(%rsi), %r11
27649 movq 0x8*7(%rsi), %r12
27650
27651 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27652 movq %rdx, 0x8*2(%rdi)
27653 movq %r8, 0x8*3(%rdi)
27654 movq %r9, 0x8*4(%rdi)
27655 - movq %r10, 0x8*5(%rdi)
27656 + movq %r13, 0x8*5(%rdi)
27657 movq %r11, 0x8*6(%rdi)
27658 movq %r12, 0x8*7(%rdi)
27659
27660 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27661 movq 0x8*2(%rsi), %rdx
27662 movq 0x8*3(%rsi), %r8
27663 movq 0x8*4(%rsi), %r9
27664 - movq 0x8*5(%rsi), %r10
27665 + movq 0x8*5(%rsi), %r13
27666 movq 0x8*6(%rsi), %r11
27667 movq 0x8*7(%rsi), %r12
27668
27669 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27670 movq %rdx, 0x8*2(%rdi)
27671 movq %r8, 0x8*3(%rdi)
27672 movq %r9, 0x8*4(%rdi)
27673 - movq %r10, 0x8*5(%rdi)
27674 + movq %r13, 0x8*5(%rdi)
27675 movq %r11, 0x8*6(%rdi)
27676 movq %r12, 0x8*7(%rdi)
27677
27678 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27679 CFI_RESTORE rbx
27680 movq 1*8(%rsp), %r12
27681 CFI_RESTORE r12
27682 - addq $2*8, %rsp
27683 - CFI_ADJUST_CFA_OFFSET -2*8
27684 + movq 2*8(%rsp), %r13
27685 + CFI_RESTORE r13
27686 + addq $3*8, %rsp
27687 + CFI_ADJUST_CFA_OFFSET -3*8
27688 + pax_force_retaddr
27689 ret
27690 .Lcopy_page_end:
27691 CFI_ENDPROC
27692 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27693
27694 #include <asm/cpufeature.h>
27695
27696 - .section .altinstr_replacement,"ax"
27697 + .section .altinstr_replacement,"a"
27698 1: .byte 0xeb /* jmp <disp8> */
27699 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27700 2:
27701 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27702 index a30ca15..6b3f4e1 100644
27703 --- a/arch/x86/lib/copy_user_64.S
27704 +++ b/arch/x86/lib/copy_user_64.S
27705 @@ -18,31 +18,7 @@
27706 #include <asm/alternative-asm.h>
27707 #include <asm/asm.h>
27708 #include <asm/smap.h>
27709 -
27710 -/*
27711 - * By placing feature2 after feature1 in altinstructions section, we logically
27712 - * implement:
27713 - * If CPU has feature2, jmp to alt2 is used
27714 - * else if CPU has feature1, jmp to alt1 is used
27715 - * else jmp to orig is used.
27716 - */
27717 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27718 -0:
27719 - .byte 0xe9 /* 32bit jump */
27720 - .long \orig-1f /* by default jump to orig */
27721 -1:
27722 - .section .altinstr_replacement,"ax"
27723 -2: .byte 0xe9 /* near jump with 32bit immediate */
27724 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27725 -3: .byte 0xe9 /* near jump with 32bit immediate */
27726 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27727 - .previous
27728 -
27729 - .section .altinstructions,"a"
27730 - altinstruction_entry 0b,2b,\feature1,5,5
27731 - altinstruction_entry 0b,3b,\feature2,5,5
27732 - .previous
27733 - .endm
27734 +#include <asm/pgtable.h>
27735
27736 .macro ALIGN_DESTINATION
27737 #ifdef FIX_ALIGNMENT
27738 @@ -70,52 +46,6 @@
27739 #endif
27740 .endm
27741
27742 -/* Standard copy_to_user with segment limit checking */
27743 -ENTRY(_copy_to_user)
27744 - CFI_STARTPROC
27745 - GET_THREAD_INFO(%rax)
27746 - movq %rdi,%rcx
27747 - addq %rdx,%rcx
27748 - jc bad_to_user
27749 - cmpq TI_addr_limit(%rax),%rcx
27750 - ja bad_to_user
27751 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27752 - copy_user_generic_unrolled,copy_user_generic_string, \
27753 - copy_user_enhanced_fast_string
27754 - CFI_ENDPROC
27755 -ENDPROC(_copy_to_user)
27756 -
27757 -/* Standard copy_from_user with segment limit checking */
27758 -ENTRY(_copy_from_user)
27759 - CFI_STARTPROC
27760 - GET_THREAD_INFO(%rax)
27761 - movq %rsi,%rcx
27762 - addq %rdx,%rcx
27763 - jc bad_from_user
27764 - cmpq TI_addr_limit(%rax),%rcx
27765 - ja bad_from_user
27766 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27767 - copy_user_generic_unrolled,copy_user_generic_string, \
27768 - copy_user_enhanced_fast_string
27769 - CFI_ENDPROC
27770 -ENDPROC(_copy_from_user)
27771 -
27772 - .section .fixup,"ax"
27773 - /* must zero dest */
27774 -ENTRY(bad_from_user)
27775 -bad_from_user:
27776 - CFI_STARTPROC
27777 - movl %edx,%ecx
27778 - xorl %eax,%eax
27779 - rep
27780 - stosb
27781 -bad_to_user:
27782 - movl %edx,%eax
27783 - ret
27784 - CFI_ENDPROC
27785 -ENDPROC(bad_from_user)
27786 - .previous
27787 -
27788 /*
27789 * copy_user_generic_unrolled - memory copy with exception handling.
27790 * This version is for CPUs like P4 that don't have efficient micro
27791 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27792 */
27793 ENTRY(copy_user_generic_unrolled)
27794 CFI_STARTPROC
27795 + ASM_PAX_OPEN_USERLAND
27796 ASM_STAC
27797 cmpl $8,%edx
27798 jb 20f /* less then 8 bytes, go to byte copy loop */
27799 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27800 jz 17f
27801 1: movq (%rsi),%r8
27802 2: movq 1*8(%rsi),%r9
27803 -3: movq 2*8(%rsi),%r10
27804 +3: movq 2*8(%rsi),%rax
27805 4: movq 3*8(%rsi),%r11
27806 5: movq %r8,(%rdi)
27807 6: movq %r9,1*8(%rdi)
27808 -7: movq %r10,2*8(%rdi)
27809 +7: movq %rax,2*8(%rdi)
27810 8: movq %r11,3*8(%rdi)
27811 9: movq 4*8(%rsi),%r8
27812 10: movq 5*8(%rsi),%r9
27813 -11: movq 6*8(%rsi),%r10
27814 +11: movq 6*8(%rsi),%rax
27815 12: movq 7*8(%rsi),%r11
27816 13: movq %r8,4*8(%rdi)
27817 14: movq %r9,5*8(%rdi)
27818 -15: movq %r10,6*8(%rdi)
27819 +15: movq %rax,6*8(%rdi)
27820 16: movq %r11,7*8(%rdi)
27821 leaq 64(%rsi),%rsi
27822 leaq 64(%rdi),%rdi
27823 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27824 jnz 21b
27825 23: xor %eax,%eax
27826 ASM_CLAC
27827 + ASM_PAX_CLOSE_USERLAND
27828 + pax_force_retaddr
27829 ret
27830
27831 .section .fixup,"ax"
27832 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27833 */
27834 ENTRY(copy_user_generic_string)
27835 CFI_STARTPROC
27836 + ASM_PAX_OPEN_USERLAND
27837 ASM_STAC
27838 andl %edx,%edx
27839 jz 4f
27840 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27841 movsb
27842 4: xorl %eax,%eax
27843 ASM_CLAC
27844 + ASM_PAX_CLOSE_USERLAND
27845 + pax_force_retaddr
27846 ret
27847
27848 .section .fixup,"ax"
27849 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27850 */
27851 ENTRY(copy_user_enhanced_fast_string)
27852 CFI_STARTPROC
27853 + ASM_PAX_OPEN_USERLAND
27854 ASM_STAC
27855 andl %edx,%edx
27856 jz 2f
27857 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27858 movsb
27859 2: xorl %eax,%eax
27860 ASM_CLAC
27861 + ASM_PAX_CLOSE_USERLAND
27862 + pax_force_retaddr
27863 ret
27864
27865 .section .fixup,"ax"
27866 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27867 index 6a4f43c..55d26f2 100644
27868 --- a/arch/x86/lib/copy_user_nocache_64.S
27869 +++ b/arch/x86/lib/copy_user_nocache_64.S
27870 @@ -8,6 +8,7 @@
27871
27872 #include <linux/linkage.h>
27873 #include <asm/dwarf2.h>
27874 +#include <asm/alternative-asm.h>
27875
27876 #define FIX_ALIGNMENT 1
27877
27878 @@ -16,6 +17,7 @@
27879 #include <asm/thread_info.h>
27880 #include <asm/asm.h>
27881 #include <asm/smap.h>
27882 +#include <asm/pgtable.h>
27883
27884 .macro ALIGN_DESTINATION
27885 #ifdef FIX_ALIGNMENT
27886 @@ -49,6 +51,16 @@
27887 */
27888 ENTRY(__copy_user_nocache)
27889 CFI_STARTPROC
27890 +
27891 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27892 + mov pax_user_shadow_base,%rcx
27893 + cmp %rcx,%rsi
27894 + jae 1f
27895 + add %rcx,%rsi
27896 +1:
27897 +#endif
27898 +
27899 + ASM_PAX_OPEN_USERLAND
27900 ASM_STAC
27901 cmpl $8,%edx
27902 jb 20f /* less then 8 bytes, go to byte copy loop */
27903 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27904 jz 17f
27905 1: movq (%rsi),%r8
27906 2: movq 1*8(%rsi),%r9
27907 -3: movq 2*8(%rsi),%r10
27908 +3: movq 2*8(%rsi),%rax
27909 4: movq 3*8(%rsi),%r11
27910 5: movnti %r8,(%rdi)
27911 6: movnti %r9,1*8(%rdi)
27912 -7: movnti %r10,2*8(%rdi)
27913 +7: movnti %rax,2*8(%rdi)
27914 8: movnti %r11,3*8(%rdi)
27915 9: movq 4*8(%rsi),%r8
27916 10: movq 5*8(%rsi),%r9
27917 -11: movq 6*8(%rsi),%r10
27918 +11: movq 6*8(%rsi),%rax
27919 12: movq 7*8(%rsi),%r11
27920 13: movnti %r8,4*8(%rdi)
27921 14: movnti %r9,5*8(%rdi)
27922 -15: movnti %r10,6*8(%rdi)
27923 +15: movnti %rax,6*8(%rdi)
27924 16: movnti %r11,7*8(%rdi)
27925 leaq 64(%rsi),%rsi
27926 leaq 64(%rdi),%rdi
27927 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27928 jnz 21b
27929 23: xorl %eax,%eax
27930 ASM_CLAC
27931 + ASM_PAX_CLOSE_USERLAND
27932 sfence
27933 + pax_force_retaddr
27934 ret
27935
27936 .section .fixup,"ax"
27937 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27938 index 2419d5f..953ee51 100644
27939 --- a/arch/x86/lib/csum-copy_64.S
27940 +++ b/arch/x86/lib/csum-copy_64.S
27941 @@ -9,6 +9,7 @@
27942 #include <asm/dwarf2.h>
27943 #include <asm/errno.h>
27944 #include <asm/asm.h>
27945 +#include <asm/alternative-asm.h>
27946
27947 /*
27948 * Checksum copy with exception handling.
27949 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27950 CFI_RESTORE rbp
27951 addq $7*8, %rsp
27952 CFI_ADJUST_CFA_OFFSET -7*8
27953 + pax_force_retaddr 0, 1
27954 ret
27955 CFI_RESTORE_STATE
27956
27957 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27958 index 7609e0e..b449b98 100644
27959 --- a/arch/x86/lib/csum-wrappers_64.c
27960 +++ b/arch/x86/lib/csum-wrappers_64.c
27961 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27962 len -= 2;
27963 }
27964 }
27965 + pax_open_userland();
27966 stac();
27967 - isum = csum_partial_copy_generic((__force const void *)src,
27968 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27969 dst, len, isum, errp, NULL);
27970 clac();
27971 + pax_close_userland();
27972 if (unlikely(*errp))
27973 goto out_err;
27974
27975 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27976 }
27977
27978 *errp = 0;
27979 + pax_open_userland();
27980 stac();
27981 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27982 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27983 len, isum, NULL, errp);
27984 clac();
27985 + pax_close_userland();
27986 return ret;
27987 }
27988 EXPORT_SYMBOL(csum_partial_copy_to_user);
27989 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27990 index a451235..1daa956 100644
27991 --- a/arch/x86/lib/getuser.S
27992 +++ b/arch/x86/lib/getuser.S
27993 @@ -33,17 +33,40 @@
27994 #include <asm/thread_info.h>
27995 #include <asm/asm.h>
27996 #include <asm/smap.h>
27997 +#include <asm/segment.h>
27998 +#include <asm/pgtable.h>
27999 +#include <asm/alternative-asm.h>
28000 +
28001 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28002 +#define __copyuser_seg gs;
28003 +#else
28004 +#define __copyuser_seg
28005 +#endif
28006
28007 .text
28008 ENTRY(__get_user_1)
28009 CFI_STARTPROC
28010 +
28011 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28012 GET_THREAD_INFO(%_ASM_DX)
28013 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28014 jae bad_get_user
28015 ASM_STAC
28016 -1: movzbl (%_ASM_AX),%edx
28017 +
28018 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28019 + mov pax_user_shadow_base,%_ASM_DX
28020 + cmp %_ASM_DX,%_ASM_AX
28021 + jae 1234f
28022 + add %_ASM_DX,%_ASM_AX
28023 +1234:
28024 +#endif
28025 +
28026 +#endif
28027 +
28028 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28029 xor %eax,%eax
28030 ASM_CLAC
28031 + pax_force_retaddr
28032 ret
28033 CFI_ENDPROC
28034 ENDPROC(__get_user_1)
28035 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28036 ENTRY(__get_user_2)
28037 CFI_STARTPROC
28038 add $1,%_ASM_AX
28039 +
28040 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28041 jc bad_get_user
28042 GET_THREAD_INFO(%_ASM_DX)
28043 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28044 jae bad_get_user
28045 ASM_STAC
28046 -2: movzwl -1(%_ASM_AX),%edx
28047 +
28048 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28049 + mov pax_user_shadow_base,%_ASM_DX
28050 + cmp %_ASM_DX,%_ASM_AX
28051 + jae 1234f
28052 + add %_ASM_DX,%_ASM_AX
28053 +1234:
28054 +#endif
28055 +
28056 +#endif
28057 +
28058 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28059 xor %eax,%eax
28060 ASM_CLAC
28061 + pax_force_retaddr
28062 ret
28063 CFI_ENDPROC
28064 ENDPROC(__get_user_2)
28065 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28066 ENTRY(__get_user_4)
28067 CFI_STARTPROC
28068 add $3,%_ASM_AX
28069 +
28070 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28071 jc bad_get_user
28072 GET_THREAD_INFO(%_ASM_DX)
28073 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28074 jae bad_get_user
28075 ASM_STAC
28076 -3: movl -3(%_ASM_AX),%edx
28077 +
28078 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28079 + mov pax_user_shadow_base,%_ASM_DX
28080 + cmp %_ASM_DX,%_ASM_AX
28081 + jae 1234f
28082 + add %_ASM_DX,%_ASM_AX
28083 +1234:
28084 +#endif
28085 +
28086 +#endif
28087 +
28088 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28089 xor %eax,%eax
28090 ASM_CLAC
28091 + pax_force_retaddr
28092 ret
28093 CFI_ENDPROC
28094 ENDPROC(__get_user_4)
28095 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28096 GET_THREAD_INFO(%_ASM_DX)
28097 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28098 jae bad_get_user
28099 +
28100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28101 + mov pax_user_shadow_base,%_ASM_DX
28102 + cmp %_ASM_DX,%_ASM_AX
28103 + jae 1234f
28104 + add %_ASM_DX,%_ASM_AX
28105 +1234:
28106 +#endif
28107 +
28108 ASM_STAC
28109 4: movq -7(%_ASM_AX),%rdx
28110 xor %eax,%eax
28111 ASM_CLAC
28112 + pax_force_retaddr
28113 ret
28114 #else
28115 add $7,%_ASM_AX
28116 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28117 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28118 jae bad_get_user_8
28119 ASM_STAC
28120 -4: movl -7(%_ASM_AX),%edx
28121 -5: movl -3(%_ASM_AX),%ecx
28122 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28123 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28124 xor %eax,%eax
28125 ASM_CLAC
28126 + pax_force_retaddr
28127 ret
28128 #endif
28129 CFI_ENDPROC
28130 @@ -113,6 +175,7 @@ bad_get_user:
28131 xor %edx,%edx
28132 mov $(-EFAULT),%_ASM_AX
28133 ASM_CLAC
28134 + pax_force_retaddr
28135 ret
28136 CFI_ENDPROC
28137 END(bad_get_user)
28138 @@ -124,6 +187,7 @@ bad_get_user_8:
28139 xor %ecx,%ecx
28140 mov $(-EFAULT),%_ASM_AX
28141 ASM_CLAC
28142 + pax_force_retaddr
28143 ret
28144 CFI_ENDPROC
28145 END(bad_get_user_8)
28146 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28147 index 54fcffe..7be149e 100644
28148 --- a/arch/x86/lib/insn.c
28149 +++ b/arch/x86/lib/insn.c
28150 @@ -20,8 +20,10 @@
28151
28152 #ifdef __KERNEL__
28153 #include <linux/string.h>
28154 +#include <asm/pgtable_types.h>
28155 #else
28156 #include <string.h>
28157 +#define ktla_ktva(addr) addr
28158 #endif
28159 #include <asm/inat.h>
28160 #include <asm/insn.h>
28161 @@ -53,8 +55,8 @@
28162 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28163 {
28164 memset(insn, 0, sizeof(*insn));
28165 - insn->kaddr = kaddr;
28166 - insn->next_byte = kaddr;
28167 + insn->kaddr = ktla_ktva(kaddr);
28168 + insn->next_byte = ktla_ktva(kaddr);
28169 insn->x86_64 = x86_64 ? 1 : 0;
28170 insn->opnd_bytes = 4;
28171 if (x86_64)
28172 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28173 index 05a95e7..326f2fa 100644
28174 --- a/arch/x86/lib/iomap_copy_64.S
28175 +++ b/arch/x86/lib/iomap_copy_64.S
28176 @@ -17,6 +17,7 @@
28177
28178 #include <linux/linkage.h>
28179 #include <asm/dwarf2.h>
28180 +#include <asm/alternative-asm.h>
28181
28182 /*
28183 * override generic version in lib/iomap_copy.c
28184 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28185 CFI_STARTPROC
28186 movl %edx,%ecx
28187 rep movsd
28188 + pax_force_retaddr
28189 ret
28190 CFI_ENDPROC
28191 ENDPROC(__iowrite32_copy)
28192 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28193 index 56313a3..9b59269 100644
28194 --- a/arch/x86/lib/memcpy_64.S
28195 +++ b/arch/x86/lib/memcpy_64.S
28196 @@ -24,7 +24,7 @@
28197 * This gets patched over the unrolled variant (below) via the
28198 * alternative instructions framework:
28199 */
28200 - .section .altinstr_replacement, "ax", @progbits
28201 + .section .altinstr_replacement, "a", @progbits
28202 .Lmemcpy_c:
28203 movq %rdi, %rax
28204 movq %rdx, %rcx
28205 @@ -33,6 +33,7 @@
28206 rep movsq
28207 movl %edx, %ecx
28208 rep movsb
28209 + pax_force_retaddr
28210 ret
28211 .Lmemcpy_e:
28212 .previous
28213 @@ -44,11 +45,12 @@
28214 * This gets patched over the unrolled variant (below) via the
28215 * alternative instructions framework:
28216 */
28217 - .section .altinstr_replacement, "ax", @progbits
28218 + .section .altinstr_replacement, "a", @progbits
28219 .Lmemcpy_c_e:
28220 movq %rdi, %rax
28221 movq %rdx, %rcx
28222 rep movsb
28223 + pax_force_retaddr
28224 ret
28225 .Lmemcpy_e_e:
28226 .previous
28227 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28228 */
28229 movq 0*8(%rsi), %r8
28230 movq 1*8(%rsi), %r9
28231 - movq 2*8(%rsi), %r10
28232 + movq 2*8(%rsi), %rcx
28233 movq 3*8(%rsi), %r11
28234 leaq 4*8(%rsi), %rsi
28235
28236 movq %r8, 0*8(%rdi)
28237 movq %r9, 1*8(%rdi)
28238 - movq %r10, 2*8(%rdi)
28239 + movq %rcx, 2*8(%rdi)
28240 movq %r11, 3*8(%rdi)
28241 leaq 4*8(%rdi), %rdi
28242 jae .Lcopy_forward_loop
28243 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28244 subq $0x20, %rdx
28245 movq -1*8(%rsi), %r8
28246 movq -2*8(%rsi), %r9
28247 - movq -3*8(%rsi), %r10
28248 + movq -3*8(%rsi), %rcx
28249 movq -4*8(%rsi), %r11
28250 leaq -4*8(%rsi), %rsi
28251 movq %r8, -1*8(%rdi)
28252 movq %r9, -2*8(%rdi)
28253 - movq %r10, -3*8(%rdi)
28254 + movq %rcx, -3*8(%rdi)
28255 movq %r11, -4*8(%rdi)
28256 leaq -4*8(%rdi), %rdi
28257 jae .Lcopy_backward_loop
28258 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28259 */
28260 movq 0*8(%rsi), %r8
28261 movq 1*8(%rsi), %r9
28262 - movq -2*8(%rsi, %rdx), %r10
28263 + movq -2*8(%rsi, %rdx), %rcx
28264 movq -1*8(%rsi, %rdx), %r11
28265 movq %r8, 0*8(%rdi)
28266 movq %r9, 1*8(%rdi)
28267 - movq %r10, -2*8(%rdi, %rdx)
28268 + movq %rcx, -2*8(%rdi, %rdx)
28269 movq %r11, -1*8(%rdi, %rdx)
28270 + pax_force_retaddr
28271 retq
28272 .p2align 4
28273 .Lless_16bytes:
28274 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28275 movq -1*8(%rsi, %rdx), %r9
28276 movq %r8, 0*8(%rdi)
28277 movq %r9, -1*8(%rdi, %rdx)
28278 + pax_force_retaddr
28279 retq
28280 .p2align 4
28281 .Lless_8bytes:
28282 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28283 movl -4(%rsi, %rdx), %r8d
28284 movl %ecx, (%rdi)
28285 movl %r8d, -4(%rdi, %rdx)
28286 + pax_force_retaddr
28287 retq
28288 .p2align 4
28289 .Lless_3bytes:
28290 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28291 movb %cl, (%rdi)
28292
28293 .Lend:
28294 + pax_force_retaddr
28295 retq
28296 CFI_ENDPROC
28297 ENDPROC(memcpy)
28298 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28299 index 65268a6..5aa7815 100644
28300 --- a/arch/x86/lib/memmove_64.S
28301 +++ b/arch/x86/lib/memmove_64.S
28302 @@ -61,13 +61,13 @@ ENTRY(memmove)
28303 5:
28304 sub $0x20, %rdx
28305 movq 0*8(%rsi), %r11
28306 - movq 1*8(%rsi), %r10
28307 + movq 1*8(%rsi), %rcx
28308 movq 2*8(%rsi), %r9
28309 movq 3*8(%rsi), %r8
28310 leaq 4*8(%rsi), %rsi
28311
28312 movq %r11, 0*8(%rdi)
28313 - movq %r10, 1*8(%rdi)
28314 + movq %rcx, 1*8(%rdi)
28315 movq %r9, 2*8(%rdi)
28316 movq %r8, 3*8(%rdi)
28317 leaq 4*8(%rdi), %rdi
28318 @@ -81,10 +81,10 @@ ENTRY(memmove)
28319 4:
28320 movq %rdx, %rcx
28321 movq -8(%rsi, %rdx), %r11
28322 - lea -8(%rdi, %rdx), %r10
28323 + lea -8(%rdi, %rdx), %r9
28324 shrq $3, %rcx
28325 rep movsq
28326 - movq %r11, (%r10)
28327 + movq %r11, (%r9)
28328 jmp 13f
28329 .Lmemmove_end_forward:
28330
28331 @@ -95,14 +95,14 @@ ENTRY(memmove)
28332 7:
28333 movq %rdx, %rcx
28334 movq (%rsi), %r11
28335 - movq %rdi, %r10
28336 + movq %rdi, %r9
28337 leaq -8(%rsi, %rdx), %rsi
28338 leaq -8(%rdi, %rdx), %rdi
28339 shrq $3, %rcx
28340 std
28341 rep movsq
28342 cld
28343 - movq %r11, (%r10)
28344 + movq %r11, (%r9)
28345 jmp 13f
28346
28347 /*
28348 @@ -127,13 +127,13 @@ ENTRY(memmove)
28349 8:
28350 subq $0x20, %rdx
28351 movq -1*8(%rsi), %r11
28352 - movq -2*8(%rsi), %r10
28353 + movq -2*8(%rsi), %rcx
28354 movq -3*8(%rsi), %r9
28355 movq -4*8(%rsi), %r8
28356 leaq -4*8(%rsi), %rsi
28357
28358 movq %r11, -1*8(%rdi)
28359 - movq %r10, -2*8(%rdi)
28360 + movq %rcx, -2*8(%rdi)
28361 movq %r9, -3*8(%rdi)
28362 movq %r8, -4*8(%rdi)
28363 leaq -4*8(%rdi), %rdi
28364 @@ -151,11 +151,11 @@ ENTRY(memmove)
28365 * Move data from 16 bytes to 31 bytes.
28366 */
28367 movq 0*8(%rsi), %r11
28368 - movq 1*8(%rsi), %r10
28369 + movq 1*8(%rsi), %rcx
28370 movq -2*8(%rsi, %rdx), %r9
28371 movq -1*8(%rsi, %rdx), %r8
28372 movq %r11, 0*8(%rdi)
28373 - movq %r10, 1*8(%rdi)
28374 + movq %rcx, 1*8(%rdi)
28375 movq %r9, -2*8(%rdi, %rdx)
28376 movq %r8, -1*8(%rdi, %rdx)
28377 jmp 13f
28378 @@ -167,9 +167,9 @@ ENTRY(memmove)
28379 * Move data from 8 bytes to 15 bytes.
28380 */
28381 movq 0*8(%rsi), %r11
28382 - movq -1*8(%rsi, %rdx), %r10
28383 + movq -1*8(%rsi, %rdx), %r9
28384 movq %r11, 0*8(%rdi)
28385 - movq %r10, -1*8(%rdi, %rdx)
28386 + movq %r9, -1*8(%rdi, %rdx)
28387 jmp 13f
28388 10:
28389 cmpq $4, %rdx
28390 @@ -178,9 +178,9 @@ ENTRY(memmove)
28391 * Move data from 4 bytes to 7 bytes.
28392 */
28393 movl (%rsi), %r11d
28394 - movl -4(%rsi, %rdx), %r10d
28395 + movl -4(%rsi, %rdx), %r9d
28396 movl %r11d, (%rdi)
28397 - movl %r10d, -4(%rdi, %rdx)
28398 + movl %r9d, -4(%rdi, %rdx)
28399 jmp 13f
28400 11:
28401 cmp $2, %rdx
28402 @@ -189,9 +189,9 @@ ENTRY(memmove)
28403 * Move data from 2 bytes to 3 bytes.
28404 */
28405 movw (%rsi), %r11w
28406 - movw -2(%rsi, %rdx), %r10w
28407 + movw -2(%rsi, %rdx), %r9w
28408 movw %r11w, (%rdi)
28409 - movw %r10w, -2(%rdi, %rdx)
28410 + movw %r9w, -2(%rdi, %rdx)
28411 jmp 13f
28412 12:
28413 cmp $1, %rdx
28414 @@ -202,14 +202,16 @@ ENTRY(memmove)
28415 movb (%rsi), %r11b
28416 movb %r11b, (%rdi)
28417 13:
28418 + pax_force_retaddr
28419 retq
28420 CFI_ENDPROC
28421
28422 - .section .altinstr_replacement,"ax"
28423 + .section .altinstr_replacement,"a"
28424 .Lmemmove_begin_forward_efs:
28425 /* Forward moving data. */
28426 movq %rdx, %rcx
28427 rep movsb
28428 + pax_force_retaddr
28429 retq
28430 .Lmemmove_end_forward_efs:
28431 .previous
28432 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28433 index 2dcb380..50a78bc 100644
28434 --- a/arch/x86/lib/memset_64.S
28435 +++ b/arch/x86/lib/memset_64.S
28436 @@ -16,7 +16,7 @@
28437 *
28438 * rax original destination
28439 */
28440 - .section .altinstr_replacement, "ax", @progbits
28441 + .section .altinstr_replacement, "a", @progbits
28442 .Lmemset_c:
28443 movq %rdi,%r9
28444 movq %rdx,%rcx
28445 @@ -30,6 +30,7 @@
28446 movl %edx,%ecx
28447 rep stosb
28448 movq %r9,%rax
28449 + pax_force_retaddr
28450 ret
28451 .Lmemset_e:
28452 .previous
28453 @@ -45,13 +46,14 @@
28454 *
28455 * rax original destination
28456 */
28457 - .section .altinstr_replacement, "ax", @progbits
28458 + .section .altinstr_replacement, "a", @progbits
28459 .Lmemset_c_e:
28460 movq %rdi,%r9
28461 movb %sil,%al
28462 movq %rdx,%rcx
28463 rep stosb
28464 movq %r9,%rax
28465 + pax_force_retaddr
28466 ret
28467 .Lmemset_e_e:
28468 .previous
28469 @@ -59,7 +61,7 @@
28470 ENTRY(memset)
28471 ENTRY(__memset)
28472 CFI_STARTPROC
28473 - movq %rdi,%r10
28474 + movq %rdi,%r11
28475
28476 /* expand byte value */
28477 movzbl %sil,%ecx
28478 @@ -117,7 +119,8 @@ ENTRY(__memset)
28479 jnz .Lloop_1
28480
28481 .Lende:
28482 - movq %r10,%rax
28483 + movq %r11,%rax
28484 + pax_force_retaddr
28485 ret
28486
28487 CFI_RESTORE_STATE
28488 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28489 index c9f2d9b..e7fd2c0 100644
28490 --- a/arch/x86/lib/mmx_32.c
28491 +++ b/arch/x86/lib/mmx_32.c
28492 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28493 {
28494 void *p;
28495 int i;
28496 + unsigned long cr0;
28497
28498 if (unlikely(in_interrupt()))
28499 return __memcpy(to, from, len);
28500 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28501 kernel_fpu_begin();
28502
28503 __asm__ __volatile__ (
28504 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28505 - " prefetch 64(%0)\n"
28506 - " prefetch 128(%0)\n"
28507 - " prefetch 192(%0)\n"
28508 - " prefetch 256(%0)\n"
28509 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28510 + " prefetch 64(%1)\n"
28511 + " prefetch 128(%1)\n"
28512 + " prefetch 192(%1)\n"
28513 + " prefetch 256(%1)\n"
28514 "2: \n"
28515 ".section .fixup, \"ax\"\n"
28516 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28517 + "3: \n"
28518 +
28519 +#ifdef CONFIG_PAX_KERNEXEC
28520 + " movl %%cr0, %0\n"
28521 + " movl %0, %%eax\n"
28522 + " andl $0xFFFEFFFF, %%eax\n"
28523 + " movl %%eax, %%cr0\n"
28524 +#endif
28525 +
28526 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28527 +
28528 +#ifdef CONFIG_PAX_KERNEXEC
28529 + " movl %0, %%cr0\n"
28530 +#endif
28531 +
28532 " jmp 2b\n"
28533 ".previous\n"
28534 _ASM_EXTABLE(1b, 3b)
28535 - : : "r" (from));
28536 + : "=&r" (cr0) : "r" (from) : "ax");
28537
28538 for ( ; i > 5; i--) {
28539 __asm__ __volatile__ (
28540 - "1: prefetch 320(%0)\n"
28541 - "2: movq (%0), %%mm0\n"
28542 - " movq 8(%0), %%mm1\n"
28543 - " movq 16(%0), %%mm2\n"
28544 - " movq 24(%0), %%mm3\n"
28545 - " movq %%mm0, (%1)\n"
28546 - " movq %%mm1, 8(%1)\n"
28547 - " movq %%mm2, 16(%1)\n"
28548 - " movq %%mm3, 24(%1)\n"
28549 - " movq 32(%0), %%mm0\n"
28550 - " movq 40(%0), %%mm1\n"
28551 - " movq 48(%0), %%mm2\n"
28552 - " movq 56(%0), %%mm3\n"
28553 - " movq %%mm0, 32(%1)\n"
28554 - " movq %%mm1, 40(%1)\n"
28555 - " movq %%mm2, 48(%1)\n"
28556 - " movq %%mm3, 56(%1)\n"
28557 + "1: prefetch 320(%1)\n"
28558 + "2: movq (%1), %%mm0\n"
28559 + " movq 8(%1), %%mm1\n"
28560 + " movq 16(%1), %%mm2\n"
28561 + " movq 24(%1), %%mm3\n"
28562 + " movq %%mm0, (%2)\n"
28563 + " movq %%mm1, 8(%2)\n"
28564 + " movq %%mm2, 16(%2)\n"
28565 + " movq %%mm3, 24(%2)\n"
28566 + " movq 32(%1), %%mm0\n"
28567 + " movq 40(%1), %%mm1\n"
28568 + " movq 48(%1), %%mm2\n"
28569 + " movq 56(%1), %%mm3\n"
28570 + " movq %%mm0, 32(%2)\n"
28571 + " movq %%mm1, 40(%2)\n"
28572 + " movq %%mm2, 48(%2)\n"
28573 + " movq %%mm3, 56(%2)\n"
28574 ".section .fixup, \"ax\"\n"
28575 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28576 + "3:\n"
28577 +
28578 +#ifdef CONFIG_PAX_KERNEXEC
28579 + " movl %%cr0, %0\n"
28580 + " movl %0, %%eax\n"
28581 + " andl $0xFFFEFFFF, %%eax\n"
28582 + " movl %%eax, %%cr0\n"
28583 +#endif
28584 +
28585 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28586 +
28587 +#ifdef CONFIG_PAX_KERNEXEC
28588 + " movl %0, %%cr0\n"
28589 +#endif
28590 +
28591 " jmp 2b\n"
28592 ".previous\n"
28593 _ASM_EXTABLE(1b, 3b)
28594 - : : "r" (from), "r" (to) : "memory");
28595 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28596
28597 from += 64;
28598 to += 64;
28599 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28600 static void fast_copy_page(void *to, void *from)
28601 {
28602 int i;
28603 + unsigned long cr0;
28604
28605 kernel_fpu_begin();
28606
28607 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28608 * but that is for later. -AV
28609 */
28610 __asm__ __volatile__(
28611 - "1: prefetch (%0)\n"
28612 - " prefetch 64(%0)\n"
28613 - " prefetch 128(%0)\n"
28614 - " prefetch 192(%0)\n"
28615 - " prefetch 256(%0)\n"
28616 + "1: prefetch (%1)\n"
28617 + " prefetch 64(%1)\n"
28618 + " prefetch 128(%1)\n"
28619 + " prefetch 192(%1)\n"
28620 + " prefetch 256(%1)\n"
28621 "2: \n"
28622 ".section .fixup, \"ax\"\n"
28623 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28624 + "3: \n"
28625 +
28626 +#ifdef CONFIG_PAX_KERNEXEC
28627 + " movl %%cr0, %0\n"
28628 + " movl %0, %%eax\n"
28629 + " andl $0xFFFEFFFF, %%eax\n"
28630 + " movl %%eax, %%cr0\n"
28631 +#endif
28632 +
28633 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28634 +
28635 +#ifdef CONFIG_PAX_KERNEXEC
28636 + " movl %0, %%cr0\n"
28637 +#endif
28638 +
28639 " jmp 2b\n"
28640 ".previous\n"
28641 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28642 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28643
28644 for (i = 0; i < (4096-320)/64; i++) {
28645 __asm__ __volatile__ (
28646 - "1: prefetch 320(%0)\n"
28647 - "2: movq (%0), %%mm0\n"
28648 - " movntq %%mm0, (%1)\n"
28649 - " movq 8(%0), %%mm1\n"
28650 - " movntq %%mm1, 8(%1)\n"
28651 - " movq 16(%0), %%mm2\n"
28652 - " movntq %%mm2, 16(%1)\n"
28653 - " movq 24(%0), %%mm3\n"
28654 - " movntq %%mm3, 24(%1)\n"
28655 - " movq 32(%0), %%mm4\n"
28656 - " movntq %%mm4, 32(%1)\n"
28657 - " movq 40(%0), %%mm5\n"
28658 - " movntq %%mm5, 40(%1)\n"
28659 - " movq 48(%0), %%mm6\n"
28660 - " movntq %%mm6, 48(%1)\n"
28661 - " movq 56(%0), %%mm7\n"
28662 - " movntq %%mm7, 56(%1)\n"
28663 + "1: prefetch 320(%1)\n"
28664 + "2: movq (%1), %%mm0\n"
28665 + " movntq %%mm0, (%2)\n"
28666 + " movq 8(%1), %%mm1\n"
28667 + " movntq %%mm1, 8(%2)\n"
28668 + " movq 16(%1), %%mm2\n"
28669 + " movntq %%mm2, 16(%2)\n"
28670 + " movq 24(%1), %%mm3\n"
28671 + " movntq %%mm3, 24(%2)\n"
28672 + " movq 32(%1), %%mm4\n"
28673 + " movntq %%mm4, 32(%2)\n"
28674 + " movq 40(%1), %%mm5\n"
28675 + " movntq %%mm5, 40(%2)\n"
28676 + " movq 48(%1), %%mm6\n"
28677 + " movntq %%mm6, 48(%2)\n"
28678 + " movq 56(%1), %%mm7\n"
28679 + " movntq %%mm7, 56(%2)\n"
28680 ".section .fixup, \"ax\"\n"
28681 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28682 + "3:\n"
28683 +
28684 +#ifdef CONFIG_PAX_KERNEXEC
28685 + " movl %%cr0, %0\n"
28686 + " movl %0, %%eax\n"
28687 + " andl $0xFFFEFFFF, %%eax\n"
28688 + " movl %%eax, %%cr0\n"
28689 +#endif
28690 +
28691 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28692 +
28693 +#ifdef CONFIG_PAX_KERNEXEC
28694 + " movl %0, %%cr0\n"
28695 +#endif
28696 +
28697 " jmp 2b\n"
28698 ".previous\n"
28699 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28700 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28701
28702 from += 64;
28703 to += 64;
28704 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28705 static void fast_copy_page(void *to, void *from)
28706 {
28707 int i;
28708 + unsigned long cr0;
28709
28710 kernel_fpu_begin();
28711
28712 __asm__ __volatile__ (
28713 - "1: prefetch (%0)\n"
28714 - " prefetch 64(%0)\n"
28715 - " prefetch 128(%0)\n"
28716 - " prefetch 192(%0)\n"
28717 - " prefetch 256(%0)\n"
28718 + "1: prefetch (%1)\n"
28719 + " prefetch 64(%1)\n"
28720 + " prefetch 128(%1)\n"
28721 + " prefetch 192(%1)\n"
28722 + " prefetch 256(%1)\n"
28723 "2: \n"
28724 ".section .fixup, \"ax\"\n"
28725 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28726 + "3: \n"
28727 +
28728 +#ifdef CONFIG_PAX_KERNEXEC
28729 + " movl %%cr0, %0\n"
28730 + " movl %0, %%eax\n"
28731 + " andl $0xFFFEFFFF, %%eax\n"
28732 + " movl %%eax, %%cr0\n"
28733 +#endif
28734 +
28735 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28736 +
28737 +#ifdef CONFIG_PAX_KERNEXEC
28738 + " movl %0, %%cr0\n"
28739 +#endif
28740 +
28741 " jmp 2b\n"
28742 ".previous\n"
28743 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28744 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28745
28746 for (i = 0; i < 4096/64; i++) {
28747 __asm__ __volatile__ (
28748 - "1: prefetch 320(%0)\n"
28749 - "2: movq (%0), %%mm0\n"
28750 - " movq 8(%0), %%mm1\n"
28751 - " movq 16(%0), %%mm2\n"
28752 - " movq 24(%0), %%mm3\n"
28753 - " movq %%mm0, (%1)\n"
28754 - " movq %%mm1, 8(%1)\n"
28755 - " movq %%mm2, 16(%1)\n"
28756 - " movq %%mm3, 24(%1)\n"
28757 - " movq 32(%0), %%mm0\n"
28758 - " movq 40(%0), %%mm1\n"
28759 - " movq 48(%0), %%mm2\n"
28760 - " movq 56(%0), %%mm3\n"
28761 - " movq %%mm0, 32(%1)\n"
28762 - " movq %%mm1, 40(%1)\n"
28763 - " movq %%mm2, 48(%1)\n"
28764 - " movq %%mm3, 56(%1)\n"
28765 + "1: prefetch 320(%1)\n"
28766 + "2: movq (%1), %%mm0\n"
28767 + " movq 8(%1), %%mm1\n"
28768 + " movq 16(%1), %%mm2\n"
28769 + " movq 24(%1), %%mm3\n"
28770 + " movq %%mm0, (%2)\n"
28771 + " movq %%mm1, 8(%2)\n"
28772 + " movq %%mm2, 16(%2)\n"
28773 + " movq %%mm3, 24(%2)\n"
28774 + " movq 32(%1), %%mm0\n"
28775 + " movq 40(%1), %%mm1\n"
28776 + " movq 48(%1), %%mm2\n"
28777 + " movq 56(%1), %%mm3\n"
28778 + " movq %%mm0, 32(%2)\n"
28779 + " movq %%mm1, 40(%2)\n"
28780 + " movq %%mm2, 48(%2)\n"
28781 + " movq %%mm3, 56(%2)\n"
28782 ".section .fixup, \"ax\"\n"
28783 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28784 + "3:\n"
28785 +
28786 +#ifdef CONFIG_PAX_KERNEXEC
28787 + " movl %%cr0, %0\n"
28788 + " movl %0, %%eax\n"
28789 + " andl $0xFFFEFFFF, %%eax\n"
28790 + " movl %%eax, %%cr0\n"
28791 +#endif
28792 +
28793 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28794 +
28795 +#ifdef CONFIG_PAX_KERNEXEC
28796 + " movl %0, %%cr0\n"
28797 +#endif
28798 +
28799 " jmp 2b\n"
28800 ".previous\n"
28801 _ASM_EXTABLE(1b, 3b)
28802 - : : "r" (from), "r" (to) : "memory");
28803 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28804
28805 from += 64;
28806 to += 64;
28807 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28808 index f6d13ee..aca5f0b 100644
28809 --- a/arch/x86/lib/msr-reg.S
28810 +++ b/arch/x86/lib/msr-reg.S
28811 @@ -3,6 +3,7 @@
28812 #include <asm/dwarf2.h>
28813 #include <asm/asm.h>
28814 #include <asm/msr.h>
28815 +#include <asm/alternative-asm.h>
28816
28817 #ifdef CONFIG_X86_64
28818 /*
28819 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28820 CFI_STARTPROC
28821 pushq_cfi %rbx
28822 pushq_cfi %rbp
28823 - movq %rdi, %r10 /* Save pointer */
28824 + movq %rdi, %r9 /* Save pointer */
28825 xorl %r11d, %r11d /* Return value */
28826 movl (%rdi), %eax
28827 movl 4(%rdi), %ecx
28828 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28829 movl 28(%rdi), %edi
28830 CFI_REMEMBER_STATE
28831 1: \op
28832 -2: movl %eax, (%r10)
28833 +2: movl %eax, (%r9)
28834 movl %r11d, %eax /* Return value */
28835 - movl %ecx, 4(%r10)
28836 - movl %edx, 8(%r10)
28837 - movl %ebx, 12(%r10)
28838 - movl %ebp, 20(%r10)
28839 - movl %esi, 24(%r10)
28840 - movl %edi, 28(%r10)
28841 + movl %ecx, 4(%r9)
28842 + movl %edx, 8(%r9)
28843 + movl %ebx, 12(%r9)
28844 + movl %ebp, 20(%r9)
28845 + movl %esi, 24(%r9)
28846 + movl %edi, 28(%r9)
28847 popq_cfi %rbp
28848 popq_cfi %rbx
28849 + pax_force_retaddr
28850 ret
28851 3:
28852 CFI_RESTORE_STATE
28853 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28854 index fc6ba17..d4d989d 100644
28855 --- a/arch/x86/lib/putuser.S
28856 +++ b/arch/x86/lib/putuser.S
28857 @@ -16,7 +16,9 @@
28858 #include <asm/errno.h>
28859 #include <asm/asm.h>
28860 #include <asm/smap.h>
28861 -
28862 +#include <asm/segment.h>
28863 +#include <asm/pgtable.h>
28864 +#include <asm/alternative-asm.h>
28865
28866 /*
28867 * __put_user_X
28868 @@ -30,57 +32,125 @@
28869 * as they get called from within inline assembly.
28870 */
28871
28872 -#define ENTER CFI_STARTPROC ; \
28873 - GET_THREAD_INFO(%_ASM_BX)
28874 -#define EXIT ASM_CLAC ; \
28875 - ret ; \
28876 +#define ENTER CFI_STARTPROC
28877 +#define EXIT ASM_CLAC ; \
28878 + pax_force_retaddr ; \
28879 + ret ; \
28880 CFI_ENDPROC
28881
28882 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28883 +#define _DEST %_ASM_CX,%_ASM_BX
28884 +#else
28885 +#define _DEST %_ASM_CX
28886 +#endif
28887 +
28888 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28889 +#define __copyuser_seg gs;
28890 +#else
28891 +#define __copyuser_seg
28892 +#endif
28893 +
28894 .text
28895 ENTRY(__put_user_1)
28896 ENTER
28897 +
28898 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28899 + GET_THREAD_INFO(%_ASM_BX)
28900 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28901 jae bad_put_user
28902 ASM_STAC
28903 -1: movb %al,(%_ASM_CX)
28904 +
28905 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28906 + mov pax_user_shadow_base,%_ASM_BX
28907 + cmp %_ASM_BX,%_ASM_CX
28908 + jb 1234f
28909 + xor %ebx,%ebx
28910 +1234:
28911 +#endif
28912 +
28913 +#endif
28914 +
28915 +1: __copyuser_seg movb %al,(_DEST)
28916 xor %eax,%eax
28917 EXIT
28918 ENDPROC(__put_user_1)
28919
28920 ENTRY(__put_user_2)
28921 ENTER
28922 +
28923 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28924 + GET_THREAD_INFO(%_ASM_BX)
28925 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28926 sub $1,%_ASM_BX
28927 cmp %_ASM_BX,%_ASM_CX
28928 jae bad_put_user
28929 ASM_STAC
28930 -2: movw %ax,(%_ASM_CX)
28931 +
28932 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28933 + mov pax_user_shadow_base,%_ASM_BX
28934 + cmp %_ASM_BX,%_ASM_CX
28935 + jb 1234f
28936 + xor %ebx,%ebx
28937 +1234:
28938 +#endif
28939 +
28940 +#endif
28941 +
28942 +2: __copyuser_seg movw %ax,(_DEST)
28943 xor %eax,%eax
28944 EXIT
28945 ENDPROC(__put_user_2)
28946
28947 ENTRY(__put_user_4)
28948 ENTER
28949 +
28950 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28951 + GET_THREAD_INFO(%_ASM_BX)
28952 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28953 sub $3,%_ASM_BX
28954 cmp %_ASM_BX,%_ASM_CX
28955 jae bad_put_user
28956 ASM_STAC
28957 -3: movl %eax,(%_ASM_CX)
28958 +
28959 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28960 + mov pax_user_shadow_base,%_ASM_BX
28961 + cmp %_ASM_BX,%_ASM_CX
28962 + jb 1234f
28963 + xor %ebx,%ebx
28964 +1234:
28965 +#endif
28966 +
28967 +#endif
28968 +
28969 +3: __copyuser_seg movl %eax,(_DEST)
28970 xor %eax,%eax
28971 EXIT
28972 ENDPROC(__put_user_4)
28973
28974 ENTRY(__put_user_8)
28975 ENTER
28976 +
28977 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28978 + GET_THREAD_INFO(%_ASM_BX)
28979 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28980 sub $7,%_ASM_BX
28981 cmp %_ASM_BX,%_ASM_CX
28982 jae bad_put_user
28983 ASM_STAC
28984 -4: mov %_ASM_AX,(%_ASM_CX)
28985 +
28986 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28987 + mov pax_user_shadow_base,%_ASM_BX
28988 + cmp %_ASM_BX,%_ASM_CX
28989 + jb 1234f
28990 + xor %ebx,%ebx
28991 +1234:
28992 +#endif
28993 +
28994 +#endif
28995 +
28996 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28997 #ifdef CONFIG_X86_32
28998 -5: movl %edx,4(%_ASM_CX)
28999 +5: __copyuser_seg movl %edx,4(_DEST)
29000 #endif
29001 xor %eax,%eax
29002 EXIT
29003 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29004 index 1cad221..de671ee 100644
29005 --- a/arch/x86/lib/rwlock.S
29006 +++ b/arch/x86/lib/rwlock.S
29007 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29008 FRAME
29009 0: LOCK_PREFIX
29010 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29011 +
29012 +#ifdef CONFIG_PAX_REFCOUNT
29013 + jno 1234f
29014 + LOCK_PREFIX
29015 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29016 + int $4
29017 +1234:
29018 + _ASM_EXTABLE(1234b, 1234b)
29019 +#endif
29020 +
29021 1: rep; nop
29022 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29023 jne 1b
29024 LOCK_PREFIX
29025 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29026 +
29027 +#ifdef CONFIG_PAX_REFCOUNT
29028 + jno 1234f
29029 + LOCK_PREFIX
29030 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29031 + int $4
29032 +1234:
29033 + _ASM_EXTABLE(1234b, 1234b)
29034 +#endif
29035 +
29036 jnz 0b
29037 ENDFRAME
29038 + pax_force_retaddr
29039 ret
29040 CFI_ENDPROC
29041 END(__write_lock_failed)
29042 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29043 FRAME
29044 0: LOCK_PREFIX
29045 READ_LOCK_SIZE(inc) (%__lock_ptr)
29046 +
29047 +#ifdef CONFIG_PAX_REFCOUNT
29048 + jno 1234f
29049 + LOCK_PREFIX
29050 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29051 + int $4
29052 +1234:
29053 + _ASM_EXTABLE(1234b, 1234b)
29054 +#endif
29055 +
29056 1: rep; nop
29057 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29058 js 1b
29059 LOCK_PREFIX
29060 READ_LOCK_SIZE(dec) (%__lock_ptr)
29061 +
29062 +#ifdef CONFIG_PAX_REFCOUNT
29063 + jno 1234f
29064 + LOCK_PREFIX
29065 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29066 + int $4
29067 +1234:
29068 + _ASM_EXTABLE(1234b, 1234b)
29069 +#endif
29070 +
29071 js 0b
29072 ENDFRAME
29073 + pax_force_retaddr
29074 ret
29075 CFI_ENDPROC
29076 END(__read_lock_failed)
29077 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29078 index 5dff5f0..cadebf4 100644
29079 --- a/arch/x86/lib/rwsem.S
29080 +++ b/arch/x86/lib/rwsem.S
29081 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29082 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29083 CFI_RESTORE __ASM_REG(dx)
29084 restore_common_regs
29085 + pax_force_retaddr
29086 ret
29087 CFI_ENDPROC
29088 ENDPROC(call_rwsem_down_read_failed)
29089 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29090 movq %rax,%rdi
29091 call rwsem_down_write_failed
29092 restore_common_regs
29093 + pax_force_retaddr
29094 ret
29095 CFI_ENDPROC
29096 ENDPROC(call_rwsem_down_write_failed)
29097 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29098 movq %rax,%rdi
29099 call rwsem_wake
29100 restore_common_regs
29101 -1: ret
29102 +1: pax_force_retaddr
29103 + ret
29104 CFI_ENDPROC
29105 ENDPROC(call_rwsem_wake)
29106
29107 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29108 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29109 CFI_RESTORE __ASM_REG(dx)
29110 restore_common_regs
29111 + pax_force_retaddr
29112 ret
29113 CFI_ENDPROC
29114 ENDPROC(call_rwsem_downgrade_wake)
29115 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29116 index a63efd6..ccecad8 100644
29117 --- a/arch/x86/lib/thunk_64.S
29118 +++ b/arch/x86/lib/thunk_64.S
29119 @@ -8,6 +8,7 @@
29120 #include <linux/linkage.h>
29121 #include <asm/dwarf2.h>
29122 #include <asm/calling.h>
29123 +#include <asm/alternative-asm.h>
29124
29125 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29126 .macro THUNK name, func, put_ret_addr_in_rdi=0
29127 @@ -41,5 +42,6 @@
29128 SAVE_ARGS
29129 restore:
29130 RESTORE_ARGS
29131 + pax_force_retaddr
29132 ret
29133 CFI_ENDPROC
29134 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29135 index 3eb18ac..6890bc3 100644
29136 --- a/arch/x86/lib/usercopy_32.c
29137 +++ b/arch/x86/lib/usercopy_32.c
29138 @@ -42,11 +42,13 @@ do { \
29139 int __d0; \
29140 might_fault(); \
29141 __asm__ __volatile__( \
29142 + __COPYUSER_SET_ES \
29143 ASM_STAC "\n" \
29144 "0: rep; stosl\n" \
29145 " movl %2,%0\n" \
29146 "1: rep; stosb\n" \
29147 "2: " ASM_CLAC "\n" \
29148 + __COPYUSER_RESTORE_ES \
29149 ".section .fixup,\"ax\"\n" \
29150 "3: lea 0(%2,%0,4),%0\n" \
29151 " jmp 2b\n" \
29152 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29153
29154 #ifdef CONFIG_X86_INTEL_USERCOPY
29155 static unsigned long
29156 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29157 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29158 {
29159 int d0, d1;
29160 __asm__ __volatile__(
29161 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29162 " .align 2,0x90\n"
29163 "3: movl 0(%4), %%eax\n"
29164 "4: movl 4(%4), %%edx\n"
29165 - "5: movl %%eax, 0(%3)\n"
29166 - "6: movl %%edx, 4(%3)\n"
29167 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29168 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29169 "7: movl 8(%4), %%eax\n"
29170 "8: movl 12(%4),%%edx\n"
29171 - "9: movl %%eax, 8(%3)\n"
29172 - "10: movl %%edx, 12(%3)\n"
29173 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29174 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29175 "11: movl 16(%4), %%eax\n"
29176 "12: movl 20(%4), %%edx\n"
29177 - "13: movl %%eax, 16(%3)\n"
29178 - "14: movl %%edx, 20(%3)\n"
29179 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29180 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29181 "15: movl 24(%4), %%eax\n"
29182 "16: movl 28(%4), %%edx\n"
29183 - "17: movl %%eax, 24(%3)\n"
29184 - "18: movl %%edx, 28(%3)\n"
29185 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29186 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29187 "19: movl 32(%4), %%eax\n"
29188 "20: movl 36(%4), %%edx\n"
29189 - "21: movl %%eax, 32(%3)\n"
29190 - "22: movl %%edx, 36(%3)\n"
29191 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29192 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29193 "23: movl 40(%4), %%eax\n"
29194 "24: movl 44(%4), %%edx\n"
29195 - "25: movl %%eax, 40(%3)\n"
29196 - "26: movl %%edx, 44(%3)\n"
29197 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29198 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29199 "27: movl 48(%4), %%eax\n"
29200 "28: movl 52(%4), %%edx\n"
29201 - "29: movl %%eax, 48(%3)\n"
29202 - "30: movl %%edx, 52(%3)\n"
29203 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29204 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29205 "31: movl 56(%4), %%eax\n"
29206 "32: movl 60(%4), %%edx\n"
29207 - "33: movl %%eax, 56(%3)\n"
29208 - "34: movl %%edx, 60(%3)\n"
29209 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29210 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29211 " addl $-64, %0\n"
29212 " addl $64, %4\n"
29213 " addl $64, %3\n"
29214 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29215 " shrl $2, %0\n"
29216 " andl $3, %%eax\n"
29217 " cld\n"
29218 + __COPYUSER_SET_ES
29219 "99: rep; movsl\n"
29220 "36: movl %%eax, %0\n"
29221 "37: rep; movsb\n"
29222 "100:\n"
29223 + __COPYUSER_RESTORE_ES
29224 ".section .fixup,\"ax\"\n"
29225 "101: lea 0(%%eax,%0,4),%0\n"
29226 " jmp 100b\n"
29227 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29228 }
29229
29230 static unsigned long
29231 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29232 +{
29233 + int d0, d1;
29234 + __asm__ __volatile__(
29235 + " .align 2,0x90\n"
29236 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29237 + " cmpl $67, %0\n"
29238 + " jbe 3f\n"
29239 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29240 + " .align 2,0x90\n"
29241 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29242 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29243 + "5: movl %%eax, 0(%3)\n"
29244 + "6: movl %%edx, 4(%3)\n"
29245 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29246 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29247 + "9: movl %%eax, 8(%3)\n"
29248 + "10: movl %%edx, 12(%3)\n"
29249 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29250 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29251 + "13: movl %%eax, 16(%3)\n"
29252 + "14: movl %%edx, 20(%3)\n"
29253 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29254 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29255 + "17: movl %%eax, 24(%3)\n"
29256 + "18: movl %%edx, 28(%3)\n"
29257 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29258 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29259 + "21: movl %%eax, 32(%3)\n"
29260 + "22: movl %%edx, 36(%3)\n"
29261 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29262 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29263 + "25: movl %%eax, 40(%3)\n"
29264 + "26: movl %%edx, 44(%3)\n"
29265 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29266 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29267 + "29: movl %%eax, 48(%3)\n"
29268 + "30: movl %%edx, 52(%3)\n"
29269 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29270 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29271 + "33: movl %%eax, 56(%3)\n"
29272 + "34: movl %%edx, 60(%3)\n"
29273 + " addl $-64, %0\n"
29274 + " addl $64, %4\n"
29275 + " addl $64, %3\n"
29276 + " cmpl $63, %0\n"
29277 + " ja 1b\n"
29278 + "35: movl %0, %%eax\n"
29279 + " shrl $2, %0\n"
29280 + " andl $3, %%eax\n"
29281 + " cld\n"
29282 + "99: rep; "__copyuser_seg" movsl\n"
29283 + "36: movl %%eax, %0\n"
29284 + "37: rep; "__copyuser_seg" movsb\n"
29285 + "100:\n"
29286 + ".section .fixup,\"ax\"\n"
29287 + "101: lea 0(%%eax,%0,4),%0\n"
29288 + " jmp 100b\n"
29289 + ".previous\n"
29290 + _ASM_EXTABLE(1b,100b)
29291 + _ASM_EXTABLE(2b,100b)
29292 + _ASM_EXTABLE(3b,100b)
29293 + _ASM_EXTABLE(4b,100b)
29294 + _ASM_EXTABLE(5b,100b)
29295 + _ASM_EXTABLE(6b,100b)
29296 + _ASM_EXTABLE(7b,100b)
29297 + _ASM_EXTABLE(8b,100b)
29298 + _ASM_EXTABLE(9b,100b)
29299 + _ASM_EXTABLE(10b,100b)
29300 + _ASM_EXTABLE(11b,100b)
29301 + _ASM_EXTABLE(12b,100b)
29302 + _ASM_EXTABLE(13b,100b)
29303 + _ASM_EXTABLE(14b,100b)
29304 + _ASM_EXTABLE(15b,100b)
29305 + _ASM_EXTABLE(16b,100b)
29306 + _ASM_EXTABLE(17b,100b)
29307 + _ASM_EXTABLE(18b,100b)
29308 + _ASM_EXTABLE(19b,100b)
29309 + _ASM_EXTABLE(20b,100b)
29310 + _ASM_EXTABLE(21b,100b)
29311 + _ASM_EXTABLE(22b,100b)
29312 + _ASM_EXTABLE(23b,100b)
29313 + _ASM_EXTABLE(24b,100b)
29314 + _ASM_EXTABLE(25b,100b)
29315 + _ASM_EXTABLE(26b,100b)
29316 + _ASM_EXTABLE(27b,100b)
29317 + _ASM_EXTABLE(28b,100b)
29318 + _ASM_EXTABLE(29b,100b)
29319 + _ASM_EXTABLE(30b,100b)
29320 + _ASM_EXTABLE(31b,100b)
29321 + _ASM_EXTABLE(32b,100b)
29322 + _ASM_EXTABLE(33b,100b)
29323 + _ASM_EXTABLE(34b,100b)
29324 + _ASM_EXTABLE(35b,100b)
29325 + _ASM_EXTABLE(36b,100b)
29326 + _ASM_EXTABLE(37b,100b)
29327 + _ASM_EXTABLE(99b,101b)
29328 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29329 + : "1"(to), "2"(from), "0"(size)
29330 + : "eax", "edx", "memory");
29331 + return size;
29332 +}
29333 +
29334 +static unsigned long __size_overflow(3)
29335 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29336 {
29337 int d0, d1;
29338 __asm__ __volatile__(
29339 " .align 2,0x90\n"
29340 - "0: movl 32(%4), %%eax\n"
29341 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29342 " cmpl $67, %0\n"
29343 " jbe 2f\n"
29344 - "1: movl 64(%4), %%eax\n"
29345 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29346 " .align 2,0x90\n"
29347 - "2: movl 0(%4), %%eax\n"
29348 - "21: movl 4(%4), %%edx\n"
29349 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29350 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29351 " movl %%eax, 0(%3)\n"
29352 " movl %%edx, 4(%3)\n"
29353 - "3: movl 8(%4), %%eax\n"
29354 - "31: movl 12(%4),%%edx\n"
29355 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29356 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29357 " movl %%eax, 8(%3)\n"
29358 " movl %%edx, 12(%3)\n"
29359 - "4: movl 16(%4), %%eax\n"
29360 - "41: movl 20(%4), %%edx\n"
29361 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29362 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29363 " movl %%eax, 16(%3)\n"
29364 " movl %%edx, 20(%3)\n"
29365 - "10: movl 24(%4), %%eax\n"
29366 - "51: movl 28(%4), %%edx\n"
29367 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29368 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29369 " movl %%eax, 24(%3)\n"
29370 " movl %%edx, 28(%3)\n"
29371 - "11: movl 32(%4), %%eax\n"
29372 - "61: movl 36(%4), %%edx\n"
29373 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29374 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29375 " movl %%eax, 32(%3)\n"
29376 " movl %%edx, 36(%3)\n"
29377 - "12: movl 40(%4), %%eax\n"
29378 - "71: movl 44(%4), %%edx\n"
29379 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29380 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29381 " movl %%eax, 40(%3)\n"
29382 " movl %%edx, 44(%3)\n"
29383 - "13: movl 48(%4), %%eax\n"
29384 - "81: movl 52(%4), %%edx\n"
29385 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29386 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29387 " movl %%eax, 48(%3)\n"
29388 " movl %%edx, 52(%3)\n"
29389 - "14: movl 56(%4), %%eax\n"
29390 - "91: movl 60(%4), %%edx\n"
29391 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29392 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29393 " movl %%eax, 56(%3)\n"
29394 " movl %%edx, 60(%3)\n"
29395 " addl $-64, %0\n"
29396 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29397 " shrl $2, %0\n"
29398 " andl $3, %%eax\n"
29399 " cld\n"
29400 - "6: rep; movsl\n"
29401 + "6: rep; "__copyuser_seg" movsl\n"
29402 " movl %%eax,%0\n"
29403 - "7: rep; movsb\n"
29404 + "7: rep; "__copyuser_seg" movsb\n"
29405 "8:\n"
29406 ".section .fixup,\"ax\"\n"
29407 "9: lea 0(%%eax,%0,4),%0\n"
29408 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29409 * hyoshiok@miraclelinux.com
29410 */
29411
29412 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29413 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29414 const void __user *from, unsigned long size)
29415 {
29416 int d0, d1;
29417
29418 __asm__ __volatile__(
29419 " .align 2,0x90\n"
29420 - "0: movl 32(%4), %%eax\n"
29421 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29422 " cmpl $67, %0\n"
29423 " jbe 2f\n"
29424 - "1: movl 64(%4), %%eax\n"
29425 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29426 " .align 2,0x90\n"
29427 - "2: movl 0(%4), %%eax\n"
29428 - "21: movl 4(%4), %%edx\n"
29429 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29430 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29431 " movnti %%eax, 0(%3)\n"
29432 " movnti %%edx, 4(%3)\n"
29433 - "3: movl 8(%4), %%eax\n"
29434 - "31: movl 12(%4),%%edx\n"
29435 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29436 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29437 " movnti %%eax, 8(%3)\n"
29438 " movnti %%edx, 12(%3)\n"
29439 - "4: movl 16(%4), %%eax\n"
29440 - "41: movl 20(%4), %%edx\n"
29441 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29442 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29443 " movnti %%eax, 16(%3)\n"
29444 " movnti %%edx, 20(%3)\n"
29445 - "10: movl 24(%4), %%eax\n"
29446 - "51: movl 28(%4), %%edx\n"
29447 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29448 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29449 " movnti %%eax, 24(%3)\n"
29450 " movnti %%edx, 28(%3)\n"
29451 - "11: movl 32(%4), %%eax\n"
29452 - "61: movl 36(%4), %%edx\n"
29453 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29454 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29455 " movnti %%eax, 32(%3)\n"
29456 " movnti %%edx, 36(%3)\n"
29457 - "12: movl 40(%4), %%eax\n"
29458 - "71: movl 44(%4), %%edx\n"
29459 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29460 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29461 " movnti %%eax, 40(%3)\n"
29462 " movnti %%edx, 44(%3)\n"
29463 - "13: movl 48(%4), %%eax\n"
29464 - "81: movl 52(%4), %%edx\n"
29465 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29466 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29467 " movnti %%eax, 48(%3)\n"
29468 " movnti %%edx, 52(%3)\n"
29469 - "14: movl 56(%4), %%eax\n"
29470 - "91: movl 60(%4), %%edx\n"
29471 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29472 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29473 " movnti %%eax, 56(%3)\n"
29474 " movnti %%edx, 60(%3)\n"
29475 " addl $-64, %0\n"
29476 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29477 " shrl $2, %0\n"
29478 " andl $3, %%eax\n"
29479 " cld\n"
29480 - "6: rep; movsl\n"
29481 + "6: rep; "__copyuser_seg" movsl\n"
29482 " movl %%eax,%0\n"
29483 - "7: rep; movsb\n"
29484 + "7: rep; "__copyuser_seg" movsb\n"
29485 "8:\n"
29486 ".section .fixup,\"ax\"\n"
29487 "9: lea 0(%%eax,%0,4),%0\n"
29488 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29489 return size;
29490 }
29491
29492 -static unsigned long __copy_user_intel_nocache(void *to,
29493 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29494 const void __user *from, unsigned long size)
29495 {
29496 int d0, d1;
29497
29498 __asm__ __volatile__(
29499 " .align 2,0x90\n"
29500 - "0: movl 32(%4), %%eax\n"
29501 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29502 " cmpl $67, %0\n"
29503 " jbe 2f\n"
29504 - "1: movl 64(%4), %%eax\n"
29505 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29506 " .align 2,0x90\n"
29507 - "2: movl 0(%4), %%eax\n"
29508 - "21: movl 4(%4), %%edx\n"
29509 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29510 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29511 " movnti %%eax, 0(%3)\n"
29512 " movnti %%edx, 4(%3)\n"
29513 - "3: movl 8(%4), %%eax\n"
29514 - "31: movl 12(%4),%%edx\n"
29515 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29516 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29517 " movnti %%eax, 8(%3)\n"
29518 " movnti %%edx, 12(%3)\n"
29519 - "4: movl 16(%4), %%eax\n"
29520 - "41: movl 20(%4), %%edx\n"
29521 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29522 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29523 " movnti %%eax, 16(%3)\n"
29524 " movnti %%edx, 20(%3)\n"
29525 - "10: movl 24(%4), %%eax\n"
29526 - "51: movl 28(%4), %%edx\n"
29527 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29528 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29529 " movnti %%eax, 24(%3)\n"
29530 " movnti %%edx, 28(%3)\n"
29531 - "11: movl 32(%4), %%eax\n"
29532 - "61: movl 36(%4), %%edx\n"
29533 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29534 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29535 " movnti %%eax, 32(%3)\n"
29536 " movnti %%edx, 36(%3)\n"
29537 - "12: movl 40(%4), %%eax\n"
29538 - "71: movl 44(%4), %%edx\n"
29539 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29540 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29541 " movnti %%eax, 40(%3)\n"
29542 " movnti %%edx, 44(%3)\n"
29543 - "13: movl 48(%4), %%eax\n"
29544 - "81: movl 52(%4), %%edx\n"
29545 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29546 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29547 " movnti %%eax, 48(%3)\n"
29548 " movnti %%edx, 52(%3)\n"
29549 - "14: movl 56(%4), %%eax\n"
29550 - "91: movl 60(%4), %%edx\n"
29551 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29552 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29553 " movnti %%eax, 56(%3)\n"
29554 " movnti %%edx, 60(%3)\n"
29555 " addl $-64, %0\n"
29556 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29557 " shrl $2, %0\n"
29558 " andl $3, %%eax\n"
29559 " cld\n"
29560 - "6: rep; movsl\n"
29561 + "6: rep; "__copyuser_seg" movsl\n"
29562 " movl %%eax,%0\n"
29563 - "7: rep; movsb\n"
29564 + "7: rep; "__copyuser_seg" movsb\n"
29565 "8:\n"
29566 ".section .fixup,\"ax\"\n"
29567 "9: lea 0(%%eax,%0,4),%0\n"
29568 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29569 */
29570 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29571 unsigned long size);
29572 -unsigned long __copy_user_intel(void __user *to, const void *from,
29573 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29574 + unsigned long size);
29575 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29576 unsigned long size);
29577 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29578 const void __user *from, unsigned long size);
29579 #endif /* CONFIG_X86_INTEL_USERCOPY */
29580
29581 /* Generic arbitrary sized copy. */
29582 -#define __copy_user(to, from, size) \
29583 +#define __copy_user(to, from, size, prefix, set, restore) \
29584 do { \
29585 int __d0, __d1, __d2; \
29586 __asm__ __volatile__( \
29587 + set \
29588 " cmp $7,%0\n" \
29589 " jbe 1f\n" \
29590 " movl %1,%0\n" \
29591 " negl %0\n" \
29592 " andl $7,%0\n" \
29593 " subl %0,%3\n" \
29594 - "4: rep; movsb\n" \
29595 + "4: rep; "prefix"movsb\n" \
29596 " movl %3,%0\n" \
29597 " shrl $2,%0\n" \
29598 " andl $3,%3\n" \
29599 " .align 2,0x90\n" \
29600 - "0: rep; movsl\n" \
29601 + "0: rep; "prefix"movsl\n" \
29602 " movl %3,%0\n" \
29603 - "1: rep; movsb\n" \
29604 + "1: rep; "prefix"movsb\n" \
29605 "2:\n" \
29606 + restore \
29607 ".section .fixup,\"ax\"\n" \
29608 "5: addl %3,%0\n" \
29609 " jmp 2b\n" \
29610 @@ -538,14 +650,14 @@ do { \
29611 " negl %0\n" \
29612 " andl $7,%0\n" \
29613 " subl %0,%3\n" \
29614 - "4: rep; movsb\n" \
29615 + "4: rep; "__copyuser_seg"movsb\n" \
29616 " movl %3,%0\n" \
29617 " shrl $2,%0\n" \
29618 " andl $3,%3\n" \
29619 " .align 2,0x90\n" \
29620 - "0: rep; movsl\n" \
29621 + "0: rep; "__copyuser_seg"movsl\n" \
29622 " movl %3,%0\n" \
29623 - "1: rep; movsb\n" \
29624 + "1: rep; "__copyuser_seg"movsb\n" \
29625 "2:\n" \
29626 ".section .fixup,\"ax\"\n" \
29627 "5: addl %3,%0\n" \
29628 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29629 {
29630 stac();
29631 if (movsl_is_ok(to, from, n))
29632 - __copy_user(to, from, n);
29633 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29634 else
29635 - n = __copy_user_intel(to, from, n);
29636 + n = __generic_copy_to_user_intel(to, from, n);
29637 clac();
29638 return n;
29639 }
29640 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29641 {
29642 stac();
29643 if (movsl_is_ok(to, from, n))
29644 - __copy_user(to, from, n);
29645 + __copy_user(to, from, n, __copyuser_seg, "", "");
29646 else
29647 - n = __copy_user_intel((void __user *)to,
29648 - (const void *)from, n);
29649 + n = __generic_copy_from_user_intel(to, from, n);
29650 clac();
29651 return n;
29652 }
29653 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29654 if (n > 64 && cpu_has_xmm2)
29655 n = __copy_user_intel_nocache(to, from, n);
29656 else
29657 - __copy_user(to, from, n);
29658 + __copy_user(to, from, n, __copyuser_seg, "", "");
29659 #else
29660 - __copy_user(to, from, n);
29661 + __copy_user(to, from, n, __copyuser_seg, "", "");
29662 #endif
29663 clac();
29664 return n;
29665 }
29666 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29667
29668 -/**
29669 - * copy_to_user: - Copy a block of data into user space.
29670 - * @to: Destination address, in user space.
29671 - * @from: Source address, in kernel space.
29672 - * @n: Number of bytes to copy.
29673 - *
29674 - * Context: User context only. This function may sleep.
29675 - *
29676 - * Copy data from kernel space to user space.
29677 - *
29678 - * Returns number of bytes that could not be copied.
29679 - * On success, this will be zero.
29680 - */
29681 -unsigned long
29682 -copy_to_user(void __user *to, const void *from, unsigned long n)
29683 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29684 +void __set_fs(mm_segment_t x)
29685 {
29686 - if (access_ok(VERIFY_WRITE, to, n))
29687 - n = __copy_to_user(to, from, n);
29688 - return n;
29689 + switch (x.seg) {
29690 + case 0:
29691 + loadsegment(gs, 0);
29692 + break;
29693 + case TASK_SIZE_MAX:
29694 + loadsegment(gs, __USER_DS);
29695 + break;
29696 + case -1UL:
29697 + loadsegment(gs, __KERNEL_DS);
29698 + break;
29699 + default:
29700 + BUG();
29701 + }
29702 }
29703 -EXPORT_SYMBOL(copy_to_user);
29704 +EXPORT_SYMBOL(__set_fs);
29705
29706 -/**
29707 - * copy_from_user: - Copy a block of data from user space.
29708 - * @to: Destination address, in kernel space.
29709 - * @from: Source address, in user space.
29710 - * @n: Number of bytes to copy.
29711 - *
29712 - * Context: User context only. This function may sleep.
29713 - *
29714 - * Copy data from user space to kernel space.
29715 - *
29716 - * Returns number of bytes that could not be copied.
29717 - * On success, this will be zero.
29718 - *
29719 - * If some data could not be copied, this function will pad the copied
29720 - * data to the requested size using zero bytes.
29721 - */
29722 -unsigned long
29723 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29724 +void set_fs(mm_segment_t x)
29725 {
29726 - if (access_ok(VERIFY_READ, from, n))
29727 - n = __copy_from_user(to, from, n);
29728 - else
29729 - memset(to, 0, n);
29730 - return n;
29731 + current_thread_info()->addr_limit = x;
29732 + __set_fs(x);
29733 }
29734 -EXPORT_SYMBOL(_copy_from_user);
29735 +EXPORT_SYMBOL(set_fs);
29736 +#endif
29737 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29738 index 906fea3..0194a18 100644
29739 --- a/arch/x86/lib/usercopy_64.c
29740 +++ b/arch/x86/lib/usercopy_64.c
29741 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29742 might_fault();
29743 /* no memory constraint because it doesn't change any memory gcc knows
29744 about */
29745 + pax_open_userland();
29746 stac();
29747 asm volatile(
29748 " testq %[size8],%[size8]\n"
29749 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29750 _ASM_EXTABLE(0b,3b)
29751 _ASM_EXTABLE(1b,2b)
29752 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29753 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29754 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29755 [zero] "r" (0UL), [eight] "r" (8UL));
29756 clac();
29757 + pax_close_userland();
29758 return size;
29759 }
29760 EXPORT_SYMBOL(__clear_user);
29761 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29762 }
29763 EXPORT_SYMBOL(clear_user);
29764
29765 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29766 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29767 {
29768 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29769 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29770 - }
29771 - return len;
29772 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29773 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29774 + return len;
29775 }
29776 EXPORT_SYMBOL(copy_in_user);
29777
29778 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29779 * it is not necessary to optimize tail handling.
29780 */
29781 unsigned long
29782 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29783 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29784 {
29785 char c;
29786 unsigned zero_len;
29787
29788 + clac();
29789 + pax_close_userland();
29790 for (; len; --len, to++) {
29791 if (__get_user_nocheck(c, from++, sizeof(char)))
29792 break;
29793 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29794 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29795 if (__put_user_nocheck(c, to++, sizeof(char)))
29796 break;
29797 - clac();
29798 return len;
29799 }
29800 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29801 index 23d8e5f..9ccc13a 100644
29802 --- a/arch/x86/mm/Makefile
29803 +++ b/arch/x86/mm/Makefile
29804 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29805 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29806
29807 obj-$(CONFIG_MEMTEST) += memtest.o
29808 +
29809 +quote:="
29810 +obj-$(CONFIG_X86_64) += uderef_64.o
29811 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29812 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29813 index 903ec1e..c4166b2 100644
29814 --- a/arch/x86/mm/extable.c
29815 +++ b/arch/x86/mm/extable.c
29816 @@ -6,12 +6,24 @@
29817 static inline unsigned long
29818 ex_insn_addr(const struct exception_table_entry *x)
29819 {
29820 - return (unsigned long)&x->insn + x->insn;
29821 + unsigned long reloc = 0;
29822 +
29823 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29824 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29825 +#endif
29826 +
29827 + return (unsigned long)&x->insn + x->insn + reloc;
29828 }
29829 static inline unsigned long
29830 ex_fixup_addr(const struct exception_table_entry *x)
29831 {
29832 - return (unsigned long)&x->fixup + x->fixup;
29833 + unsigned long reloc = 0;
29834 +
29835 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29836 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29837 +#endif
29838 +
29839 + return (unsigned long)&x->fixup + x->fixup + reloc;
29840 }
29841
29842 int fixup_exception(struct pt_regs *regs)
29843 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29844 unsigned long new_ip;
29845
29846 #ifdef CONFIG_PNPBIOS
29847 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29848 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29849 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29850 extern u32 pnp_bios_is_utter_crap;
29851 pnp_bios_is_utter_crap = 1;
29852 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29853 i += 4;
29854 p->fixup -= i;
29855 i += 4;
29856 +
29857 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29858 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29859 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29860 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29861 +#endif
29862 +
29863 }
29864 }
29865
29866 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29867 index 654be4a..a4a3da1 100644
29868 --- a/arch/x86/mm/fault.c
29869 +++ b/arch/x86/mm/fault.c
29870 @@ -14,11 +14,18 @@
29871 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29872 #include <linux/prefetch.h> /* prefetchw */
29873 #include <linux/context_tracking.h> /* exception_enter(), ... */
29874 +#include <linux/unistd.h>
29875 +#include <linux/compiler.h>
29876
29877 #include <asm/traps.h> /* dotraplinkage, ... */
29878 #include <asm/pgalloc.h> /* pgd_*(), ... */
29879 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29880 #include <asm/fixmap.h> /* VSYSCALL_START */
29881 +#include <asm/tlbflush.h>
29882 +
29883 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29884 +#include <asm/stacktrace.h>
29885 +#endif
29886
29887 /*
29888 * Page fault error code bits:
29889 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29890 int ret = 0;
29891
29892 /* kprobe_running() needs smp_processor_id() */
29893 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29894 + if (kprobes_built_in() && !user_mode(regs)) {
29895 preempt_disable();
29896 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29897 ret = 1;
29898 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29899 return !instr_lo || (instr_lo>>1) == 1;
29900 case 0x00:
29901 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29902 - if (probe_kernel_address(instr, opcode))
29903 + if (user_mode(regs)) {
29904 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29905 + return 0;
29906 + } else if (probe_kernel_address(instr, opcode))
29907 return 0;
29908
29909 *prefetch = (instr_lo == 0xF) &&
29910 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29911 while (instr < max_instr) {
29912 unsigned char opcode;
29913
29914 - if (probe_kernel_address(instr, opcode))
29915 + if (user_mode(regs)) {
29916 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29917 + break;
29918 + } else if (probe_kernel_address(instr, opcode))
29919 break;
29920
29921 instr++;
29922 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29923 force_sig_info(si_signo, &info, tsk);
29924 }
29925
29926 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29927 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29928 +#endif
29929 +
29930 +#ifdef CONFIG_PAX_EMUTRAMP
29931 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29932 +#endif
29933 +
29934 +#ifdef CONFIG_PAX_PAGEEXEC
29935 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29936 +{
29937 + pgd_t *pgd;
29938 + pud_t *pud;
29939 + pmd_t *pmd;
29940 +
29941 + pgd = pgd_offset(mm, address);
29942 + if (!pgd_present(*pgd))
29943 + return NULL;
29944 + pud = pud_offset(pgd, address);
29945 + if (!pud_present(*pud))
29946 + return NULL;
29947 + pmd = pmd_offset(pud, address);
29948 + if (!pmd_present(*pmd))
29949 + return NULL;
29950 + return pmd;
29951 +}
29952 +#endif
29953 +
29954 DEFINE_SPINLOCK(pgd_lock);
29955 LIST_HEAD(pgd_list);
29956
29957 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29958 for (address = VMALLOC_START & PMD_MASK;
29959 address >= TASK_SIZE && address < FIXADDR_TOP;
29960 address += PMD_SIZE) {
29961 +
29962 +#ifdef CONFIG_PAX_PER_CPU_PGD
29963 + unsigned long cpu;
29964 +#else
29965 struct page *page;
29966 +#endif
29967
29968 spin_lock(&pgd_lock);
29969 +
29970 +#ifdef CONFIG_PAX_PER_CPU_PGD
29971 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29972 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29973 + pmd_t *ret;
29974 +
29975 + ret = vmalloc_sync_one(pgd, address);
29976 + if (!ret)
29977 + break;
29978 + pgd = get_cpu_pgd(cpu, kernel);
29979 +#else
29980 list_for_each_entry(page, &pgd_list, lru) {
29981 + pgd_t *pgd;
29982 spinlock_t *pgt_lock;
29983 pmd_t *ret;
29984
29985 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29986 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29987
29988 spin_lock(pgt_lock);
29989 - ret = vmalloc_sync_one(page_address(page), address);
29990 + pgd = page_address(page);
29991 +#endif
29992 +
29993 + ret = vmalloc_sync_one(pgd, address);
29994 +
29995 +#ifndef CONFIG_PAX_PER_CPU_PGD
29996 spin_unlock(pgt_lock);
29997 +#endif
29998
29999 if (!ret)
30000 break;
30001 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30002 * an interrupt in the middle of a task switch..
30003 */
30004 pgd_paddr = read_cr3();
30005 +
30006 +#ifdef CONFIG_PAX_PER_CPU_PGD
30007 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30008 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30009 +#endif
30010 +
30011 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30012 if (!pmd_k)
30013 return -1;
30014 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30015 * happen within a race in page table update. In the later
30016 * case just flush:
30017 */
30018 - pgd = pgd_offset(current->active_mm, address);
30019 +
30020 pgd_ref = pgd_offset_k(address);
30021 if (pgd_none(*pgd_ref))
30022 return -1;
30023
30024 +#ifdef CONFIG_PAX_PER_CPU_PGD
30025 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30026 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30027 + if (pgd_none(*pgd)) {
30028 + set_pgd(pgd, *pgd_ref);
30029 + arch_flush_lazy_mmu_mode();
30030 + } else {
30031 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30032 + }
30033 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30034 +#else
30035 + pgd = pgd_offset(current->active_mm, address);
30036 +#endif
30037 +
30038 if (pgd_none(*pgd)) {
30039 set_pgd(pgd, *pgd_ref);
30040 arch_flush_lazy_mmu_mode();
30041 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30042 static int is_errata100(struct pt_regs *regs, unsigned long address)
30043 {
30044 #ifdef CONFIG_X86_64
30045 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30046 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30047 return 1;
30048 #endif
30049 return 0;
30050 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30051 }
30052
30053 static const char nx_warning[] = KERN_CRIT
30054 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30055 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30056
30057 static void
30058 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30059 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30060 if (!oops_may_print())
30061 return;
30062
30063 - if (error_code & PF_INSTR) {
30064 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30065 unsigned int level;
30066
30067 pte_t *pte = lookup_address(address, &level);
30068
30069 if (pte && pte_present(*pte) && !pte_exec(*pte))
30070 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30071 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30072 }
30073
30074 +#ifdef CONFIG_PAX_KERNEXEC
30075 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30076 + if (current->signal->curr_ip)
30077 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30078 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30079 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30080 + else
30081 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30082 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30083 + }
30084 +#endif
30085 +
30086 printk(KERN_ALERT "BUG: unable to handle kernel ");
30087 if (address < PAGE_SIZE)
30088 printk(KERN_CONT "NULL pointer dereference");
30089 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30090 return;
30091 }
30092 #endif
30093 +
30094 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30095 + if (pax_is_fetch_fault(regs, error_code, address)) {
30096 +
30097 +#ifdef CONFIG_PAX_EMUTRAMP
30098 + switch (pax_handle_fetch_fault(regs)) {
30099 + case 2:
30100 + return;
30101 + }
30102 +#endif
30103 +
30104 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30105 + do_group_exit(SIGKILL);
30106 + }
30107 +#endif
30108 +
30109 /* Kernel addresses are always protection faults: */
30110 if (address >= TASK_SIZE)
30111 error_code |= PF_PROT;
30112 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30113 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30114 printk(KERN_ERR
30115 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30116 - tsk->comm, tsk->pid, address);
30117 + tsk->comm, task_pid_nr(tsk), address);
30118 code = BUS_MCEERR_AR;
30119 }
30120 #endif
30121 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30122 return 1;
30123 }
30124
30125 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30126 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30127 +{
30128 + pte_t *pte;
30129 + pmd_t *pmd;
30130 + spinlock_t *ptl;
30131 + unsigned char pte_mask;
30132 +
30133 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30134 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30135 + return 0;
30136 +
30137 + /* PaX: it's our fault, let's handle it if we can */
30138 +
30139 + /* PaX: take a look at read faults before acquiring any locks */
30140 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30141 + /* instruction fetch attempt from a protected page in user mode */
30142 + up_read(&mm->mmap_sem);
30143 +
30144 +#ifdef CONFIG_PAX_EMUTRAMP
30145 + switch (pax_handle_fetch_fault(regs)) {
30146 + case 2:
30147 + return 1;
30148 + }
30149 +#endif
30150 +
30151 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30152 + do_group_exit(SIGKILL);
30153 + }
30154 +
30155 + pmd = pax_get_pmd(mm, address);
30156 + if (unlikely(!pmd))
30157 + return 0;
30158 +
30159 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30160 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30161 + pte_unmap_unlock(pte, ptl);
30162 + return 0;
30163 + }
30164 +
30165 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30166 + /* write attempt to a protected page in user mode */
30167 + pte_unmap_unlock(pte, ptl);
30168 + return 0;
30169 + }
30170 +
30171 +#ifdef CONFIG_SMP
30172 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30173 +#else
30174 + if (likely(address > get_limit(regs->cs)))
30175 +#endif
30176 + {
30177 + set_pte(pte, pte_mkread(*pte));
30178 + __flush_tlb_one(address);
30179 + pte_unmap_unlock(pte, ptl);
30180 + up_read(&mm->mmap_sem);
30181 + return 1;
30182 + }
30183 +
30184 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30185 +
30186 + /*
30187 + * PaX: fill DTLB with user rights and retry
30188 + */
30189 + __asm__ __volatile__ (
30190 + "orb %2,(%1)\n"
30191 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30192 +/*
30193 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30194 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30195 + * page fault when examined during a TLB load attempt. this is true not only
30196 + * for PTEs holding a non-present entry but also present entries that will
30197 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30198 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30199 + * for our target pages since their PTEs are simply not in the TLBs at all.
30200 +
30201 + * the best thing in omitting it is that we gain around 15-20% speed in the
30202 + * fast path of the page fault handler and can get rid of tracing since we
30203 + * can no longer flush unintended entries.
30204 + */
30205 + "invlpg (%0)\n"
30206 +#endif
30207 + __copyuser_seg"testb $0,(%0)\n"
30208 + "xorb %3,(%1)\n"
30209 + :
30210 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30211 + : "memory", "cc");
30212 + pte_unmap_unlock(pte, ptl);
30213 + up_read(&mm->mmap_sem);
30214 + return 1;
30215 +}
30216 +#endif
30217 +
30218 /*
30219 * Handle a spurious fault caused by a stale TLB entry.
30220 *
30221 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30222 static inline int
30223 access_error(unsigned long error_code, struct vm_area_struct *vma)
30224 {
30225 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30226 + return 1;
30227 +
30228 if (error_code & PF_WRITE) {
30229 /* write, present and write, not present: */
30230 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30231 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30232 if (error_code & PF_USER)
30233 return false;
30234
30235 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30236 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30237 return false;
30238
30239 return true;
30240 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30241 {
30242 struct vm_area_struct *vma;
30243 struct task_struct *tsk;
30244 - unsigned long address;
30245 struct mm_struct *mm;
30246 int fault;
30247 int write = error_code & PF_WRITE;
30248 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30249 (write ? FAULT_FLAG_WRITE : 0);
30250
30251 - tsk = current;
30252 - mm = tsk->mm;
30253 -
30254 /* Get the faulting address: */
30255 - address = read_cr2();
30256 + unsigned long address = read_cr2();
30257 +
30258 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30259 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30260 + if (!search_exception_tables(regs->ip)) {
30261 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30262 + bad_area_nosemaphore(regs, error_code, address);
30263 + return;
30264 + }
30265 + if (address < pax_user_shadow_base) {
30266 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30267 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30268 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30269 + } else
30270 + address -= pax_user_shadow_base;
30271 + }
30272 +#endif
30273 +
30274 + tsk = current;
30275 + mm = tsk->mm;
30276
30277 /*
30278 * Detect and handle instructions that would cause a page fault for
30279 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30280 * User-mode registers count as a user access even for any
30281 * potential system fault or CPU buglet:
30282 */
30283 - if (user_mode_vm(regs)) {
30284 + if (user_mode(regs)) {
30285 local_irq_enable();
30286 error_code |= PF_USER;
30287 } else {
30288 @@ -1142,6 +1365,11 @@ retry:
30289 might_sleep();
30290 }
30291
30292 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30293 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30294 + return;
30295 +#endif
30296 +
30297 vma = find_vma(mm, address);
30298 if (unlikely(!vma)) {
30299 bad_area(regs, error_code, address);
30300 @@ -1153,18 +1381,24 @@ retry:
30301 bad_area(regs, error_code, address);
30302 return;
30303 }
30304 - if (error_code & PF_USER) {
30305 - /*
30306 - * Accessing the stack below %sp is always a bug.
30307 - * The large cushion allows instructions like enter
30308 - * and pusha to work. ("enter $65535, $31" pushes
30309 - * 32 pointers and then decrements %sp by 65535.)
30310 - */
30311 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30312 - bad_area(regs, error_code, address);
30313 - return;
30314 - }
30315 + /*
30316 + * Accessing the stack below %sp is always a bug.
30317 + * The large cushion allows instructions like enter
30318 + * and pusha to work. ("enter $65535, $31" pushes
30319 + * 32 pointers and then decrements %sp by 65535.)
30320 + */
30321 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30322 + bad_area(regs, error_code, address);
30323 + return;
30324 }
30325 +
30326 +#ifdef CONFIG_PAX_SEGMEXEC
30327 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30328 + bad_area(regs, error_code, address);
30329 + return;
30330 + }
30331 +#endif
30332 +
30333 if (unlikely(expand_stack(vma, address))) {
30334 bad_area(regs, error_code, address);
30335 return;
30336 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30337 __do_page_fault(regs, error_code);
30338 exception_exit(prev_state);
30339 }
30340 +
30341 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30342 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30343 +{
30344 + struct mm_struct *mm = current->mm;
30345 + unsigned long ip = regs->ip;
30346 +
30347 + if (v8086_mode(regs))
30348 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30349 +
30350 +#ifdef CONFIG_PAX_PAGEEXEC
30351 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30352 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30353 + return true;
30354 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30355 + return true;
30356 + return false;
30357 + }
30358 +#endif
30359 +
30360 +#ifdef CONFIG_PAX_SEGMEXEC
30361 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30362 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30363 + return true;
30364 + return false;
30365 + }
30366 +#endif
30367 +
30368 + return false;
30369 +}
30370 +#endif
30371 +
30372 +#ifdef CONFIG_PAX_EMUTRAMP
30373 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30374 +{
30375 + int err;
30376 +
30377 + do { /* PaX: libffi trampoline emulation */
30378 + unsigned char mov, jmp;
30379 + unsigned int addr1, addr2;
30380 +
30381 +#ifdef CONFIG_X86_64
30382 + if ((regs->ip + 9) >> 32)
30383 + break;
30384 +#endif
30385 +
30386 + err = get_user(mov, (unsigned char __user *)regs->ip);
30387 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30388 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30389 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30390 +
30391 + if (err)
30392 + break;
30393 +
30394 + if (mov == 0xB8 && jmp == 0xE9) {
30395 + regs->ax = addr1;
30396 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30397 + return 2;
30398 + }
30399 + } while (0);
30400 +
30401 + do { /* PaX: gcc trampoline emulation #1 */
30402 + unsigned char mov1, mov2;
30403 + unsigned short jmp;
30404 + unsigned int addr1, addr2;
30405 +
30406 +#ifdef CONFIG_X86_64
30407 + if ((regs->ip + 11) >> 32)
30408 + break;
30409 +#endif
30410 +
30411 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30412 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30413 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30414 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30415 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30416 +
30417 + if (err)
30418 + break;
30419 +
30420 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30421 + regs->cx = addr1;
30422 + regs->ax = addr2;
30423 + regs->ip = addr2;
30424 + return 2;
30425 + }
30426 + } while (0);
30427 +
30428 + do { /* PaX: gcc trampoline emulation #2 */
30429 + unsigned char mov, jmp;
30430 + unsigned int addr1, addr2;
30431 +
30432 +#ifdef CONFIG_X86_64
30433 + if ((regs->ip + 9) >> 32)
30434 + break;
30435 +#endif
30436 +
30437 + err = get_user(mov, (unsigned char __user *)regs->ip);
30438 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30439 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30440 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30441 +
30442 + if (err)
30443 + break;
30444 +
30445 + if (mov == 0xB9 && jmp == 0xE9) {
30446 + regs->cx = addr1;
30447 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30448 + return 2;
30449 + }
30450 + } while (0);
30451 +
30452 + return 1; /* PaX in action */
30453 +}
30454 +
30455 +#ifdef CONFIG_X86_64
30456 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30457 +{
30458 + int err;
30459 +
30460 + do { /* PaX: libffi trampoline emulation */
30461 + unsigned short mov1, mov2, jmp1;
30462 + unsigned char stcclc, jmp2;
30463 + unsigned long addr1, addr2;
30464 +
30465 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30466 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30467 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30468 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30469 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30470 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30471 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30472 +
30473 + if (err)
30474 + break;
30475 +
30476 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30477 + regs->r11 = addr1;
30478 + regs->r10 = addr2;
30479 + if (stcclc == 0xF8)
30480 + regs->flags &= ~X86_EFLAGS_CF;
30481 + else
30482 + regs->flags |= X86_EFLAGS_CF;
30483 + regs->ip = addr1;
30484 + return 2;
30485 + }
30486 + } while (0);
30487 +
30488 + do { /* PaX: gcc trampoline emulation #1 */
30489 + unsigned short mov1, mov2, jmp1;
30490 + unsigned char jmp2;
30491 + unsigned int addr1;
30492 + unsigned long addr2;
30493 +
30494 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30495 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30496 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30497 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30498 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30499 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30500 +
30501 + if (err)
30502 + break;
30503 +
30504 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30505 + regs->r11 = addr1;
30506 + regs->r10 = addr2;
30507 + regs->ip = addr1;
30508 + return 2;
30509 + }
30510 + } while (0);
30511 +
30512 + do { /* PaX: gcc trampoline emulation #2 */
30513 + unsigned short mov1, mov2, jmp1;
30514 + unsigned char jmp2;
30515 + unsigned long addr1, addr2;
30516 +
30517 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30518 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30519 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30520 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30521 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30522 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30523 +
30524 + if (err)
30525 + break;
30526 +
30527 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30528 + regs->r11 = addr1;
30529 + regs->r10 = addr2;
30530 + regs->ip = addr1;
30531 + return 2;
30532 + }
30533 + } while (0);
30534 +
30535 + return 1; /* PaX in action */
30536 +}
30537 +#endif
30538 +
30539 +/*
30540 + * PaX: decide what to do with offenders (regs->ip = fault address)
30541 + *
30542 + * returns 1 when task should be killed
30543 + * 2 when gcc trampoline was detected
30544 + */
30545 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30546 +{
30547 + if (v8086_mode(regs))
30548 + return 1;
30549 +
30550 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30551 + return 1;
30552 +
30553 +#ifdef CONFIG_X86_32
30554 + return pax_handle_fetch_fault_32(regs);
30555 +#else
30556 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30557 + return pax_handle_fetch_fault_32(regs);
30558 + else
30559 + return pax_handle_fetch_fault_64(regs);
30560 +#endif
30561 +}
30562 +#endif
30563 +
30564 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30565 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30566 +{
30567 + long i;
30568 +
30569 + printk(KERN_ERR "PAX: bytes at PC: ");
30570 + for (i = 0; i < 20; i++) {
30571 + unsigned char c;
30572 + if (get_user(c, (unsigned char __force_user *)pc+i))
30573 + printk(KERN_CONT "?? ");
30574 + else
30575 + printk(KERN_CONT "%02x ", c);
30576 + }
30577 + printk("\n");
30578 +
30579 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30580 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30581 + unsigned long c;
30582 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30583 +#ifdef CONFIG_X86_32
30584 + printk(KERN_CONT "???????? ");
30585 +#else
30586 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30587 + printk(KERN_CONT "???????? ???????? ");
30588 + else
30589 + printk(KERN_CONT "???????????????? ");
30590 +#endif
30591 + } else {
30592 +#ifdef CONFIG_X86_64
30593 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30594 + printk(KERN_CONT "%08x ", (unsigned int)c);
30595 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30596 + } else
30597 +#endif
30598 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30599 + }
30600 + }
30601 + printk("\n");
30602 +}
30603 +#endif
30604 +
30605 +/**
30606 + * probe_kernel_write(): safely attempt to write to a location
30607 + * @dst: address to write to
30608 + * @src: pointer to the data that shall be written
30609 + * @size: size of the data chunk
30610 + *
30611 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30612 + * happens, handle that and return -EFAULT.
30613 + */
30614 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30615 +{
30616 + long ret;
30617 + mm_segment_t old_fs = get_fs();
30618 +
30619 + set_fs(KERNEL_DS);
30620 + pagefault_disable();
30621 + pax_open_kernel();
30622 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30623 + pax_close_kernel();
30624 + pagefault_enable();
30625 + set_fs(old_fs);
30626 +
30627 + return ret ? -EFAULT : 0;
30628 +}
30629 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30630 index dd74e46..7d26398 100644
30631 --- a/arch/x86/mm/gup.c
30632 +++ b/arch/x86/mm/gup.c
30633 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30634 addr = start;
30635 len = (unsigned long) nr_pages << PAGE_SHIFT;
30636 end = start + len;
30637 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30638 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30639 (void __user *)start, len)))
30640 return 0;
30641
30642 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30643 index 4500142..53a363c 100644
30644 --- a/arch/x86/mm/highmem_32.c
30645 +++ b/arch/x86/mm/highmem_32.c
30646 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30647 idx = type + KM_TYPE_NR*smp_processor_id();
30648 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30649 BUG_ON(!pte_none(*(kmap_pte-idx)));
30650 +
30651 + pax_open_kernel();
30652 set_pte(kmap_pte-idx, mk_pte(page, prot));
30653 + pax_close_kernel();
30654 +
30655 arch_flush_lazy_mmu_mode();
30656
30657 return (void *)vaddr;
30658 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30659 index 7e73e8c..11d3b86 100644
30660 --- a/arch/x86/mm/hugetlbpage.c
30661 +++ b/arch/x86/mm/hugetlbpage.c
30662 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30663 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30664 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30665 unsigned long addr, unsigned long len,
30666 - unsigned long pgoff, unsigned long flags)
30667 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30668 {
30669 struct hstate *h = hstate_file(file);
30670 struct vm_unmapped_area_info info;
30671 -
30672 +
30673 info.flags = 0;
30674 info.length = len;
30675 info.low_limit = TASK_UNMAPPED_BASE;
30676 +
30677 +#ifdef CONFIG_PAX_RANDMMAP
30678 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30679 + info.low_limit += current->mm->delta_mmap;
30680 +#endif
30681 +
30682 info.high_limit = TASK_SIZE;
30683 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30684 info.align_offset = 0;
30685 + info.threadstack_offset = offset;
30686 return vm_unmapped_area(&info);
30687 }
30688
30689 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30690 unsigned long addr0, unsigned long len,
30691 - unsigned long pgoff, unsigned long flags)
30692 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30693 {
30694 struct hstate *h = hstate_file(file);
30695 struct vm_unmapped_area_info info;
30696 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30697 info.high_limit = current->mm->mmap_base;
30698 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30699 info.align_offset = 0;
30700 + info.threadstack_offset = offset;
30701 addr = vm_unmapped_area(&info);
30702
30703 /*
30704 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30705 VM_BUG_ON(addr != -ENOMEM);
30706 info.flags = 0;
30707 info.low_limit = TASK_UNMAPPED_BASE;
30708 +
30709 +#ifdef CONFIG_PAX_RANDMMAP
30710 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30711 + info.low_limit += current->mm->delta_mmap;
30712 +#endif
30713 +
30714 info.high_limit = TASK_SIZE;
30715 addr = vm_unmapped_area(&info);
30716 }
30717 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30718 struct hstate *h = hstate_file(file);
30719 struct mm_struct *mm = current->mm;
30720 struct vm_area_struct *vma;
30721 + unsigned long pax_task_size = TASK_SIZE;
30722 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30723
30724 if (len & ~huge_page_mask(h))
30725 return -EINVAL;
30726 - if (len > TASK_SIZE)
30727 +
30728 +#ifdef CONFIG_PAX_SEGMEXEC
30729 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30730 + pax_task_size = SEGMEXEC_TASK_SIZE;
30731 +#endif
30732 +
30733 + pax_task_size -= PAGE_SIZE;
30734 +
30735 + if (len > pax_task_size)
30736 return -ENOMEM;
30737
30738 if (flags & MAP_FIXED) {
30739 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30740 return addr;
30741 }
30742
30743 +#ifdef CONFIG_PAX_RANDMMAP
30744 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30745 +#endif
30746 +
30747 if (addr) {
30748 addr = ALIGN(addr, huge_page_size(h));
30749 vma = find_vma(mm, addr);
30750 - if (TASK_SIZE - len >= addr &&
30751 - (!vma || addr + len <= vma->vm_start))
30752 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30753 return addr;
30754 }
30755 if (mm->get_unmapped_area == arch_get_unmapped_area)
30756 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30757 - pgoff, flags);
30758 + pgoff, flags, offset);
30759 else
30760 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30761 - pgoff, flags);
30762 + pgoff, flags, offset);
30763 }
30764
30765 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30766 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30767 index 04664cd..dae6e5d 100644
30768 --- a/arch/x86/mm/init.c
30769 +++ b/arch/x86/mm/init.c
30770 @@ -4,6 +4,7 @@
30771 #include <linux/swap.h>
30772 #include <linux/memblock.h>
30773 #include <linux/bootmem.h> /* for max_low_pfn */
30774 +#include <linux/tboot.h>
30775
30776 #include <asm/cacheflush.h>
30777 #include <asm/e820.h>
30778 @@ -17,6 +18,8 @@
30779 #include <asm/proto.h>
30780 #include <asm/dma.h> /* for MAX_DMA_PFN */
30781 #include <asm/microcode.h>
30782 +#include <asm/desc.h>
30783 +#include <asm/bios_ebda.h>
30784
30785 #include "mm_internal.h"
30786
30787 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30788 early_ioremap_page_table_range_init();
30789 #endif
30790
30791 +#ifdef CONFIG_PAX_PER_CPU_PGD
30792 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30793 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30794 + KERNEL_PGD_PTRS);
30795 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30796 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30797 + KERNEL_PGD_PTRS);
30798 + load_cr3(get_cpu_pgd(0, kernel));
30799 +#else
30800 load_cr3(swapper_pg_dir);
30801 +#endif
30802 +
30803 __flush_tlb_all();
30804
30805 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30806 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30807 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30808 * mmio resources as well as potential bios/acpi data regions.
30809 */
30810 +
30811 +#ifdef CONFIG_GRKERNSEC_KMEM
30812 +static unsigned int ebda_start __read_only;
30813 +static unsigned int ebda_end __read_only;
30814 +#endif
30815 +
30816 int devmem_is_allowed(unsigned long pagenr)
30817 {
30818 - if (pagenr < 256)
30819 +#ifdef CONFIG_GRKERNSEC_KMEM
30820 + /* allow BDA */
30821 + if (!pagenr)
30822 return 1;
30823 + /* allow EBDA */
30824 + if (pagenr >= ebda_start && pagenr < ebda_end)
30825 + return 1;
30826 + /* if tboot is in use, allow access to its hardcoded serial log range */
30827 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30828 + return 1;
30829 +#else
30830 + if (!pagenr)
30831 + return 1;
30832 +#ifdef CONFIG_VM86
30833 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30834 + return 1;
30835 +#endif
30836 +#endif
30837 +
30838 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30839 + return 1;
30840 +#ifdef CONFIG_GRKERNSEC_KMEM
30841 + /* throw out everything else below 1MB */
30842 + if (pagenr <= 256)
30843 + return 0;
30844 +#endif
30845 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30846 return 0;
30847 if (!page_is_ram(pagenr))
30848 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30849 #endif
30850 }
30851
30852 +#ifdef CONFIG_GRKERNSEC_KMEM
30853 +static inline void gr_init_ebda(void)
30854 +{
30855 + unsigned int ebda_addr;
30856 + unsigned int ebda_size = 0;
30857 +
30858 + ebda_addr = get_bios_ebda();
30859 + if (ebda_addr) {
30860 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30861 + ebda_size <<= 10;
30862 + }
30863 + if (ebda_addr && ebda_size) {
30864 + ebda_start = ebda_addr >> PAGE_SHIFT;
30865 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30866 + } else {
30867 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30868 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30869 + }
30870 +}
30871 +#else
30872 +static inline void gr_init_ebda(void) { }
30873 +#endif
30874 +
30875 void free_initmem(void)
30876 {
30877 +#ifdef CONFIG_PAX_KERNEXEC
30878 +#ifdef CONFIG_X86_32
30879 + /* PaX: limit KERNEL_CS to actual size */
30880 + unsigned long addr, limit;
30881 + struct desc_struct d;
30882 + int cpu;
30883 +#else
30884 + pgd_t *pgd;
30885 + pud_t *pud;
30886 + pmd_t *pmd;
30887 + unsigned long addr, end;
30888 +#endif
30889 +#endif
30890 +
30891 + gr_init_ebda();
30892 +
30893 +#ifdef CONFIG_PAX_KERNEXEC
30894 +#ifdef CONFIG_X86_32
30895 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30896 + limit = (limit - 1UL) >> PAGE_SHIFT;
30897 +
30898 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30899 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30900 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30901 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30902 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30903 + }
30904 +
30905 + /* PaX: make KERNEL_CS read-only */
30906 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30907 + if (!paravirt_enabled())
30908 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30909 +/*
30910 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30911 + pgd = pgd_offset_k(addr);
30912 + pud = pud_offset(pgd, addr);
30913 + pmd = pmd_offset(pud, addr);
30914 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30915 + }
30916 +*/
30917 +#ifdef CONFIG_X86_PAE
30918 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30919 +/*
30920 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30921 + pgd = pgd_offset_k(addr);
30922 + pud = pud_offset(pgd, addr);
30923 + pmd = pmd_offset(pud, addr);
30924 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30925 + }
30926 +*/
30927 +#endif
30928 +
30929 +#ifdef CONFIG_MODULES
30930 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30931 +#endif
30932 +
30933 +#else
30934 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30935 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30936 + pgd = pgd_offset_k(addr);
30937 + pud = pud_offset(pgd, addr);
30938 + pmd = pmd_offset(pud, addr);
30939 + if (!pmd_present(*pmd))
30940 + continue;
30941 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30942 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30943 + else
30944 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30945 + }
30946 +
30947 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30948 + end = addr + KERNEL_IMAGE_SIZE;
30949 + for (; addr < end; addr += PMD_SIZE) {
30950 + pgd = pgd_offset_k(addr);
30951 + pud = pud_offset(pgd, addr);
30952 + pmd = pmd_offset(pud, addr);
30953 + if (!pmd_present(*pmd))
30954 + continue;
30955 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30956 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30957 + }
30958 +#endif
30959 +
30960 + flush_tlb_all();
30961 +#endif
30962 +
30963 free_init_pages("unused kernel",
30964 (unsigned long)(&__init_begin),
30965 (unsigned long)(&__init_end));
30966 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30967 index 4287f1f..3b99c71 100644
30968 --- a/arch/x86/mm/init_32.c
30969 +++ b/arch/x86/mm/init_32.c
30970 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30971 bool __read_mostly __vmalloc_start_set = false;
30972
30973 /*
30974 - * Creates a middle page table and puts a pointer to it in the
30975 - * given global directory entry. This only returns the gd entry
30976 - * in non-PAE compilation mode, since the middle layer is folded.
30977 - */
30978 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30979 -{
30980 - pud_t *pud;
30981 - pmd_t *pmd_table;
30982 -
30983 -#ifdef CONFIG_X86_PAE
30984 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30985 - pmd_table = (pmd_t *)alloc_low_page();
30986 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30987 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30988 - pud = pud_offset(pgd, 0);
30989 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30990 -
30991 - return pmd_table;
30992 - }
30993 -#endif
30994 - pud = pud_offset(pgd, 0);
30995 - pmd_table = pmd_offset(pud, 0);
30996 -
30997 - return pmd_table;
30998 -}
30999 -
31000 -/*
31001 * Create a page table and place a pointer to it in a middle page
31002 * directory entry:
31003 */
31004 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31005 pte_t *page_table = (pte_t *)alloc_low_page();
31006
31007 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31008 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31009 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31010 +#else
31011 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31012 +#endif
31013 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31014 }
31015
31016 return pte_offset_kernel(pmd, 0);
31017 }
31018
31019 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31020 +{
31021 + pud_t *pud;
31022 + pmd_t *pmd_table;
31023 +
31024 + pud = pud_offset(pgd, 0);
31025 + pmd_table = pmd_offset(pud, 0);
31026 +
31027 + return pmd_table;
31028 +}
31029 +
31030 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31031 {
31032 int pgd_idx = pgd_index(vaddr);
31033 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31034 int pgd_idx, pmd_idx;
31035 unsigned long vaddr;
31036 pgd_t *pgd;
31037 + pud_t *pud;
31038 pmd_t *pmd;
31039 pte_t *pte = NULL;
31040 unsigned long count = page_table_range_init_count(start, end);
31041 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31042 pgd = pgd_base + pgd_idx;
31043
31044 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31045 - pmd = one_md_table_init(pgd);
31046 - pmd = pmd + pmd_index(vaddr);
31047 + pud = pud_offset(pgd, vaddr);
31048 + pmd = pmd_offset(pud, vaddr);
31049 +
31050 +#ifdef CONFIG_X86_PAE
31051 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31052 +#endif
31053 +
31054 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31055 pmd++, pmd_idx++) {
31056 pte = page_table_kmap_check(one_page_table_init(pmd),
31057 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31058 }
31059 }
31060
31061 -static inline int is_kernel_text(unsigned long addr)
31062 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31063 {
31064 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31065 - return 1;
31066 - return 0;
31067 + if ((start > ktla_ktva((unsigned long)_etext) ||
31068 + end <= ktla_ktva((unsigned long)_stext)) &&
31069 + (start > ktla_ktva((unsigned long)_einittext) ||
31070 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31071 +
31072 +#ifdef CONFIG_ACPI_SLEEP
31073 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31074 +#endif
31075 +
31076 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31077 + return 0;
31078 + return 1;
31079 }
31080
31081 /*
31082 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31083 unsigned long last_map_addr = end;
31084 unsigned long start_pfn, end_pfn;
31085 pgd_t *pgd_base = swapper_pg_dir;
31086 - int pgd_idx, pmd_idx, pte_ofs;
31087 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31088 unsigned long pfn;
31089 pgd_t *pgd;
31090 + pud_t *pud;
31091 pmd_t *pmd;
31092 pte_t *pte;
31093 unsigned pages_2m, pages_4k;
31094 @@ -291,8 +295,13 @@ repeat:
31095 pfn = start_pfn;
31096 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31097 pgd = pgd_base + pgd_idx;
31098 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31099 - pmd = one_md_table_init(pgd);
31100 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31101 + pud = pud_offset(pgd, 0);
31102 + pmd = pmd_offset(pud, 0);
31103 +
31104 +#ifdef CONFIG_X86_PAE
31105 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31106 +#endif
31107
31108 if (pfn >= end_pfn)
31109 continue;
31110 @@ -304,14 +313,13 @@ repeat:
31111 #endif
31112 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31113 pmd++, pmd_idx++) {
31114 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31115 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31116
31117 /*
31118 * Map with big pages if possible, otherwise
31119 * create normal page tables:
31120 */
31121 if (use_pse) {
31122 - unsigned int addr2;
31123 pgprot_t prot = PAGE_KERNEL_LARGE;
31124 /*
31125 * first pass will use the same initial
31126 @@ -322,11 +330,7 @@ repeat:
31127 _PAGE_PSE);
31128
31129 pfn &= PMD_MASK >> PAGE_SHIFT;
31130 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31131 - PAGE_OFFSET + PAGE_SIZE-1;
31132 -
31133 - if (is_kernel_text(addr) ||
31134 - is_kernel_text(addr2))
31135 + if (is_kernel_text(address, address + PMD_SIZE))
31136 prot = PAGE_KERNEL_LARGE_EXEC;
31137
31138 pages_2m++;
31139 @@ -343,7 +347,7 @@ repeat:
31140 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31141 pte += pte_ofs;
31142 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31143 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31144 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31145 pgprot_t prot = PAGE_KERNEL;
31146 /*
31147 * first pass will use the same initial
31148 @@ -351,7 +355,7 @@ repeat:
31149 */
31150 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31151
31152 - if (is_kernel_text(addr))
31153 + if (is_kernel_text(address, address + PAGE_SIZE))
31154 prot = PAGE_KERNEL_EXEC;
31155
31156 pages_4k++;
31157 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31158
31159 pud = pud_offset(pgd, va);
31160 pmd = pmd_offset(pud, va);
31161 - if (!pmd_present(*pmd))
31162 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31163 break;
31164
31165 /* should not be large page here */
31166 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31167
31168 static void __init pagetable_init(void)
31169 {
31170 - pgd_t *pgd_base = swapper_pg_dir;
31171 -
31172 - permanent_kmaps_init(pgd_base);
31173 + permanent_kmaps_init(swapper_pg_dir);
31174 }
31175
31176 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31177 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31178 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31179
31180 /* user-defined highmem size */
31181 @@ -787,10 +789,10 @@ void __init mem_init(void)
31182 ((unsigned long)&__init_end -
31183 (unsigned long)&__init_begin) >> 10,
31184
31185 - (unsigned long)&_etext, (unsigned long)&_edata,
31186 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31187 + (unsigned long)&_sdata, (unsigned long)&_edata,
31188 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31189
31190 - (unsigned long)&_text, (unsigned long)&_etext,
31191 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31192 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31193
31194 /*
31195 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31196 if (!kernel_set_to_readonly)
31197 return;
31198
31199 + start = ktla_ktva(start);
31200 pr_debug("Set kernel text: %lx - %lx for read write\n",
31201 start, start+size);
31202
31203 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31204 if (!kernel_set_to_readonly)
31205 return;
31206
31207 + start = ktla_ktva(start);
31208 pr_debug("Set kernel text: %lx - %lx for read only\n",
31209 start, start+size);
31210
31211 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31212 unsigned long start = PFN_ALIGN(_text);
31213 unsigned long size = PFN_ALIGN(_etext) - start;
31214
31215 + start = ktla_ktva(start);
31216 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31217 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31218 size >> 10);
31219 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31220 index 104d56a..62ba13f1 100644
31221 --- a/arch/x86/mm/init_64.c
31222 +++ b/arch/x86/mm/init_64.c
31223 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31224 * around without checking the pgd every time.
31225 */
31226
31227 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31228 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31229 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31230
31231 int force_personality32;
31232 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31233
31234 for (address = start; address <= end; address += PGDIR_SIZE) {
31235 const pgd_t *pgd_ref = pgd_offset_k(address);
31236 +
31237 +#ifdef CONFIG_PAX_PER_CPU_PGD
31238 + unsigned long cpu;
31239 +#else
31240 struct page *page;
31241 +#endif
31242
31243 if (pgd_none(*pgd_ref))
31244 continue;
31245
31246 spin_lock(&pgd_lock);
31247 +
31248 +#ifdef CONFIG_PAX_PER_CPU_PGD
31249 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31250 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31251 +
31252 + if (pgd_none(*pgd))
31253 + set_pgd(pgd, *pgd_ref);
31254 + else
31255 + BUG_ON(pgd_page_vaddr(*pgd)
31256 + != pgd_page_vaddr(*pgd_ref));
31257 + pgd = pgd_offset_cpu(cpu, kernel, address);
31258 +#else
31259 list_for_each_entry(page, &pgd_list, lru) {
31260 pgd_t *pgd;
31261 spinlock_t *pgt_lock;
31262 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31263 /* the pgt_lock only for Xen */
31264 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31265 spin_lock(pgt_lock);
31266 +#endif
31267
31268 if (pgd_none(*pgd))
31269 set_pgd(pgd, *pgd_ref);
31270 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31271 BUG_ON(pgd_page_vaddr(*pgd)
31272 != pgd_page_vaddr(*pgd_ref));
31273
31274 +#ifndef CONFIG_PAX_PER_CPU_PGD
31275 spin_unlock(pgt_lock);
31276 +#endif
31277 +
31278 }
31279 spin_unlock(&pgd_lock);
31280 }
31281 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31282 {
31283 if (pgd_none(*pgd)) {
31284 pud_t *pud = (pud_t *)spp_getpage();
31285 - pgd_populate(&init_mm, pgd, pud);
31286 + pgd_populate_kernel(&init_mm, pgd, pud);
31287 if (pud != pud_offset(pgd, 0))
31288 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31289 pud, pud_offset(pgd, 0));
31290 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31291 {
31292 if (pud_none(*pud)) {
31293 pmd_t *pmd = (pmd_t *) spp_getpage();
31294 - pud_populate(&init_mm, pud, pmd);
31295 + pud_populate_kernel(&init_mm, pud, pmd);
31296 if (pmd != pmd_offset(pud, 0))
31297 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31298 pmd, pmd_offset(pud, 0));
31299 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31300 pmd = fill_pmd(pud, vaddr);
31301 pte = fill_pte(pmd, vaddr);
31302
31303 + pax_open_kernel();
31304 set_pte(pte, new_pte);
31305 + pax_close_kernel();
31306
31307 /*
31308 * It's enough to flush this one mapping.
31309 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31310 pgd = pgd_offset_k((unsigned long)__va(phys));
31311 if (pgd_none(*pgd)) {
31312 pud = (pud_t *) spp_getpage();
31313 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31314 - _PAGE_USER));
31315 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31316 }
31317 pud = pud_offset(pgd, (unsigned long)__va(phys));
31318 if (pud_none(*pud)) {
31319 pmd = (pmd_t *) spp_getpage();
31320 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31321 - _PAGE_USER));
31322 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31323 }
31324 pmd = pmd_offset(pud, phys);
31325 BUG_ON(!pmd_none(*pmd));
31326 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31327 prot);
31328
31329 spin_lock(&init_mm.page_table_lock);
31330 - pud_populate(&init_mm, pud, pmd);
31331 + pud_populate_kernel(&init_mm, pud, pmd);
31332 spin_unlock(&init_mm.page_table_lock);
31333 }
31334 __flush_tlb_all();
31335 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31336 page_size_mask);
31337
31338 spin_lock(&init_mm.page_table_lock);
31339 - pgd_populate(&init_mm, pgd, pud);
31340 + pgd_populate_kernel(&init_mm, pgd, pud);
31341 spin_unlock(&init_mm.page_table_lock);
31342 pgd_changed = true;
31343 }
31344 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31345 static struct vm_area_struct gate_vma = {
31346 .vm_start = VSYSCALL_START,
31347 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31348 - .vm_page_prot = PAGE_READONLY_EXEC,
31349 - .vm_flags = VM_READ | VM_EXEC
31350 + .vm_page_prot = PAGE_READONLY,
31351 + .vm_flags = VM_READ
31352 };
31353
31354 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31355 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31356
31357 const char *arch_vma_name(struct vm_area_struct *vma)
31358 {
31359 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31360 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31361 return "[vdso]";
31362 if (vma == &gate_vma)
31363 return "[vsyscall]";
31364 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31365 index 7b179b4..6bd17777 100644
31366 --- a/arch/x86/mm/iomap_32.c
31367 +++ b/arch/x86/mm/iomap_32.c
31368 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31369 type = kmap_atomic_idx_push();
31370 idx = type + KM_TYPE_NR * smp_processor_id();
31371 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31372 +
31373 + pax_open_kernel();
31374 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31375 + pax_close_kernel();
31376 +
31377 arch_flush_lazy_mmu_mode();
31378
31379 return (void *)vaddr;
31380 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31381 index 0215e2c..1c62dab 100644
31382 --- a/arch/x86/mm/ioremap.c
31383 +++ b/arch/x86/mm/ioremap.c
31384 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31385 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31386 int is_ram = page_is_ram(pfn);
31387
31388 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31389 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31390 return NULL;
31391 WARN_ON_ONCE(is_ram);
31392 }
31393 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31394 *
31395 * Caller must ensure there is only one unmapping for the same pointer.
31396 */
31397 -void iounmap(volatile void __iomem *addr)
31398 +void iounmap(const volatile void __iomem *addr)
31399 {
31400 struct vm_struct *p, *o;
31401
31402 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31403
31404 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31405 if (page_is_ram(start >> PAGE_SHIFT))
31406 +#ifdef CONFIG_HIGHMEM
31407 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31408 +#endif
31409 return __va(phys);
31410
31411 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31412 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31413 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31414 {
31415 if (page_is_ram(phys >> PAGE_SHIFT))
31416 +#ifdef CONFIG_HIGHMEM
31417 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31418 +#endif
31419 return;
31420
31421 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31422 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31423 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31424
31425 static __initdata int after_paging_init;
31426 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31427 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31428
31429 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31430 {
31431 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31432 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31433
31434 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31435 - memset(bm_pte, 0, sizeof(bm_pte));
31436 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31437 + pmd_populate_user(&init_mm, pmd, bm_pte);
31438
31439 /*
31440 * The boot-ioremap range spans multiple pmds, for which
31441 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31442 index d87dd6d..bf3fa66 100644
31443 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31444 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31445 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31446 * memory (e.g. tracked pages)? For now, we need this to avoid
31447 * invoking kmemcheck for PnP BIOS calls.
31448 */
31449 - if (regs->flags & X86_VM_MASK)
31450 + if (v8086_mode(regs))
31451 return false;
31452 - if (regs->cs != __KERNEL_CS)
31453 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31454 return false;
31455
31456 pte = kmemcheck_pte_lookup(address);
31457 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31458 index 25e7e13..1964579 100644
31459 --- a/arch/x86/mm/mmap.c
31460 +++ b/arch/x86/mm/mmap.c
31461 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31462 * Leave an at least ~128 MB hole with possible stack randomization.
31463 */
31464 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31465 -#define MAX_GAP (TASK_SIZE/6*5)
31466 +#define MAX_GAP (pax_task_size/6*5)
31467
31468 static int mmap_is_legacy(void)
31469 {
31470 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31471 return rnd << PAGE_SHIFT;
31472 }
31473
31474 -static unsigned long mmap_base(void)
31475 +static unsigned long mmap_base(struct mm_struct *mm)
31476 {
31477 unsigned long gap = rlimit(RLIMIT_STACK);
31478 + unsigned long pax_task_size = TASK_SIZE;
31479 +
31480 +#ifdef CONFIG_PAX_SEGMEXEC
31481 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31482 + pax_task_size = SEGMEXEC_TASK_SIZE;
31483 +#endif
31484
31485 if (gap < MIN_GAP)
31486 gap = MIN_GAP;
31487 else if (gap > MAX_GAP)
31488 gap = MAX_GAP;
31489
31490 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31491 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31492 }
31493
31494 /*
31495 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31496 * does, but not when emulating X86_32
31497 */
31498 -static unsigned long mmap_legacy_base(void)
31499 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31500 {
31501 - if (mmap_is_ia32())
31502 + if (mmap_is_ia32()) {
31503 +
31504 +#ifdef CONFIG_PAX_SEGMEXEC
31505 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31506 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31507 + else
31508 +#endif
31509 +
31510 return TASK_UNMAPPED_BASE;
31511 - else
31512 + } else
31513 return TASK_UNMAPPED_BASE + mmap_rnd();
31514 }
31515
31516 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31517 */
31518 void arch_pick_mmap_layout(struct mm_struct *mm)
31519 {
31520 - mm->mmap_legacy_base = mmap_legacy_base();
31521 - mm->mmap_base = mmap_base();
31522 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31523 + mm->mmap_base = mmap_base(mm);
31524 +
31525 +#ifdef CONFIG_PAX_RANDMMAP
31526 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31527 + mm->mmap_legacy_base += mm->delta_mmap;
31528 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31529 + }
31530 +#endif
31531
31532 if (mmap_is_legacy()) {
31533 mm->mmap_base = mm->mmap_legacy_base;
31534 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31535 index 0057a7a..95c7edd 100644
31536 --- a/arch/x86/mm/mmio-mod.c
31537 +++ b/arch/x86/mm/mmio-mod.c
31538 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31539 break;
31540 default:
31541 {
31542 - unsigned char *ip = (unsigned char *)instptr;
31543 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31544 my_trace->opcode = MMIO_UNKNOWN_OP;
31545 my_trace->width = 0;
31546 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31547 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31548 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31549 void __iomem *addr)
31550 {
31551 - static atomic_t next_id;
31552 + static atomic_unchecked_t next_id;
31553 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31554 /* These are page-unaligned. */
31555 struct mmiotrace_map map = {
31556 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31557 .private = trace
31558 },
31559 .phys = offset,
31560 - .id = atomic_inc_return(&next_id)
31561 + .id = atomic_inc_return_unchecked(&next_id)
31562 };
31563 map.map_id = trace->id;
31564
31565 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31566 ioremap_trace_core(offset, size, addr);
31567 }
31568
31569 -static void iounmap_trace_core(volatile void __iomem *addr)
31570 +static void iounmap_trace_core(const volatile void __iomem *addr)
31571 {
31572 struct mmiotrace_map map = {
31573 .phys = 0,
31574 @@ -328,7 +328,7 @@ not_enabled:
31575 }
31576 }
31577
31578 -void mmiotrace_iounmap(volatile void __iomem *addr)
31579 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31580 {
31581 might_sleep();
31582 if (is_enabled()) /* recheck and proper locking in *_core() */
31583 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31584 index 8bf93ba..dbcd670 100644
31585 --- a/arch/x86/mm/numa.c
31586 +++ b/arch/x86/mm/numa.c
31587 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31588 return true;
31589 }
31590
31591 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31592 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31593 {
31594 unsigned long uninitialized_var(pfn_align);
31595 int i, nid;
31596 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31597 index d0b1773..4c3327c 100644
31598 --- a/arch/x86/mm/pageattr-test.c
31599 +++ b/arch/x86/mm/pageattr-test.c
31600 @@ -36,7 +36,7 @@ enum {
31601
31602 static int pte_testbit(pte_t pte)
31603 {
31604 - return pte_flags(pte) & _PAGE_UNUSED1;
31605 + return pte_flags(pte) & _PAGE_CPA_TEST;
31606 }
31607
31608 struct split_state {
31609 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31610 index bb32480..75f2f5e 100644
31611 --- a/arch/x86/mm/pageattr.c
31612 +++ b/arch/x86/mm/pageattr.c
31613 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31614 */
31615 #ifdef CONFIG_PCI_BIOS
31616 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31617 - pgprot_val(forbidden) |= _PAGE_NX;
31618 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31619 #endif
31620
31621 /*
31622 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31623 * Does not cover __inittext since that is gone later on. On
31624 * 64bit we do not enforce !NX on the low mapping
31625 */
31626 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31627 - pgprot_val(forbidden) |= _PAGE_NX;
31628 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31629 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31630
31631 +#ifdef CONFIG_DEBUG_RODATA
31632 /*
31633 * The .rodata section needs to be read-only. Using the pfn
31634 * catches all aliases.
31635 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31636 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31637 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31638 pgprot_val(forbidden) |= _PAGE_RW;
31639 +#endif
31640
31641 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31642 /*
31643 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31644 }
31645 #endif
31646
31647 +#ifdef CONFIG_PAX_KERNEXEC
31648 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31649 + pgprot_val(forbidden) |= _PAGE_RW;
31650 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31651 + }
31652 +#endif
31653 +
31654 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31655
31656 return prot;
31657 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31658 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31659 {
31660 /* change init_mm */
31661 + pax_open_kernel();
31662 set_pte_atomic(kpte, pte);
31663 +
31664 #ifdef CONFIG_X86_32
31665 if (!SHARED_KERNEL_PMD) {
31666 +
31667 +#ifdef CONFIG_PAX_PER_CPU_PGD
31668 + unsigned long cpu;
31669 +#else
31670 struct page *page;
31671 +#endif
31672
31673 +#ifdef CONFIG_PAX_PER_CPU_PGD
31674 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31675 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31676 +#else
31677 list_for_each_entry(page, &pgd_list, lru) {
31678 - pgd_t *pgd;
31679 + pgd_t *pgd = (pgd_t *)page_address(page);
31680 +#endif
31681 +
31682 pud_t *pud;
31683 pmd_t *pmd;
31684
31685 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31686 + pgd += pgd_index(address);
31687 pud = pud_offset(pgd, address);
31688 pmd = pmd_offset(pud, address);
31689 set_pte_atomic((pte_t *)pmd, pte);
31690 }
31691 }
31692 #endif
31693 + pax_close_kernel();
31694 }
31695
31696 static int
31697 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31698 index 6574388..87e9bef 100644
31699 --- a/arch/x86/mm/pat.c
31700 +++ b/arch/x86/mm/pat.c
31701 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31702
31703 if (!entry) {
31704 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31705 - current->comm, current->pid, start, end - 1);
31706 + current->comm, task_pid_nr(current), start, end - 1);
31707 return -EINVAL;
31708 }
31709
31710 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31711
31712 while (cursor < to) {
31713 if (!devmem_is_allowed(pfn)) {
31714 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31715 - current->comm, from, to - 1);
31716 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31717 + current->comm, from, to - 1, cursor);
31718 return 0;
31719 }
31720 cursor += PAGE_SIZE;
31721 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31722 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31723 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31724 "for [mem %#010Lx-%#010Lx]\n",
31725 - current->comm, current->pid,
31726 + current->comm, task_pid_nr(current),
31727 cattr_name(flags),
31728 base, (unsigned long long)(base + size-1));
31729 return -EINVAL;
31730 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31731 flags = lookup_memtype(paddr);
31732 if (want_flags != flags) {
31733 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31734 - current->comm, current->pid,
31735 + current->comm, task_pid_nr(current),
31736 cattr_name(want_flags),
31737 (unsigned long long)paddr,
31738 (unsigned long long)(paddr + size - 1),
31739 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31740 free_memtype(paddr, paddr + size);
31741 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31742 " for [mem %#010Lx-%#010Lx], got %s\n",
31743 - current->comm, current->pid,
31744 + current->comm, task_pid_nr(current),
31745 cattr_name(want_flags),
31746 (unsigned long long)paddr,
31747 (unsigned long long)(paddr + size - 1),
31748 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31749 index 415f6c4..d319983 100644
31750 --- a/arch/x86/mm/pat_rbtree.c
31751 +++ b/arch/x86/mm/pat_rbtree.c
31752 @@ -160,7 +160,7 @@ success:
31753
31754 failure:
31755 printk(KERN_INFO "%s:%d conflicting memory types "
31756 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31757 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31758 end, cattr_name(found_type), cattr_name(match->type));
31759 return -EBUSY;
31760 }
31761 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31762 index 9f0614d..92ae64a 100644
31763 --- a/arch/x86/mm/pf_in.c
31764 +++ b/arch/x86/mm/pf_in.c
31765 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31766 int i;
31767 enum reason_type rv = OTHERS;
31768
31769 - p = (unsigned char *)ins_addr;
31770 + p = (unsigned char *)ktla_ktva(ins_addr);
31771 p += skip_prefix(p, &prf);
31772 p += get_opcode(p, &opcode);
31773
31774 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31775 struct prefix_bits prf;
31776 int i;
31777
31778 - p = (unsigned char *)ins_addr;
31779 + p = (unsigned char *)ktla_ktva(ins_addr);
31780 p += skip_prefix(p, &prf);
31781 p += get_opcode(p, &opcode);
31782
31783 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31784 struct prefix_bits prf;
31785 int i;
31786
31787 - p = (unsigned char *)ins_addr;
31788 + p = (unsigned char *)ktla_ktva(ins_addr);
31789 p += skip_prefix(p, &prf);
31790 p += get_opcode(p, &opcode);
31791
31792 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31793 struct prefix_bits prf;
31794 int i;
31795
31796 - p = (unsigned char *)ins_addr;
31797 + p = (unsigned char *)ktla_ktva(ins_addr);
31798 p += skip_prefix(p, &prf);
31799 p += get_opcode(p, &opcode);
31800 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31801 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31802 struct prefix_bits prf;
31803 int i;
31804
31805 - p = (unsigned char *)ins_addr;
31806 + p = (unsigned char *)ktla_ktva(ins_addr);
31807 p += skip_prefix(p, &prf);
31808 p += get_opcode(p, &opcode);
31809 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31810 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31811 index dfa537a..fd45c64 100644
31812 --- a/arch/x86/mm/pgtable.c
31813 +++ b/arch/x86/mm/pgtable.c
31814 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31815 list_del(&page->lru);
31816 }
31817
31818 -#define UNSHARED_PTRS_PER_PGD \
31819 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31820 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31821 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31822
31823 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31824 +{
31825 + unsigned int count = USER_PGD_PTRS;
31826
31827 + if (!pax_user_shadow_base)
31828 + return;
31829 +
31830 + while (count--)
31831 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31832 +}
31833 +#endif
31834 +
31835 +#ifdef CONFIG_PAX_PER_CPU_PGD
31836 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31837 +{
31838 + unsigned int count = USER_PGD_PTRS;
31839 +
31840 + while (count--) {
31841 + pgd_t pgd;
31842 +
31843 +#ifdef CONFIG_X86_64
31844 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31845 +#else
31846 + pgd = *src++;
31847 +#endif
31848 +
31849 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31850 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31851 +#endif
31852 +
31853 + *dst++ = pgd;
31854 + }
31855 +
31856 +}
31857 +#endif
31858 +
31859 +#ifdef CONFIG_X86_64
31860 +#define pxd_t pud_t
31861 +#define pyd_t pgd_t
31862 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31863 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31864 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31865 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31866 +#define PYD_SIZE PGDIR_SIZE
31867 +#else
31868 +#define pxd_t pmd_t
31869 +#define pyd_t pud_t
31870 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31871 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31872 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31873 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31874 +#define PYD_SIZE PUD_SIZE
31875 +#endif
31876 +
31877 +#ifdef CONFIG_PAX_PER_CPU_PGD
31878 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31879 +static inline void pgd_dtor(pgd_t *pgd) {}
31880 +#else
31881 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31882 {
31883 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31884 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31885 pgd_list_del(pgd);
31886 spin_unlock(&pgd_lock);
31887 }
31888 +#endif
31889
31890 /*
31891 * List of all pgd's needed for non-PAE so it can invalidate entries
31892 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31893 * -- nyc
31894 */
31895
31896 -#ifdef CONFIG_X86_PAE
31897 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31898 /*
31899 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31900 * updating the top-level pagetable entries to guarantee the
31901 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31902 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31903 * and initialize the kernel pmds here.
31904 */
31905 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31906 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31907
31908 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31909 {
31910 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31911 */
31912 flush_tlb_mm(mm);
31913 }
31914 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31915 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31916 #else /* !CONFIG_X86_PAE */
31917
31918 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31919 -#define PREALLOCATED_PMDS 0
31920 +#define PREALLOCATED_PXDS 0
31921
31922 #endif /* CONFIG_X86_PAE */
31923
31924 -static void free_pmds(pmd_t *pmds[])
31925 +static void free_pxds(pxd_t *pxds[])
31926 {
31927 int i;
31928
31929 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31930 - if (pmds[i])
31931 - free_page((unsigned long)pmds[i]);
31932 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31933 + if (pxds[i])
31934 + free_page((unsigned long)pxds[i]);
31935 }
31936
31937 -static int preallocate_pmds(pmd_t *pmds[])
31938 +static int preallocate_pxds(pxd_t *pxds[])
31939 {
31940 int i;
31941 bool failed = false;
31942
31943 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31944 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31945 - if (pmd == NULL)
31946 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31947 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31948 + if (pxd == NULL)
31949 failed = true;
31950 - pmds[i] = pmd;
31951 + pxds[i] = pxd;
31952 }
31953
31954 if (failed) {
31955 - free_pmds(pmds);
31956 + free_pxds(pxds);
31957 return -ENOMEM;
31958 }
31959
31960 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31961 * preallocate which never got a corresponding vma will need to be
31962 * freed manually.
31963 */
31964 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31965 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31966 {
31967 int i;
31968
31969 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31970 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31971 pgd_t pgd = pgdp[i];
31972
31973 if (pgd_val(pgd) != 0) {
31974 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31975 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31976
31977 - pgdp[i] = native_make_pgd(0);
31978 + set_pgd(pgdp + i, native_make_pgd(0));
31979
31980 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31981 - pmd_free(mm, pmd);
31982 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31983 + pxd_free(mm, pxd);
31984 }
31985 }
31986 }
31987
31988 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31989 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31990 {
31991 - pud_t *pud;
31992 + pyd_t *pyd;
31993 int i;
31994
31995 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31996 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31997 return;
31998
31999 - pud = pud_offset(pgd, 0);
32000 -
32001 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32002 - pmd_t *pmd = pmds[i];
32003 +#ifdef CONFIG_X86_64
32004 + pyd = pyd_offset(mm, 0L);
32005 +#else
32006 + pyd = pyd_offset(pgd, 0L);
32007 +#endif
32008
32009 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32010 + pxd_t *pxd = pxds[i];
32011 if (i >= KERNEL_PGD_BOUNDARY)
32012 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32013 - sizeof(pmd_t) * PTRS_PER_PMD);
32014 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32015 + sizeof(pxd_t) * PTRS_PER_PMD);
32016
32017 - pud_populate(mm, pud, pmd);
32018 + pyd_populate(mm, pyd, pxd);
32019 }
32020 }
32021
32022 pgd_t *pgd_alloc(struct mm_struct *mm)
32023 {
32024 pgd_t *pgd;
32025 - pmd_t *pmds[PREALLOCATED_PMDS];
32026 + pxd_t *pxds[PREALLOCATED_PXDS];
32027
32028 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32029
32030 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32031
32032 mm->pgd = pgd;
32033
32034 - if (preallocate_pmds(pmds) != 0)
32035 + if (preallocate_pxds(pxds) != 0)
32036 goto out_free_pgd;
32037
32038 if (paravirt_pgd_alloc(mm) != 0)
32039 - goto out_free_pmds;
32040 + goto out_free_pxds;
32041
32042 /*
32043 * Make sure that pre-populating the pmds is atomic with
32044 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32045 spin_lock(&pgd_lock);
32046
32047 pgd_ctor(mm, pgd);
32048 - pgd_prepopulate_pmd(mm, pgd, pmds);
32049 + pgd_prepopulate_pxd(mm, pgd, pxds);
32050
32051 spin_unlock(&pgd_lock);
32052
32053 return pgd;
32054
32055 -out_free_pmds:
32056 - free_pmds(pmds);
32057 +out_free_pxds:
32058 + free_pxds(pxds);
32059 out_free_pgd:
32060 free_page((unsigned long)pgd);
32061 out:
32062 @@ -300,7 +363,7 @@ out:
32063
32064 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32065 {
32066 - pgd_mop_up_pmds(mm, pgd);
32067 + pgd_mop_up_pxds(mm, pgd);
32068 pgd_dtor(pgd);
32069 paravirt_pgd_free(mm, pgd);
32070 free_page((unsigned long)pgd);
32071 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32072 index a69bcb8..19068ab 100644
32073 --- a/arch/x86/mm/pgtable_32.c
32074 +++ b/arch/x86/mm/pgtable_32.c
32075 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32076 return;
32077 }
32078 pte = pte_offset_kernel(pmd, vaddr);
32079 +
32080 + pax_open_kernel();
32081 if (pte_val(pteval))
32082 set_pte_at(&init_mm, vaddr, pte, pteval);
32083 else
32084 pte_clear(&init_mm, vaddr, pte);
32085 + pax_close_kernel();
32086
32087 /*
32088 * It's enough to flush this one mapping.
32089 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32090 index e666cbb..61788c45 100644
32091 --- a/arch/x86/mm/physaddr.c
32092 +++ b/arch/x86/mm/physaddr.c
32093 @@ -10,7 +10,7 @@
32094 #ifdef CONFIG_X86_64
32095
32096 #ifdef CONFIG_DEBUG_VIRTUAL
32097 -unsigned long __phys_addr(unsigned long x)
32098 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32099 {
32100 unsigned long y = x - __START_KERNEL_map;
32101
32102 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32103 #else
32104
32105 #ifdef CONFIG_DEBUG_VIRTUAL
32106 -unsigned long __phys_addr(unsigned long x)
32107 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32108 {
32109 unsigned long phys_addr = x - PAGE_OFFSET;
32110 /* VMALLOC_* aren't constants */
32111 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32112 index 90555bf..f5f1828 100644
32113 --- a/arch/x86/mm/setup_nx.c
32114 +++ b/arch/x86/mm/setup_nx.c
32115 @@ -5,8 +5,10 @@
32116 #include <asm/pgtable.h>
32117 #include <asm/proto.h>
32118
32119 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32120 static int disable_nx;
32121
32122 +#ifndef CONFIG_PAX_PAGEEXEC
32123 /*
32124 * noexec = on|off
32125 *
32126 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32127 return 0;
32128 }
32129 early_param("noexec", noexec_setup);
32130 +#endif
32131 +
32132 +#endif
32133
32134 void x86_configure_nx(void)
32135 {
32136 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32137 if (cpu_has_nx && !disable_nx)
32138 __supported_pte_mask |= _PAGE_NX;
32139 else
32140 +#endif
32141 __supported_pte_mask &= ~_PAGE_NX;
32142 }
32143
32144 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32145 index 282375f..e03a98f 100644
32146 --- a/arch/x86/mm/tlb.c
32147 +++ b/arch/x86/mm/tlb.c
32148 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32149 BUG();
32150 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32151 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32152 +
32153 +#ifndef CONFIG_PAX_PER_CPU_PGD
32154 load_cr3(swapper_pg_dir);
32155 +#endif
32156 +
32157 }
32158 }
32159 EXPORT_SYMBOL_GPL(leave_mm);
32160 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32161 new file mode 100644
32162 index 0000000..dace51c
32163 --- /dev/null
32164 +++ b/arch/x86/mm/uderef_64.c
32165 @@ -0,0 +1,37 @@
32166 +#include <linux/mm.h>
32167 +#include <asm/pgtable.h>
32168 +#include <asm/uaccess.h>
32169 +
32170 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32171 +/* PaX: due to the special call convention these functions must
32172 + * - remain leaf functions under all configurations,
32173 + * - never be called directly, only dereferenced from the wrappers.
32174 + */
32175 +void __pax_open_userland(void)
32176 +{
32177 + unsigned int cpu;
32178 +
32179 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32180 + return;
32181 +
32182 + cpu = raw_get_cpu();
32183 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32184 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32185 + raw_put_cpu_no_resched();
32186 +}
32187 +EXPORT_SYMBOL(__pax_open_userland);
32188 +
32189 +void __pax_close_userland(void)
32190 +{
32191 + unsigned int cpu;
32192 +
32193 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32194 + return;
32195 +
32196 + cpu = raw_get_cpu();
32197 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32198 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32199 + raw_put_cpu_no_resched();
32200 +}
32201 +EXPORT_SYMBOL(__pax_close_userland);
32202 +#endif
32203 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32204 index 877b9a1..a8ecf42 100644
32205 --- a/arch/x86/net/bpf_jit.S
32206 +++ b/arch/x86/net/bpf_jit.S
32207 @@ -9,6 +9,7 @@
32208 */
32209 #include <linux/linkage.h>
32210 #include <asm/dwarf2.h>
32211 +#include <asm/alternative-asm.h>
32212
32213 /*
32214 * Calling convention :
32215 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32216 jle bpf_slow_path_word
32217 mov (SKBDATA,%rsi),%eax
32218 bswap %eax /* ntohl() */
32219 + pax_force_retaddr
32220 ret
32221
32222 sk_load_half:
32223 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32224 jle bpf_slow_path_half
32225 movzwl (SKBDATA,%rsi),%eax
32226 rol $8,%ax # ntohs()
32227 + pax_force_retaddr
32228 ret
32229
32230 sk_load_byte:
32231 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32232 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32233 jle bpf_slow_path_byte
32234 movzbl (SKBDATA,%rsi),%eax
32235 + pax_force_retaddr
32236 ret
32237
32238 /**
32239 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32240 movzbl (SKBDATA,%rsi),%ebx
32241 and $15,%bl
32242 shl $2,%bl
32243 + pax_force_retaddr
32244 ret
32245
32246 /* rsi contains offset and can be scratched */
32247 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32248 js bpf_error
32249 mov -12(%rbp),%eax
32250 bswap %eax
32251 + pax_force_retaddr
32252 ret
32253
32254 bpf_slow_path_half:
32255 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32256 mov -12(%rbp),%ax
32257 rol $8,%ax
32258 movzwl %ax,%eax
32259 + pax_force_retaddr
32260 ret
32261
32262 bpf_slow_path_byte:
32263 bpf_slow_path_common(1)
32264 js bpf_error
32265 movzbl -12(%rbp),%eax
32266 + pax_force_retaddr
32267 ret
32268
32269 bpf_slow_path_byte_msh:
32270 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32271 and $15,%al
32272 shl $2,%al
32273 xchg %eax,%ebx
32274 + pax_force_retaddr
32275 ret
32276
32277 #define sk_negative_common(SIZE) \
32278 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32279 sk_negative_common(4)
32280 mov (%rax), %eax
32281 bswap %eax
32282 + pax_force_retaddr
32283 ret
32284
32285 bpf_slow_path_half_neg:
32286 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32287 mov (%rax),%ax
32288 rol $8,%ax
32289 movzwl %ax,%eax
32290 + pax_force_retaddr
32291 ret
32292
32293 bpf_slow_path_byte_neg:
32294 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32295 .globl sk_load_byte_negative_offset
32296 sk_negative_common(1)
32297 movzbl (%rax), %eax
32298 + pax_force_retaddr
32299 ret
32300
32301 bpf_slow_path_byte_msh_neg:
32302 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32303 and $15,%al
32304 shl $2,%al
32305 xchg %eax,%ebx
32306 + pax_force_retaddr
32307 ret
32308
32309 bpf_error:
32310 @@ -197,4 +210,5 @@ bpf_error:
32311 xor %eax,%eax
32312 mov -8(%rbp),%rbx
32313 leaveq
32314 + pax_force_retaddr
32315 ret
32316 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32317 index 79c216a..08d39cc 100644
32318 --- a/arch/x86/net/bpf_jit_comp.c
32319 +++ b/arch/x86/net/bpf_jit_comp.c
32320 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32321 return ptr + len;
32322 }
32323
32324 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32325 +#define MAX_INSTR_CODE_SIZE 96
32326 +#else
32327 +#define MAX_INSTR_CODE_SIZE 64
32328 +#endif
32329 +
32330 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32331
32332 #define EMIT1(b1) EMIT(b1, 1)
32333 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32334 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32335 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32336 +
32337 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32338 +/* original constant will appear in ecx */
32339 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32340 +do { \
32341 + /* mov ecx, randkey */ \
32342 + EMIT1(0xb9); \
32343 + EMIT(_key, 4); \
32344 + /* xor ecx, randkey ^ off */ \
32345 + EMIT2(0x81, 0xf1); \
32346 + EMIT((_key) ^ (_off), 4); \
32347 +} while (0)
32348 +
32349 +#define EMIT1_off32(b1, _off) \
32350 +do { \
32351 + switch (b1) { \
32352 + case 0x05: /* add eax, imm32 */ \
32353 + case 0x2d: /* sub eax, imm32 */ \
32354 + case 0x25: /* and eax, imm32 */ \
32355 + case 0x0d: /* or eax, imm32 */ \
32356 + case 0xb8: /* mov eax, imm32 */ \
32357 + case 0x35: /* xor eax, imm32 */ \
32358 + case 0x3d: /* cmp eax, imm32 */ \
32359 + case 0xa9: /* test eax, imm32 */ \
32360 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32361 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32362 + break; \
32363 + case 0xbb: /* mov ebx, imm32 */ \
32364 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32365 + /* mov ebx, ecx */ \
32366 + EMIT2(0x89, 0xcb); \
32367 + break; \
32368 + case 0xbe: /* mov esi, imm32 */ \
32369 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32370 + /* mov esi, ecx */ \
32371 + EMIT2(0x89, 0xce); \
32372 + break; \
32373 + case 0xe8: /* call rel imm32, always to known funcs */ \
32374 + EMIT1(b1); \
32375 + EMIT(_off, 4); \
32376 + break; \
32377 + case 0xe9: /* jmp rel imm32 */ \
32378 + EMIT1(b1); \
32379 + EMIT(_off, 4); \
32380 + /* prevent fall-through, we're not called if off = 0 */ \
32381 + EMIT(0xcccccccc, 4); \
32382 + EMIT(0xcccccccc, 4); \
32383 + break; \
32384 + default: \
32385 + BUILD_BUG(); \
32386 + } \
32387 +} while (0)
32388 +
32389 +#define EMIT2_off32(b1, b2, _off) \
32390 +do { \
32391 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32392 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32393 + EMIT(randkey, 4); \
32394 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32395 + EMIT((_off) - randkey, 4); \
32396 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32397 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32398 + /* imul eax, ecx */ \
32399 + EMIT3(0x0f, 0xaf, 0xc1); \
32400 + } else { \
32401 + BUILD_BUG(); \
32402 + } \
32403 +} while (0)
32404 +#else
32405 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32406 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32407 +#endif
32408
32409 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32410 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32411 @@ -91,6 +168,24 @@ do { \
32412 #define X86_JBE 0x76
32413 #define X86_JA 0x77
32414
32415 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32416 +#define APPEND_FLOW_VERIFY() \
32417 +do { \
32418 + /* mov ecx, randkey */ \
32419 + EMIT1(0xb9); \
32420 + EMIT(randkey, 4); \
32421 + /* cmp ecx, randkey */ \
32422 + EMIT2(0x81, 0xf9); \
32423 + EMIT(randkey, 4); \
32424 + /* jz after 8 int 3s */ \
32425 + EMIT2(0x74, 0x08); \
32426 + EMIT(0xcccccccc, 4); \
32427 + EMIT(0xcccccccc, 4); \
32428 +} while (0)
32429 +#else
32430 +#define APPEND_FLOW_VERIFY() do { } while (0)
32431 +#endif
32432 +
32433 #define EMIT_COND_JMP(op, offset) \
32434 do { \
32435 if (is_near(offset)) \
32436 @@ -98,6 +193,7 @@ do { \
32437 else { \
32438 EMIT2(0x0f, op + 0x10); \
32439 EMIT(offset, 4); /* jxx .+off32 */ \
32440 + APPEND_FLOW_VERIFY(); \
32441 } \
32442 } while (0)
32443
32444 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32445 return -1;
32446 }
32447
32448 -struct bpf_binary_header {
32449 - unsigned int pages;
32450 - /* Note : for security reasons, bpf code will follow a randomly
32451 - * sized amount of int3 instructions
32452 - */
32453 - u8 image[];
32454 -};
32455 -
32456 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32457 +/* Note : for security reasons, bpf code will follow a randomly
32458 + * sized amount of int3 instructions
32459 + */
32460 +static u8 *bpf_alloc_binary(unsigned int proglen,
32461 u8 **image_ptr)
32462 {
32463 unsigned int sz, hole;
32464 - struct bpf_binary_header *header;
32465 + u8 *header;
32466
32467 /* Most of BPF filters are really small,
32468 * but if some of them fill a page, allow at least
32469 * 128 extra bytes to insert a random section of int3
32470 */
32471 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32472 - header = module_alloc(sz);
32473 + sz = round_up(proglen + 128, PAGE_SIZE);
32474 + header = module_alloc_exec(sz);
32475 if (!header)
32476 return NULL;
32477
32478 + pax_open_kernel();
32479 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32480 + pax_close_kernel();
32481
32482 - header->pages = sz / PAGE_SIZE;
32483 - hole = sz - (proglen + sizeof(*header));
32484 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32485
32486 /* insert a random number of int3 instructions before BPF code */
32487 - *image_ptr = &header->image[prandom_u32() % hole];
32488 + *image_ptr = &header[prandom_u32() % hole];
32489 return header;
32490 }
32491
32492 void bpf_jit_compile(struct sk_filter *fp)
32493 {
32494 - u8 temp[64];
32495 + u8 temp[MAX_INSTR_CODE_SIZE];
32496 u8 *prog;
32497 unsigned int proglen, oldproglen = 0;
32498 int ilen, i;
32499 int t_offset, f_offset;
32500 u8 t_op, f_op, seen = 0, pass;
32501 u8 *image = NULL;
32502 - struct bpf_binary_header *header = NULL;
32503 + u8 *header = NULL;
32504 u8 *func;
32505 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32506 unsigned int cleanup_addr; /* epilogue code offset */
32507 unsigned int *addrs;
32508 const struct sock_filter *filter = fp->insns;
32509 int flen = fp->len;
32510 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32511 + unsigned int randkey;
32512 +#endif
32513
32514 if (!bpf_jit_enable)
32515 return;
32516 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32517 if (addrs == NULL)
32518 return;
32519
32520 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32521 + randkey = get_random_int();
32522 +#endif
32523 +
32524 /* Before first pass, make a rough estimation of addrs[]
32525 - * each bpf instruction is translated to less than 64 bytes
32526 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32527 */
32528 for (proglen = 0, i = 0; i < flen; i++) {
32529 - proglen += 64;
32530 + proglen += MAX_INSTR_CODE_SIZE;
32531 addrs[i] = proglen;
32532 }
32533 cleanup_addr = proglen; /* epilogue address */
32534 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32535 case BPF_S_ALU_MUL_K: /* A *= K */
32536 if (is_imm8(K))
32537 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32538 - else {
32539 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32540 - EMIT(K, 4);
32541 - }
32542 + else
32543 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32544 break;
32545 case BPF_S_ALU_DIV_X: /* A /= X; */
32546 seen |= SEEN_XREG;
32547 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32548 break;
32549 case BPF_S_ALU_MOD_K: /* A %= K; */
32550 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32551 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32552 + DILUTE_CONST_SEQUENCE(K, randkey);
32553 +#else
32554 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32555 +#endif
32556 EMIT2(0xf7, 0xf1); /* div %ecx */
32557 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32558 break;
32559 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32560 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32561 + DILUTE_CONST_SEQUENCE(K, randkey);
32562 + // imul rax, rcx
32563 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32564 +#else
32565 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32566 EMIT(K, 4);
32567 +#endif
32568 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32569 break;
32570 case BPF_S_ALU_AND_X:
32571 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32572 if (is_imm8(K)) {
32573 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32574 } else {
32575 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32576 - EMIT(K, 4);
32577 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32578 }
32579 } else {
32580 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32581 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32582 if (unlikely(proglen + ilen > oldproglen)) {
32583 pr_err("bpb_jit_compile fatal error\n");
32584 kfree(addrs);
32585 - module_free(NULL, header);
32586 + module_free_exec(NULL, image);
32587 return;
32588 }
32589 + pax_open_kernel();
32590 memcpy(image + proglen, temp, ilen);
32591 + pax_close_kernel();
32592 }
32593 proglen += ilen;
32594 addrs[i] = proglen;
32595 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32596
32597 if (image) {
32598 bpf_flush_icache(header, image + proglen);
32599 - set_memory_ro((unsigned long)header, header->pages);
32600 fp->bpf_func = (void *)image;
32601 }
32602 out:
32603 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32604 {
32605 if (fp->bpf_func != sk_run_filter) {
32606 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32607 - struct bpf_binary_header *header = (void *)addr;
32608 -
32609 - set_memory_rw(addr, header->pages);
32610 - module_free(NULL, header);
32611 + set_memory_rw(addr, 1);
32612 + module_free_exec(NULL, (void *)addr);
32613 }
32614 }
32615 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32616 index d6aa6e8..266395a 100644
32617 --- a/arch/x86/oprofile/backtrace.c
32618 +++ b/arch/x86/oprofile/backtrace.c
32619 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32620 struct stack_frame_ia32 *fp;
32621 unsigned long bytes;
32622
32623 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32624 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32625 if (bytes != sizeof(bufhead))
32626 return NULL;
32627
32628 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32629 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32630
32631 oprofile_add_trace(bufhead[0].return_address);
32632
32633 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32634 struct stack_frame bufhead[2];
32635 unsigned long bytes;
32636
32637 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32638 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32639 if (bytes != sizeof(bufhead))
32640 return NULL;
32641
32642 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32643 {
32644 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32645
32646 - if (!user_mode_vm(regs)) {
32647 + if (!user_mode(regs)) {
32648 unsigned long stack = kernel_stack_pointer(regs);
32649 if (depth)
32650 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32651 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32652 index 48768df..ba9143c 100644
32653 --- a/arch/x86/oprofile/nmi_int.c
32654 +++ b/arch/x86/oprofile/nmi_int.c
32655 @@ -23,6 +23,7 @@
32656 #include <asm/nmi.h>
32657 #include <asm/msr.h>
32658 #include <asm/apic.h>
32659 +#include <asm/pgtable.h>
32660
32661 #include "op_counter.h"
32662 #include "op_x86_model.h"
32663 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32664 if (ret)
32665 return ret;
32666
32667 - if (!model->num_virt_counters)
32668 - model->num_virt_counters = model->num_counters;
32669 + if (!model->num_virt_counters) {
32670 + pax_open_kernel();
32671 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32672 + pax_close_kernel();
32673 + }
32674
32675 mux_init(ops);
32676
32677 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32678 index b2b9443..be58856 100644
32679 --- a/arch/x86/oprofile/op_model_amd.c
32680 +++ b/arch/x86/oprofile/op_model_amd.c
32681 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32682 num_counters = AMD64_NUM_COUNTERS;
32683 }
32684
32685 - op_amd_spec.num_counters = num_counters;
32686 - op_amd_spec.num_controls = num_counters;
32687 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32688 + pax_open_kernel();
32689 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32690 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32691 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32692 + pax_close_kernel();
32693
32694 return 0;
32695 }
32696 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32697 index d90528e..0127e2b 100644
32698 --- a/arch/x86/oprofile/op_model_ppro.c
32699 +++ b/arch/x86/oprofile/op_model_ppro.c
32700 @@ -19,6 +19,7 @@
32701 #include <asm/msr.h>
32702 #include <asm/apic.h>
32703 #include <asm/nmi.h>
32704 +#include <asm/pgtable.h>
32705
32706 #include "op_x86_model.h"
32707 #include "op_counter.h"
32708 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32709
32710 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32711
32712 - op_arch_perfmon_spec.num_counters = num_counters;
32713 - op_arch_perfmon_spec.num_controls = num_counters;
32714 + pax_open_kernel();
32715 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32716 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32717 + pax_close_kernel();
32718 }
32719
32720 static int arch_perfmon_init(struct oprofile_operations *ignore)
32721 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32722 index 71e8a67..6a313bb 100644
32723 --- a/arch/x86/oprofile/op_x86_model.h
32724 +++ b/arch/x86/oprofile/op_x86_model.h
32725 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32726 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32727 struct op_msrs const * const msrs);
32728 #endif
32729 -};
32730 +} __do_const;
32731
32732 struct op_counter_config;
32733
32734 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32735 index 372e9b8..e775a6c 100644
32736 --- a/arch/x86/pci/irq.c
32737 +++ b/arch/x86/pci/irq.c
32738 @@ -50,7 +50,7 @@ struct irq_router {
32739 struct irq_router_handler {
32740 u16 vendor;
32741 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32742 -};
32743 +} __do_const;
32744
32745 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32746 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32747 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32748 return 0;
32749 }
32750
32751 -static __initdata struct irq_router_handler pirq_routers[] = {
32752 +static __initconst const struct irq_router_handler pirq_routers[] = {
32753 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32754 { PCI_VENDOR_ID_AL, ali_router_probe },
32755 { PCI_VENDOR_ID_ITE, ite_router_probe },
32756 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32757 static void __init pirq_find_router(struct irq_router *r)
32758 {
32759 struct irq_routing_table *rt = pirq_table;
32760 - struct irq_router_handler *h;
32761 + const struct irq_router_handler *h;
32762
32763 #ifdef CONFIG_PCI_BIOS
32764 if (!rt->signature) {
32765 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32766 return 0;
32767 }
32768
32769 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32770 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32771 {
32772 .callback = fix_broken_hp_bios_irq9,
32773 .ident = "HP Pavilion N5400 Series Laptop",
32774 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32775 index 6eb18c4..20d83de 100644
32776 --- a/arch/x86/pci/mrst.c
32777 +++ b/arch/x86/pci/mrst.c
32778 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32779 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32780 pci_mmcfg_late_init();
32781 pcibios_enable_irq = mrst_pci_irq_enable;
32782 - pci_root_ops = pci_mrst_ops;
32783 + pax_open_kernel();
32784 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32785 + pax_close_kernel();
32786 pci_soc_mode = 1;
32787 /* Continue with standard init */
32788 return 1;
32789 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32790 index c77b24a..c979855 100644
32791 --- a/arch/x86/pci/pcbios.c
32792 +++ b/arch/x86/pci/pcbios.c
32793 @@ -79,7 +79,7 @@ union bios32 {
32794 static struct {
32795 unsigned long address;
32796 unsigned short segment;
32797 -} bios32_indirect = { 0, __KERNEL_CS };
32798 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32799
32800 /*
32801 * Returns the entry point for the given service, NULL on error
32802 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32803 unsigned long length; /* %ecx */
32804 unsigned long entry; /* %edx */
32805 unsigned long flags;
32806 + struct desc_struct d, *gdt;
32807
32808 local_irq_save(flags);
32809 - __asm__("lcall *(%%edi); cld"
32810 +
32811 + gdt = get_cpu_gdt_table(smp_processor_id());
32812 +
32813 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32814 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32815 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32816 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32817 +
32818 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32819 : "=a" (return_code),
32820 "=b" (address),
32821 "=c" (length),
32822 "=d" (entry)
32823 : "0" (service),
32824 "1" (0),
32825 - "D" (&bios32_indirect));
32826 + "D" (&bios32_indirect),
32827 + "r"(__PCIBIOS_DS)
32828 + : "memory");
32829 +
32830 + pax_open_kernel();
32831 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32832 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32833 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32834 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32835 + pax_close_kernel();
32836 +
32837 local_irq_restore(flags);
32838
32839 switch (return_code) {
32840 - case 0:
32841 - return address + entry;
32842 - case 0x80: /* Not present */
32843 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32844 - return 0;
32845 - default: /* Shouldn't happen */
32846 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32847 - service, return_code);
32848 + case 0: {
32849 + int cpu;
32850 + unsigned char flags;
32851 +
32852 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32853 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32854 + printk(KERN_WARNING "bios32_service: not valid\n");
32855 return 0;
32856 + }
32857 + address = address + PAGE_OFFSET;
32858 + length += 16UL; /* some BIOSs underreport this... */
32859 + flags = 4;
32860 + if (length >= 64*1024*1024) {
32861 + length >>= PAGE_SHIFT;
32862 + flags |= 8;
32863 + }
32864 +
32865 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32866 + gdt = get_cpu_gdt_table(cpu);
32867 + pack_descriptor(&d, address, length, 0x9b, flags);
32868 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32869 + pack_descriptor(&d, address, length, 0x93, flags);
32870 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32871 + }
32872 + return entry;
32873 + }
32874 + case 0x80: /* Not present */
32875 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32876 + return 0;
32877 + default: /* Shouldn't happen */
32878 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32879 + service, return_code);
32880 + return 0;
32881 }
32882 }
32883
32884 static struct {
32885 unsigned long address;
32886 unsigned short segment;
32887 -} pci_indirect = { 0, __KERNEL_CS };
32888 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32889
32890 -static int pci_bios_present;
32891 +static int pci_bios_present __read_only;
32892
32893 static int check_pcibios(void)
32894 {
32895 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32896 unsigned long flags, pcibios_entry;
32897
32898 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32899 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32900 + pci_indirect.address = pcibios_entry;
32901
32902 local_irq_save(flags);
32903 - __asm__(
32904 - "lcall *(%%edi); cld\n\t"
32905 + __asm__("movw %w6, %%ds\n\t"
32906 + "lcall *%%ss:(%%edi); cld\n\t"
32907 + "push %%ss\n\t"
32908 + "pop %%ds\n\t"
32909 "jc 1f\n\t"
32910 "xor %%ah, %%ah\n"
32911 "1:"
32912 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32913 "=b" (ebx),
32914 "=c" (ecx)
32915 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32916 - "D" (&pci_indirect)
32917 + "D" (&pci_indirect),
32918 + "r" (__PCIBIOS_DS)
32919 : "memory");
32920 local_irq_restore(flags);
32921
32922 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32923
32924 switch (len) {
32925 case 1:
32926 - __asm__("lcall *(%%esi); cld\n\t"
32927 + __asm__("movw %w6, %%ds\n\t"
32928 + "lcall *%%ss:(%%esi); cld\n\t"
32929 + "push %%ss\n\t"
32930 + "pop %%ds\n\t"
32931 "jc 1f\n\t"
32932 "xor %%ah, %%ah\n"
32933 "1:"
32934 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32935 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32936 "b" (bx),
32937 "D" ((long)reg),
32938 - "S" (&pci_indirect));
32939 + "S" (&pci_indirect),
32940 + "r" (__PCIBIOS_DS));
32941 /*
32942 * Zero-extend the result beyond 8 bits, do not trust the
32943 * BIOS having done it:
32944 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32945 *value &= 0xff;
32946 break;
32947 case 2:
32948 - __asm__("lcall *(%%esi); cld\n\t"
32949 + __asm__("movw %w6, %%ds\n\t"
32950 + "lcall *%%ss:(%%esi); cld\n\t"
32951 + "push %%ss\n\t"
32952 + "pop %%ds\n\t"
32953 "jc 1f\n\t"
32954 "xor %%ah, %%ah\n"
32955 "1:"
32956 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32957 : "1" (PCIBIOS_READ_CONFIG_WORD),
32958 "b" (bx),
32959 "D" ((long)reg),
32960 - "S" (&pci_indirect));
32961 + "S" (&pci_indirect),
32962 + "r" (__PCIBIOS_DS));
32963 /*
32964 * Zero-extend the result beyond 16 bits, do not trust the
32965 * BIOS having done it:
32966 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32967 *value &= 0xffff;
32968 break;
32969 case 4:
32970 - __asm__("lcall *(%%esi); cld\n\t"
32971 + __asm__("movw %w6, %%ds\n\t"
32972 + "lcall *%%ss:(%%esi); cld\n\t"
32973 + "push %%ss\n\t"
32974 + "pop %%ds\n\t"
32975 "jc 1f\n\t"
32976 "xor %%ah, %%ah\n"
32977 "1:"
32978 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32979 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32980 "b" (bx),
32981 "D" ((long)reg),
32982 - "S" (&pci_indirect));
32983 + "S" (&pci_indirect),
32984 + "r" (__PCIBIOS_DS));
32985 break;
32986 }
32987
32988 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32989
32990 switch (len) {
32991 case 1:
32992 - __asm__("lcall *(%%esi); cld\n\t"
32993 + __asm__("movw %w6, %%ds\n\t"
32994 + "lcall *%%ss:(%%esi); cld\n\t"
32995 + "push %%ss\n\t"
32996 + "pop %%ds\n\t"
32997 "jc 1f\n\t"
32998 "xor %%ah, %%ah\n"
32999 "1:"
33000 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33001 "c" (value),
33002 "b" (bx),
33003 "D" ((long)reg),
33004 - "S" (&pci_indirect));
33005 + "S" (&pci_indirect),
33006 + "r" (__PCIBIOS_DS));
33007 break;
33008 case 2:
33009 - __asm__("lcall *(%%esi); cld\n\t"
33010 + __asm__("movw %w6, %%ds\n\t"
33011 + "lcall *%%ss:(%%esi); cld\n\t"
33012 + "push %%ss\n\t"
33013 + "pop %%ds\n\t"
33014 "jc 1f\n\t"
33015 "xor %%ah, %%ah\n"
33016 "1:"
33017 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33018 "c" (value),
33019 "b" (bx),
33020 "D" ((long)reg),
33021 - "S" (&pci_indirect));
33022 + "S" (&pci_indirect),
33023 + "r" (__PCIBIOS_DS));
33024 break;
33025 case 4:
33026 - __asm__("lcall *(%%esi); cld\n\t"
33027 + __asm__("movw %w6, %%ds\n\t"
33028 + "lcall *%%ss:(%%esi); cld\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n\t"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33035 "c" (value),
33036 "b" (bx),
33037 "D" ((long)reg),
33038 - "S" (&pci_indirect));
33039 + "S" (&pci_indirect),
33040 + "r" (__PCIBIOS_DS));
33041 break;
33042 }
33043
33044 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33045
33046 DBG("PCI: Fetching IRQ routing table... ");
33047 __asm__("push %%es\n\t"
33048 + "movw %w8, %%ds\n\t"
33049 "push %%ds\n\t"
33050 "pop %%es\n\t"
33051 - "lcall *(%%esi); cld\n\t"
33052 + "lcall *%%ss:(%%esi); cld\n\t"
33053 "pop %%es\n\t"
33054 + "push %%ss\n\t"
33055 + "pop %%ds\n"
33056 "jc 1f\n\t"
33057 "xor %%ah, %%ah\n"
33058 "1:"
33059 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33060 "1" (0),
33061 "D" ((long) &opt),
33062 "S" (&pci_indirect),
33063 - "m" (opt)
33064 + "m" (opt),
33065 + "r" (__PCIBIOS_DS)
33066 : "memory");
33067 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33068 if (ret & 0xff00)
33069 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33070 {
33071 int ret;
33072
33073 - __asm__("lcall *(%%esi); cld\n\t"
33074 + __asm__("movw %w5, %%ds\n\t"
33075 + "lcall *%%ss:(%%esi); cld\n\t"
33076 + "push %%ss\n\t"
33077 + "pop %%ds\n"
33078 "jc 1f\n\t"
33079 "xor %%ah, %%ah\n"
33080 "1:"
33081 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33082 : "0" (PCIBIOS_SET_PCI_HW_INT),
33083 "b" ((dev->bus->number << 8) | dev->devfn),
33084 "c" ((irq << 8) | (pin + 10)),
33085 - "S" (&pci_indirect));
33086 + "S" (&pci_indirect),
33087 + "r" (__PCIBIOS_DS));
33088 return !(ret & 0xff00);
33089 }
33090 EXPORT_SYMBOL(pcibios_set_irq_routing);
33091 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33092 index 40e4469..d915bf9 100644
33093 --- a/arch/x86/platform/efi/efi_32.c
33094 +++ b/arch/x86/platform/efi/efi_32.c
33095 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33096 {
33097 struct desc_ptr gdt_descr;
33098
33099 +#ifdef CONFIG_PAX_KERNEXEC
33100 + struct desc_struct d;
33101 +#endif
33102 +
33103 local_irq_save(efi_rt_eflags);
33104
33105 load_cr3(initial_page_table);
33106 __flush_tlb_all();
33107
33108 +#ifdef CONFIG_PAX_KERNEXEC
33109 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33110 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33111 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33112 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33113 +#endif
33114 +
33115 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33116 gdt_descr.size = GDT_SIZE - 1;
33117 load_gdt(&gdt_descr);
33118 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33119 {
33120 struct desc_ptr gdt_descr;
33121
33122 +#ifdef CONFIG_PAX_KERNEXEC
33123 + struct desc_struct d;
33124 +
33125 + memset(&d, 0, sizeof d);
33126 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33127 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33128 +#endif
33129 +
33130 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33131 gdt_descr.size = GDT_SIZE - 1;
33132 load_gdt(&gdt_descr);
33133
33134 +#ifdef CONFIG_PAX_PER_CPU_PGD
33135 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33136 +#else
33137 load_cr3(swapper_pg_dir);
33138 +#endif
33139 +
33140 __flush_tlb_all();
33141
33142 local_irq_restore(efi_rt_eflags);
33143 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33144 index 39a0e7f1..872396e 100644
33145 --- a/arch/x86/platform/efi/efi_64.c
33146 +++ b/arch/x86/platform/efi/efi_64.c
33147 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33148 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33149 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33150 }
33151 +
33152 +#ifdef CONFIG_PAX_PER_CPU_PGD
33153 + load_cr3(swapper_pg_dir);
33154 +#endif
33155 +
33156 __flush_tlb_all();
33157 }
33158
33159 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33160 for (pgd = 0; pgd < n_pgds; pgd++)
33161 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33162 kfree(save_pgd);
33163 +
33164 +#ifdef CONFIG_PAX_PER_CPU_PGD
33165 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33166 +#endif
33167 +
33168 __flush_tlb_all();
33169 local_irq_restore(efi_flags);
33170 early_code_mapping_set_exec(0);
33171 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33172 index fbe66e6..eae5e38 100644
33173 --- a/arch/x86/platform/efi/efi_stub_32.S
33174 +++ b/arch/x86/platform/efi/efi_stub_32.S
33175 @@ -6,7 +6,9 @@
33176 */
33177
33178 #include <linux/linkage.h>
33179 +#include <linux/init.h>
33180 #include <asm/page_types.h>
33181 +#include <asm/segment.h>
33182
33183 /*
33184 * efi_call_phys(void *, ...) is a function with variable parameters.
33185 @@ -20,7 +22,7 @@
33186 * service functions will comply with gcc calling convention, too.
33187 */
33188
33189 -.text
33190 +__INIT
33191 ENTRY(efi_call_phys)
33192 /*
33193 * 0. The function can only be called in Linux kernel. So CS has been
33194 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33195 * The mapping of lower virtual memory has been created in prelog and
33196 * epilog.
33197 */
33198 - movl $1f, %edx
33199 - subl $__PAGE_OFFSET, %edx
33200 - jmp *%edx
33201 +#ifdef CONFIG_PAX_KERNEXEC
33202 + movl $(__KERNEXEC_EFI_DS), %edx
33203 + mov %edx, %ds
33204 + mov %edx, %es
33205 + mov %edx, %ss
33206 + addl $2f,(1f)
33207 + ljmp *(1f)
33208 +
33209 +__INITDATA
33210 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33211 +.previous
33212 +
33213 +2:
33214 + subl $2b,(1b)
33215 +#else
33216 + jmp 1f-__PAGE_OFFSET
33217 1:
33218 +#endif
33219
33220 /*
33221 * 2. Now on the top of stack is the return
33222 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33223 * parameter 2, ..., param n. To make things easy, we save the return
33224 * address of efi_call_phys in a global variable.
33225 */
33226 - popl %edx
33227 - movl %edx, saved_return_addr
33228 - /* get the function pointer into ECX*/
33229 - popl %ecx
33230 - movl %ecx, efi_rt_function_ptr
33231 - movl $2f, %edx
33232 - subl $__PAGE_OFFSET, %edx
33233 - pushl %edx
33234 + popl (saved_return_addr)
33235 + popl (efi_rt_function_ptr)
33236
33237 /*
33238 * 3. Clear PG bit in %CR0.
33239 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33240 /*
33241 * 5. Call the physical function.
33242 */
33243 - jmp *%ecx
33244 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33245
33246 -2:
33247 /*
33248 * 6. After EFI runtime service returns, control will return to
33249 * following instruction. We'd better readjust stack pointer first.
33250 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33251 movl %cr0, %edx
33252 orl $0x80000000, %edx
33253 movl %edx, %cr0
33254 - jmp 1f
33255 -1:
33256 +
33257 /*
33258 * 8. Now restore the virtual mode from flat mode by
33259 * adding EIP with PAGE_OFFSET.
33260 */
33261 - movl $1f, %edx
33262 - jmp *%edx
33263 +#ifdef CONFIG_PAX_KERNEXEC
33264 + movl $(__KERNEL_DS), %edx
33265 + mov %edx, %ds
33266 + mov %edx, %es
33267 + mov %edx, %ss
33268 + ljmp $(__KERNEL_CS),$1f
33269 +#else
33270 + jmp 1f+__PAGE_OFFSET
33271 +#endif
33272 1:
33273
33274 /*
33275 * 9. Balance the stack. And because EAX contain the return value,
33276 * we'd better not clobber it.
33277 */
33278 - leal efi_rt_function_ptr, %edx
33279 - movl (%edx), %ecx
33280 - pushl %ecx
33281 + pushl (efi_rt_function_ptr)
33282
33283 /*
33284 - * 10. Push the saved return address onto the stack and return.
33285 + * 10. Return to the saved return address.
33286 */
33287 - leal saved_return_addr, %edx
33288 - movl (%edx), %ecx
33289 - pushl %ecx
33290 - ret
33291 + jmpl *(saved_return_addr)
33292 ENDPROC(efi_call_phys)
33293 .previous
33294
33295 -.data
33296 +__INITDATA
33297 saved_return_addr:
33298 .long 0
33299 efi_rt_function_ptr:
33300 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33301 index 4c07cca..2c8427d 100644
33302 --- a/arch/x86/platform/efi/efi_stub_64.S
33303 +++ b/arch/x86/platform/efi/efi_stub_64.S
33304 @@ -7,6 +7,7 @@
33305 */
33306
33307 #include <linux/linkage.h>
33308 +#include <asm/alternative-asm.h>
33309
33310 #define SAVE_XMM \
33311 mov %rsp, %rax; \
33312 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33313 call *%rdi
33314 addq $32, %rsp
33315 RESTORE_XMM
33316 + pax_force_retaddr 0, 1
33317 ret
33318 ENDPROC(efi_call0)
33319
33320 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33321 call *%rdi
33322 addq $32, %rsp
33323 RESTORE_XMM
33324 + pax_force_retaddr 0, 1
33325 ret
33326 ENDPROC(efi_call1)
33327
33328 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33329 call *%rdi
33330 addq $32, %rsp
33331 RESTORE_XMM
33332 + pax_force_retaddr 0, 1
33333 ret
33334 ENDPROC(efi_call2)
33335
33336 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33337 call *%rdi
33338 addq $32, %rsp
33339 RESTORE_XMM
33340 + pax_force_retaddr 0, 1
33341 ret
33342 ENDPROC(efi_call3)
33343
33344 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33345 call *%rdi
33346 addq $32, %rsp
33347 RESTORE_XMM
33348 + pax_force_retaddr 0, 1
33349 ret
33350 ENDPROC(efi_call4)
33351
33352 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33353 call *%rdi
33354 addq $48, %rsp
33355 RESTORE_XMM
33356 + pax_force_retaddr 0, 1
33357 ret
33358 ENDPROC(efi_call5)
33359
33360 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33361 call *%rdi
33362 addq $48, %rsp
33363 RESTORE_XMM
33364 + pax_force_retaddr 0, 1
33365 ret
33366 ENDPROC(efi_call6)
33367 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33368 index 47fe66f..6206449 100644
33369 --- a/arch/x86/platform/mrst/mrst.c
33370 +++ b/arch/x86/platform/mrst/mrst.c
33371 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33372 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33373 int sfi_mrtc_num;
33374
33375 -static void mrst_power_off(void)
33376 +static __noreturn void mrst_power_off(void)
33377 {
33378 + BUG();
33379 }
33380
33381 -static void mrst_reboot(void)
33382 +static __noreturn void mrst_reboot(void)
33383 {
33384 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33385 + BUG();
33386 }
33387
33388 /* parse all the mtimer info to a static mtimer array */
33389 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33390 index d6ee929..3637cb5 100644
33391 --- a/arch/x86/platform/olpc/olpc_dt.c
33392 +++ b/arch/x86/platform/olpc/olpc_dt.c
33393 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33394 return res;
33395 }
33396
33397 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33398 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33399 .nextprop = olpc_dt_nextprop,
33400 .getproplen = olpc_dt_getproplen,
33401 .getproperty = olpc_dt_getproperty,
33402 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33403 index 1cf5b30..fd45732 100644
33404 --- a/arch/x86/power/cpu.c
33405 +++ b/arch/x86/power/cpu.c
33406 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33407 static void fix_processor_context(void)
33408 {
33409 int cpu = smp_processor_id();
33410 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33411 -#ifdef CONFIG_X86_64
33412 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33413 - tss_desc tss;
33414 -#endif
33415 + struct tss_struct *t = init_tss + cpu;
33416 +
33417 set_tss_desc(cpu, t); /*
33418 * This just modifies memory; should not be
33419 * necessary. But... This is necessary, because
33420 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33421 */
33422
33423 #ifdef CONFIG_X86_64
33424 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33425 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33426 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33427 -
33428 syscall_init(); /* This sets MSR_*STAR and related */
33429 #endif
33430 load_TR_desc(); /* This does ltr */
33431 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33432 index a44f457..9140171 100644
33433 --- a/arch/x86/realmode/init.c
33434 +++ b/arch/x86/realmode/init.c
33435 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33436 __va(real_mode_header->trampoline_header);
33437
33438 #ifdef CONFIG_X86_32
33439 - trampoline_header->start = __pa_symbol(startup_32_smp);
33440 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33441 +
33442 +#ifdef CONFIG_PAX_KERNEXEC
33443 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33444 +#endif
33445 +
33446 + trampoline_header->boot_cs = __BOOT_CS;
33447 trampoline_header->gdt_limit = __BOOT_DS + 7;
33448 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33449 #else
33450 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33451 *trampoline_cr4_features = read_cr4();
33452
33453 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33454 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33455 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33456 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33457 #endif
33458 }
33459 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33460 index 8869287..d577672 100644
33461 --- a/arch/x86/realmode/rm/Makefile
33462 +++ b/arch/x86/realmode/rm/Makefile
33463 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33464 $(call cc-option, -fno-unit-at-a-time)) \
33465 $(call cc-option, -fno-stack-protector) \
33466 $(call cc-option, -mpreferred-stack-boundary=2)
33467 +ifdef CONSTIFY_PLUGIN
33468 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33469 +endif
33470 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33471 GCOV_PROFILE := n
33472 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33473 index a28221d..93c40f1 100644
33474 --- a/arch/x86/realmode/rm/header.S
33475 +++ b/arch/x86/realmode/rm/header.S
33476 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33477 #endif
33478 /* APM/BIOS reboot */
33479 .long pa_machine_real_restart_asm
33480 -#ifdef CONFIG_X86_64
33481 +#ifdef CONFIG_X86_32
33482 + .long __KERNEL_CS
33483 +#else
33484 .long __KERNEL32_CS
33485 #endif
33486 END(real_mode_header)
33487 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33488 index c1b2791..f9e31c7 100644
33489 --- a/arch/x86/realmode/rm/trampoline_32.S
33490 +++ b/arch/x86/realmode/rm/trampoline_32.S
33491 @@ -25,6 +25,12 @@
33492 #include <asm/page_types.h>
33493 #include "realmode.h"
33494
33495 +#ifdef CONFIG_PAX_KERNEXEC
33496 +#define ta(X) (X)
33497 +#else
33498 +#define ta(X) (pa_ ## X)
33499 +#endif
33500 +
33501 .text
33502 .code16
33503
33504 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33505
33506 cli # We should be safe anyway
33507
33508 - movl tr_start, %eax # where we need to go
33509 -
33510 movl $0xA5A5A5A5, trampoline_status
33511 # write marker for master knows we're running
33512
33513 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33514 movw $1, %dx # protected mode (PE) bit
33515 lmsw %dx # into protected mode
33516
33517 - ljmpl $__BOOT_CS, $pa_startup_32
33518 + ljmpl *(trampoline_header)
33519
33520 .section ".text32","ax"
33521 .code32
33522 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33523 .balign 8
33524 GLOBAL(trampoline_header)
33525 tr_start: .space 4
33526 - tr_gdt_pad: .space 2
33527 + tr_boot_cs: .space 2
33528 tr_gdt: .space 6
33529 END(trampoline_header)
33530
33531 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33532 index bb360dc..d0fd8f8 100644
33533 --- a/arch/x86/realmode/rm/trampoline_64.S
33534 +++ b/arch/x86/realmode/rm/trampoline_64.S
33535 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33536 movl %edx, %gs
33537
33538 movl pa_tr_cr4, %eax
33539 + andl $~X86_CR4_PCIDE, %eax
33540 movl %eax, %cr4 # Enable PAE mode
33541
33542 # Setup trampoline 4 level pagetables
33543 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33544 wrmsr
33545
33546 # Enable paging and in turn activate Long Mode
33547 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33548 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33549 movl %eax, %cr0
33550
33551 /*
33552 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33553 index e812034..c747134 100644
33554 --- a/arch/x86/tools/Makefile
33555 +++ b/arch/x86/tools/Makefile
33556 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33557
33558 $(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
33559
33560 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33561 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33562 hostprogs-y += relocs
33563 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33564 relocs: $(obj)/relocs
33565 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33566 index f7bab68..b6d9886 100644
33567 --- a/arch/x86/tools/relocs.c
33568 +++ b/arch/x86/tools/relocs.c
33569 @@ -1,5 +1,7 @@
33570 /* This is included from relocs_32/64.c */
33571
33572 +#include "../../../include/generated/autoconf.h"
33573 +
33574 #define ElfW(type) _ElfW(ELF_BITS, type)
33575 #define _ElfW(bits, type) __ElfW(bits, type)
33576 #define __ElfW(bits, type) Elf##bits##_##type
33577 @@ -11,6 +13,7 @@
33578 #define Elf_Sym ElfW(Sym)
33579
33580 static Elf_Ehdr ehdr;
33581 +static Elf_Phdr *phdr;
33582
33583 struct relocs {
33584 uint32_t *offset;
33585 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33586 }
33587 }
33588
33589 +static void read_phdrs(FILE *fp)
33590 +{
33591 + unsigned int i;
33592 +
33593 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33594 + if (!phdr) {
33595 + die("Unable to allocate %d program headers\n",
33596 + ehdr.e_phnum);
33597 + }
33598 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33599 + die("Seek to %d failed: %s\n",
33600 + ehdr.e_phoff, strerror(errno));
33601 + }
33602 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33603 + die("Cannot read ELF program headers: %s\n",
33604 + strerror(errno));
33605 + }
33606 + for(i = 0; i < ehdr.e_phnum; i++) {
33607 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33608 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33609 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33610 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33611 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33612 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33613 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33614 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33615 + }
33616 +
33617 +}
33618 +
33619 static void read_shdrs(FILE *fp)
33620 {
33621 - int i;
33622 + unsigned int i;
33623 Elf_Shdr shdr;
33624
33625 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33626 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33627
33628 static void read_strtabs(FILE *fp)
33629 {
33630 - int i;
33631 + unsigned int i;
33632 for (i = 0; i < ehdr.e_shnum; i++) {
33633 struct section *sec = &secs[i];
33634 if (sec->shdr.sh_type != SHT_STRTAB) {
33635 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33636
33637 static void read_symtabs(FILE *fp)
33638 {
33639 - int i,j;
33640 + unsigned int i,j;
33641 for (i = 0; i < ehdr.e_shnum; i++) {
33642 struct section *sec = &secs[i];
33643 if (sec->shdr.sh_type != SHT_SYMTAB) {
33644 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33645 }
33646
33647
33648 -static void read_relocs(FILE *fp)
33649 +static void read_relocs(FILE *fp, int use_real_mode)
33650 {
33651 - int i,j;
33652 + unsigned int i,j;
33653 + uint32_t base;
33654 +
33655 for (i = 0; i < ehdr.e_shnum; i++) {
33656 struct section *sec = &secs[i];
33657 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33658 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33659 die("Cannot read symbol table: %s\n",
33660 strerror(errno));
33661 }
33662 + base = 0;
33663 +
33664 +#ifdef CONFIG_X86_32
33665 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33666 + if (phdr[j].p_type != PT_LOAD )
33667 + continue;
33668 + 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)
33669 + continue;
33670 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33671 + break;
33672 + }
33673 +#endif
33674 +
33675 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33676 Elf_Rel *rel = &sec->reltab[j];
33677 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33678 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33679 rel->r_info = elf_xword_to_cpu(rel->r_info);
33680 #if (SHT_REL_TYPE == SHT_RELA)
33681 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33682 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33683
33684 static void print_absolute_symbols(void)
33685 {
33686 - int i;
33687 + unsigned int i;
33688 const char *format;
33689
33690 if (ELF_BITS == 64)
33691 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33692 for (i = 0; i < ehdr.e_shnum; i++) {
33693 struct section *sec = &secs[i];
33694 char *sym_strtab;
33695 - int j;
33696 + unsigned int j;
33697
33698 if (sec->shdr.sh_type != SHT_SYMTAB) {
33699 continue;
33700 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33701
33702 static void print_absolute_relocs(void)
33703 {
33704 - int i, printed = 0;
33705 + unsigned int i, printed = 0;
33706 const char *format;
33707
33708 if (ELF_BITS == 64)
33709 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33710 struct section *sec_applies, *sec_symtab;
33711 char *sym_strtab;
33712 Elf_Sym *sh_symtab;
33713 - int j;
33714 + unsigned int j;
33715 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33716 continue;
33717 }
33718 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33719 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33720 Elf_Sym *sym, const char *symname))
33721 {
33722 - int i;
33723 + unsigned int i;
33724 /* Walk through the relocations */
33725 for (i = 0; i < ehdr.e_shnum; i++) {
33726 char *sym_strtab;
33727 Elf_Sym *sh_symtab;
33728 struct section *sec_applies, *sec_symtab;
33729 - int j;
33730 + unsigned int j;
33731 struct section *sec = &secs[i];
33732
33733 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33734 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33735 {
33736 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33737 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33738 + char *sym_strtab = sec->link->link->strtab;
33739 +
33740 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33741 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33742 + return 0;
33743 +
33744 +#ifdef CONFIG_PAX_KERNEXEC
33745 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33746 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33747 + return 0;
33748 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33749 + return 0;
33750 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33751 + return 0;
33752 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33753 + return 0;
33754 +#endif
33755
33756 switch (r_type) {
33757 case R_386_NONE:
33758 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33759
33760 static void emit_relocs(int as_text, int use_real_mode)
33761 {
33762 - int i;
33763 + unsigned int i;
33764 int (*write_reloc)(uint32_t, FILE *) = write32;
33765 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33766 const char *symname);
33767 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33768 {
33769 regex_init(use_real_mode);
33770 read_ehdr(fp);
33771 + read_phdrs(fp);
33772 read_shdrs(fp);
33773 read_strtabs(fp);
33774 read_symtabs(fp);
33775 - read_relocs(fp);
33776 + read_relocs(fp, use_real_mode);
33777 if (ELF_BITS == 64)
33778 percpu_init();
33779 if (show_absolute_syms) {
33780 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33781 index 80ffa5b..a33bd15 100644
33782 --- a/arch/x86/um/tls_32.c
33783 +++ b/arch/x86/um/tls_32.c
33784 @@ -260,7 +260,7 @@ out:
33785 if (unlikely(task == current &&
33786 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33787 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33788 - "without flushed TLS.", current->pid);
33789 + "without flushed TLS.", task_pid_nr(current));
33790 }
33791
33792 return 0;
33793 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33794 index fd14be1..e3c79c0 100644
33795 --- a/arch/x86/vdso/Makefile
33796 +++ b/arch/x86/vdso/Makefile
33797 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33798 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33799 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33800
33801 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33802 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33803 GCOV_PROFILE := n
33804
33805 #
33806 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33807 index d6bfb87..876ee18 100644
33808 --- a/arch/x86/vdso/vdso32-setup.c
33809 +++ b/arch/x86/vdso/vdso32-setup.c
33810 @@ -25,6 +25,7 @@
33811 #include <asm/tlbflush.h>
33812 #include <asm/vdso.h>
33813 #include <asm/proto.h>
33814 +#include <asm/mman.h>
33815
33816 enum {
33817 VDSO_DISABLED = 0,
33818 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33819 void enable_sep_cpu(void)
33820 {
33821 int cpu = get_cpu();
33822 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33823 + struct tss_struct *tss = init_tss + cpu;
33824
33825 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33826 put_cpu();
33827 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33828 gate_vma.vm_start = FIXADDR_USER_START;
33829 gate_vma.vm_end = FIXADDR_USER_END;
33830 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33831 - gate_vma.vm_page_prot = __P101;
33832 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33833
33834 return 0;
33835 }
33836 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33837 if (compat)
33838 addr = VDSO_HIGH_BASE;
33839 else {
33840 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33841 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33842 if (IS_ERR_VALUE(addr)) {
33843 ret = addr;
33844 goto up_fail;
33845 }
33846 }
33847
33848 - current->mm->context.vdso = (void *)addr;
33849 + current->mm->context.vdso = addr;
33850
33851 if (compat_uses_vma || !compat) {
33852 /*
33853 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33854 }
33855
33856 current_thread_info()->sysenter_return =
33857 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33858 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33859
33860 up_fail:
33861 if (ret)
33862 - current->mm->context.vdso = NULL;
33863 + current->mm->context.vdso = 0;
33864
33865 up_write(&mm->mmap_sem);
33866
33867 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33868
33869 const char *arch_vma_name(struct vm_area_struct *vma)
33870 {
33871 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33872 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33873 return "[vdso]";
33874 +
33875 +#ifdef CONFIG_PAX_SEGMEXEC
33876 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33877 + return "[vdso]";
33878 +#endif
33879 +
33880 return NULL;
33881 }
33882
33883 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33884 * Check to see if the corresponding task was created in compat vdso
33885 * mode.
33886 */
33887 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33888 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33889 return &gate_vma;
33890 return NULL;
33891 }
33892 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33893 index 431e875..cbb23f3 100644
33894 --- a/arch/x86/vdso/vma.c
33895 +++ b/arch/x86/vdso/vma.c
33896 @@ -16,8 +16,6 @@
33897 #include <asm/vdso.h>
33898 #include <asm/page.h>
33899
33900 -unsigned int __read_mostly vdso_enabled = 1;
33901 -
33902 extern char vdso_start[], vdso_end[];
33903 extern unsigned short vdso_sync_cpuid;
33904
33905 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33906 * unaligned here as a result of stack start randomization.
33907 */
33908 addr = PAGE_ALIGN(addr);
33909 - addr = align_vdso_addr(addr);
33910
33911 return addr;
33912 }
33913 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33914 unsigned size)
33915 {
33916 struct mm_struct *mm = current->mm;
33917 - unsigned long addr;
33918 + unsigned long addr = 0;
33919 int ret;
33920
33921 - if (!vdso_enabled)
33922 - return 0;
33923 -
33924 down_write(&mm->mmap_sem);
33925 +
33926 +#ifdef CONFIG_PAX_RANDMMAP
33927 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33928 +#endif
33929 +
33930 addr = vdso_addr(mm->start_stack, size);
33931 + addr = align_vdso_addr(addr);
33932 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33933 if (IS_ERR_VALUE(addr)) {
33934 ret = addr;
33935 goto up_fail;
33936 }
33937
33938 - current->mm->context.vdso = (void *)addr;
33939 + mm->context.vdso = addr;
33940
33941 ret = install_special_mapping(mm, addr, size,
33942 VM_READ|VM_EXEC|
33943 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33944 pages);
33945 - if (ret) {
33946 - current->mm->context.vdso = NULL;
33947 - goto up_fail;
33948 - }
33949 + if (ret)
33950 + mm->context.vdso = 0;
33951
33952 up_fail:
33953 up_write(&mm->mmap_sem);
33954 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33955 vdsox32_size);
33956 }
33957 #endif
33958 -
33959 -static __init int vdso_setup(char *s)
33960 -{
33961 - vdso_enabled = simple_strtoul(s, NULL, 0);
33962 - return 0;
33963 -}
33964 -__setup("vdso=", vdso_setup);
33965 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33966 index 193097e..7590269 100644
33967 --- a/arch/x86/xen/enlighten.c
33968 +++ b/arch/x86/xen/enlighten.c
33969 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33970
33971 struct shared_info xen_dummy_shared_info;
33972
33973 -void *xen_initial_gdt;
33974 -
33975 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33976 __read_mostly int xen_have_vector_callback;
33977 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33978 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33979 {
33980 unsigned long va = dtr->address;
33981 unsigned int size = dtr->size + 1;
33982 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33983 - unsigned long frames[pages];
33984 + unsigned long frames[65536 / PAGE_SIZE];
33985 int f;
33986
33987 /*
33988 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33989 {
33990 unsigned long va = dtr->address;
33991 unsigned int size = dtr->size + 1;
33992 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33993 - unsigned long frames[pages];
33994 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33995 int f;
33996
33997 /*
33998 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33999 * 8-byte entries, or 16 4k pages..
34000 */
34001
34002 - BUG_ON(size > 65536);
34003 + BUG_ON(size > GDT_SIZE);
34004 BUG_ON(va & ~PAGE_MASK);
34005
34006 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34007 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34008 return 0;
34009 }
34010
34011 -static void set_xen_basic_apic_ops(void)
34012 +static void __init set_xen_basic_apic_ops(void)
34013 {
34014 apic->read = xen_apic_read;
34015 apic->write = xen_apic_write;
34016 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34017 #endif
34018 };
34019
34020 -static void xen_reboot(int reason)
34021 +static __noreturn void xen_reboot(int reason)
34022 {
34023 struct sched_shutdown r = { .reason = reason };
34024
34025 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34026 - BUG();
34027 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34028 + BUG();
34029 }
34030
34031 -static void xen_restart(char *msg)
34032 +static __noreturn void xen_restart(char *msg)
34033 {
34034 xen_reboot(SHUTDOWN_reboot);
34035 }
34036
34037 -static void xen_emergency_restart(void)
34038 +static __noreturn void xen_emergency_restart(void)
34039 {
34040 xen_reboot(SHUTDOWN_reboot);
34041 }
34042
34043 -static void xen_machine_halt(void)
34044 +static __noreturn void xen_machine_halt(void)
34045 {
34046 xen_reboot(SHUTDOWN_poweroff);
34047 }
34048
34049 -static void xen_machine_power_off(void)
34050 +static __noreturn void xen_machine_power_off(void)
34051 {
34052 if (pm_power_off)
34053 pm_power_off();
34054 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34055 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34056
34057 /* Work out if we support NX */
34058 - x86_configure_nx();
34059 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34060 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34061 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34062 + unsigned l, h;
34063 +
34064 + __supported_pte_mask |= _PAGE_NX;
34065 + rdmsr(MSR_EFER, l, h);
34066 + l |= EFER_NX;
34067 + wrmsr(MSR_EFER, l, h);
34068 + }
34069 +#endif
34070
34071 xen_setup_features();
34072
34073 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34074
34075 machine_ops = xen_machine_ops;
34076
34077 - /*
34078 - * The only reliable way to retain the initial address of the
34079 - * percpu gdt_page is to remember it here, so we can go and
34080 - * mark it RW later, when the initial percpu area is freed.
34081 - */
34082 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34083 -
34084 xen_smp_init();
34085
34086 #ifdef CONFIG_ACPI_NUMA
34087 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34088 index fdc3ba2..3daee39 100644
34089 --- a/arch/x86/xen/mmu.c
34090 +++ b/arch/x86/xen/mmu.c
34091 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34092 /* L3_k[510] -> level2_kernel_pgt
34093 * L3_i[511] -> level2_fixmap_pgt */
34094 convert_pfn_mfn(level3_kernel_pgt);
34095 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34096 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34097 + convert_pfn_mfn(level3_vmemmap_pgt);
34098
34099 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34100 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34101 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34102 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34103 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34104 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34105 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34106 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34107 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34108 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34109 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34110 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34111 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34112 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34113
34114 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34115 pv_mmu_ops.set_pud = xen_set_pud;
34116 #if PAGETABLE_LEVELS == 4
34117 pv_mmu_ops.set_pgd = xen_set_pgd;
34118 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34119 #endif
34120
34121 /* This will work as long as patching hasn't happened yet
34122 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34123 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34124 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34125 .set_pgd = xen_set_pgd_hyper,
34126 + .set_pgd_batched = xen_set_pgd_hyper,
34127
34128 .alloc_pud = xen_alloc_pmd_init,
34129 .release_pud = xen_release_pmd_init,
34130 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34131 index b81c88e..2cbe7b8 100644
34132 --- a/arch/x86/xen/smp.c
34133 +++ b/arch/x86/xen/smp.c
34134 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34135 {
34136 BUG_ON(smp_processor_id() != 0);
34137 native_smp_prepare_boot_cpu();
34138 -
34139 - /* We've switched to the "real" per-cpu gdt, so make sure the
34140 - old memory can be recycled */
34141 - make_lowmem_page_readwrite(xen_initial_gdt);
34142 -
34143 xen_filter_cpu_maps();
34144 xen_setup_vcpu_info_placement();
34145 }
34146 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34147 ctxt->user_regs.ss = __KERNEL_DS;
34148 #ifdef CONFIG_X86_32
34149 ctxt->user_regs.fs = __KERNEL_PERCPU;
34150 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34151 + savesegment(gs, ctxt->user_regs.gs);
34152 #else
34153 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34154 #endif
34155 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34156
34157 {
34158 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34159 - ctxt->user_regs.ds = __USER_DS;
34160 - ctxt->user_regs.es = __USER_DS;
34161 + ctxt->user_regs.ds = __KERNEL_DS;
34162 + ctxt->user_regs.es = __KERNEL_DS;
34163
34164 xen_copy_trap_info(ctxt->trap_ctxt);
34165
34166 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34167 int rc;
34168
34169 per_cpu(current_task, cpu) = idle;
34170 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34171 #ifdef CONFIG_X86_32
34172 irq_ctx_init(cpu);
34173 #else
34174 clear_tsk_thread_flag(idle, TIF_FORK);
34175 - per_cpu(kernel_stack, cpu) =
34176 - (unsigned long)task_stack_page(idle) -
34177 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34178 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34179 #endif
34180 xen_setup_runstate_info(cpu);
34181 xen_setup_timer(cpu);
34182 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34183
34184 void __init xen_smp_init(void)
34185 {
34186 - smp_ops = xen_smp_ops;
34187 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34188 xen_fill_possible_map();
34189 xen_init_spinlocks();
34190 }
34191 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34192 index 33ca6e4..0ded929 100644
34193 --- a/arch/x86/xen/xen-asm_32.S
34194 +++ b/arch/x86/xen/xen-asm_32.S
34195 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34196 ESP_OFFSET=4 # bytes pushed onto stack
34197
34198 /*
34199 - * Store vcpu_info pointer for easy access. Do it this way to
34200 - * avoid having to reload %fs
34201 + * Store vcpu_info pointer for easy access.
34202 */
34203 #ifdef CONFIG_SMP
34204 - GET_THREAD_INFO(%eax)
34205 - movl %ss:TI_cpu(%eax), %eax
34206 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34207 - mov %ss:xen_vcpu(%eax), %eax
34208 + push %fs
34209 + mov $(__KERNEL_PERCPU), %eax
34210 + mov %eax, %fs
34211 + mov PER_CPU_VAR(xen_vcpu), %eax
34212 + pop %fs
34213 #else
34214 movl %ss:xen_vcpu, %eax
34215 #endif
34216 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34217 index 7faed58..ba4427c 100644
34218 --- a/arch/x86/xen/xen-head.S
34219 +++ b/arch/x86/xen/xen-head.S
34220 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34221 #ifdef CONFIG_X86_32
34222 mov %esi,xen_start_info
34223 mov $init_thread_union+THREAD_SIZE,%esp
34224 +#ifdef CONFIG_SMP
34225 + movl $cpu_gdt_table,%edi
34226 + movl $__per_cpu_load,%eax
34227 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34228 + rorl $16,%eax
34229 + movb %al,__KERNEL_PERCPU + 4(%edi)
34230 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34231 + movl $__per_cpu_end - 1,%eax
34232 + subl $__per_cpu_start,%eax
34233 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34234 +#endif
34235 #else
34236 mov %rsi,xen_start_info
34237 mov $init_thread_union+THREAD_SIZE,%rsp
34238 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34239 index 86782c5..fa272c8 100644
34240 --- a/arch/x86/xen/xen-ops.h
34241 +++ b/arch/x86/xen/xen-ops.h
34242 @@ -10,8 +10,6 @@
34243 extern const char xen_hypervisor_callback[];
34244 extern const char xen_failsafe_callback[];
34245
34246 -extern void *xen_initial_gdt;
34247 -
34248 struct trap_info;
34249 void xen_copy_trap_info(struct trap_info *traps);
34250
34251 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34252 index 525bd3d..ef888b1 100644
34253 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34254 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34255 @@ -119,9 +119,9 @@
34256 ----------------------------------------------------------------------*/
34257
34258 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34259 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34260 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34261 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34262 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34263
34264 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34265 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34266 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34267 index 2f33760..835e50a 100644
34268 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34269 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34270 @@ -11,6 +11,7 @@
34271 #ifndef _XTENSA_CORE_H
34272 #define _XTENSA_CORE_H
34273
34274 +#include <linux/const.h>
34275
34276 /****************************************************************************
34277 Parameters Useful for Any Code, USER or PRIVILEGED
34278 @@ -112,9 +113,9 @@
34279 ----------------------------------------------------------------------*/
34280
34281 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34282 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34283 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34284 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34285 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34286
34287 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34288 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34289 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34290 index af00795..2bb8105 100644
34291 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34292 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34293 @@ -11,6 +11,7 @@
34294 #ifndef _XTENSA_CORE_CONFIGURATION_H
34295 #define _XTENSA_CORE_CONFIGURATION_H
34296
34297 +#include <linux/const.h>
34298
34299 /****************************************************************************
34300 Parameters Useful for Any Code, USER or PRIVILEGED
34301 @@ -118,9 +119,9 @@
34302 ----------------------------------------------------------------------*/
34303
34304 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34305 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34306 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34307 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34308 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34309
34310 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34311 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34312 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34313 index 290792a..416f287 100644
34314 --- a/block/blk-cgroup.c
34315 +++ b/block/blk-cgroup.c
34316 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34317
34318 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34319 {
34320 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34321 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34322 struct blkcg *blkcg;
34323 struct cgroup *parent = cgroup->parent;
34324
34325 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34326
34327 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34328 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34329 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34330 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34331 done:
34332 spin_lock_init(&blkcg->lock);
34333 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34334 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34335 index 4b8d9b54..a7178c0 100644
34336 --- a/block/blk-iopoll.c
34337 +++ b/block/blk-iopoll.c
34338 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34339 }
34340 EXPORT_SYMBOL(blk_iopoll_complete);
34341
34342 -static void blk_iopoll_softirq(struct softirq_action *h)
34343 +static __latent_entropy void blk_iopoll_softirq(void)
34344 {
34345 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34346 int rearm = 0, budget = blk_iopoll_budget;
34347 diff --git a/block/blk-map.c b/block/blk-map.c
34348 index 623e1cd..ca1e109 100644
34349 --- a/block/blk-map.c
34350 +++ b/block/blk-map.c
34351 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34352 if (!len || !kbuf)
34353 return -EINVAL;
34354
34355 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34356 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34357 if (do_copy)
34358 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34359 else
34360 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34361 index ec9e606..3f38839 100644
34362 --- a/block/blk-softirq.c
34363 +++ b/block/blk-softirq.c
34364 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34365 * Softirq action handler - move entries to local list and loop over them
34366 * while passing them to the queue registered handler.
34367 */
34368 -static void blk_done_softirq(struct softirq_action *h)
34369 +static __latent_entropy void blk_done_softirq(void)
34370 {
34371 struct list_head *cpu_list, local_list;
34372
34373 diff --git a/block/bsg.c b/block/bsg.c
34374 index 420a5a9..23834aa 100644
34375 --- a/block/bsg.c
34376 +++ b/block/bsg.c
34377 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34378 struct sg_io_v4 *hdr, struct bsg_device *bd,
34379 fmode_t has_write_perm)
34380 {
34381 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34382 + unsigned char *cmdptr;
34383 +
34384 if (hdr->request_len > BLK_MAX_CDB) {
34385 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34386 if (!rq->cmd)
34387 return -ENOMEM;
34388 - }
34389 + cmdptr = rq->cmd;
34390 + } else
34391 + cmdptr = tmpcmd;
34392
34393 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34394 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34395 hdr->request_len))
34396 return -EFAULT;
34397
34398 + if (cmdptr != rq->cmd)
34399 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34400 +
34401 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34402 if (blk_verify_command(rq->cmd, has_write_perm))
34403 return -EPERM;
34404 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34405 index 7e5d474..0cf0017 100644
34406 --- a/block/compat_ioctl.c
34407 +++ b/block/compat_ioctl.c
34408 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34409 err |= __get_user(f->spec1, &uf->spec1);
34410 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34411 err |= __get_user(name, &uf->name);
34412 - f->name = compat_ptr(name);
34413 + f->name = (void __force_kernel *)compat_ptr(name);
34414 if (err) {
34415 err = -EFAULT;
34416 goto out;
34417 diff --git a/block/genhd.c b/block/genhd.c
34418 index dadf42b..48dc887 100644
34419 --- a/block/genhd.c
34420 +++ b/block/genhd.c
34421 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34422
34423 /*
34424 * Register device numbers dev..(dev+range-1)
34425 - * range must be nonzero
34426 + * Noop if @range is zero.
34427 * The hash chain is sorted on range, so that subranges can override.
34428 */
34429 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34430 struct kobject *(*probe)(dev_t, int *, void *),
34431 int (*lock)(dev_t, void *), void *data)
34432 {
34433 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34434 + if (range)
34435 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34436 }
34437
34438 EXPORT_SYMBOL(blk_register_region);
34439
34440 +/* undo blk_register_region(), noop if @range is zero */
34441 void blk_unregister_region(dev_t devt, unsigned long range)
34442 {
34443 - kobj_unmap(bdev_map, devt, range);
34444 + if (range)
34445 + kobj_unmap(bdev_map, devt, range);
34446 }
34447
34448 EXPORT_SYMBOL(blk_unregister_region);
34449 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34450 index c85fc89..51e690b 100644
34451 --- a/block/partitions/efi.c
34452 +++ b/block/partitions/efi.c
34453 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34454 if (!gpt)
34455 return NULL;
34456
34457 + if (!le32_to_cpu(gpt->num_partition_entries))
34458 + return NULL;
34459 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34460 + if (!pte)
34461 + return NULL;
34462 +
34463 count = le32_to_cpu(gpt->num_partition_entries) *
34464 le32_to_cpu(gpt->sizeof_partition_entry);
34465 - if (!count)
34466 - return NULL;
34467 - pte = kmalloc(count, GFP_KERNEL);
34468 - if (!pte)
34469 - return NULL;
34470 -
34471 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34472 (u8 *) pte,
34473 count) < count) {
34474 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34475 index a5ffcc9..3cedc9c 100644
34476 --- a/block/scsi_ioctl.c
34477 +++ b/block/scsi_ioctl.c
34478 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34479 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34480 struct sg_io_hdr *hdr, fmode_t mode)
34481 {
34482 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34483 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34484 + unsigned char *cmdptr;
34485 +
34486 + if (rq->cmd != rq->__cmd)
34487 + cmdptr = rq->cmd;
34488 + else
34489 + cmdptr = tmpcmd;
34490 +
34491 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34492 return -EFAULT;
34493 +
34494 + if (cmdptr != rq->cmd)
34495 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34496 +
34497 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34498 return -EPERM;
34499
34500 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34501 int err;
34502 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34503 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34504 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34505 + unsigned char *cmdptr;
34506
34507 if (!sic)
34508 return -EINVAL;
34509 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34510 */
34511 err = -EFAULT;
34512 rq->cmd_len = cmdlen;
34513 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34514 +
34515 + if (rq->cmd != rq->__cmd)
34516 + cmdptr = rq->cmd;
34517 + else
34518 + cmdptr = tmpcmd;
34519 +
34520 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34521 goto error;
34522
34523 + if (rq->cmd != cmdptr)
34524 + memcpy(rq->cmd, cmdptr, cmdlen);
34525 +
34526 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34527 goto error;
34528
34529 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34530 index 7bdd61b..afec999 100644
34531 --- a/crypto/cryptd.c
34532 +++ b/crypto/cryptd.c
34533 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34534
34535 struct cryptd_blkcipher_request_ctx {
34536 crypto_completion_t complete;
34537 -};
34538 +} __no_const;
34539
34540 struct cryptd_hash_ctx {
34541 struct crypto_shash *child;
34542 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34543
34544 struct cryptd_aead_request_ctx {
34545 crypto_completion_t complete;
34546 -};
34547 +} __no_const;
34548
34549 static void cryptd_queue_worker(struct work_struct *work);
34550
34551 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34552 index f8c920c..ab2cb5a 100644
34553 --- a/crypto/pcrypt.c
34554 +++ b/crypto/pcrypt.c
34555 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34556 int ret;
34557
34558 pinst->kobj.kset = pcrypt_kset;
34559 - ret = kobject_add(&pinst->kobj, NULL, name);
34560 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34561 if (!ret)
34562 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34563
34564 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34565 index f220d64..d359ad6 100644
34566 --- a/drivers/acpi/apei/apei-internal.h
34567 +++ b/drivers/acpi/apei/apei-internal.h
34568 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34569 struct apei_exec_ins_type {
34570 u32 flags;
34571 apei_exec_ins_func_t run;
34572 -};
34573 +} __do_const;
34574
34575 struct apei_exec_context {
34576 u32 ip;
34577 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34578 index 33dc6a0..4b24b47 100644
34579 --- a/drivers/acpi/apei/cper.c
34580 +++ b/drivers/acpi/apei/cper.c
34581 @@ -39,12 +39,12 @@
34582 */
34583 u64 cper_next_record_id(void)
34584 {
34585 - static atomic64_t seq;
34586 + static atomic64_unchecked_t seq;
34587
34588 - if (!atomic64_read(&seq))
34589 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34590 + if (!atomic64_read_unchecked(&seq))
34591 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34592
34593 - return atomic64_inc_return(&seq);
34594 + return atomic64_inc_return_unchecked(&seq);
34595 }
34596 EXPORT_SYMBOL_GPL(cper_next_record_id);
34597
34598 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34599 index ec9b57d..9682b3a 100644
34600 --- a/drivers/acpi/apei/ghes.c
34601 +++ b/drivers/acpi/apei/ghes.c
34602 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34603 const struct acpi_hest_generic *generic,
34604 const struct acpi_hest_generic_status *estatus)
34605 {
34606 - static atomic_t seqno;
34607 + static atomic_unchecked_t seqno;
34608 unsigned int curr_seqno;
34609 char pfx_seq[64];
34610
34611 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34612 else
34613 pfx = KERN_ERR;
34614 }
34615 - curr_seqno = atomic_inc_return(&seqno);
34616 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34617 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34618 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34619 pfx_seq, generic->header.source_id);
34620 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34621 index be60399..778b33e8 100644
34622 --- a/drivers/acpi/bgrt.c
34623 +++ b/drivers/acpi/bgrt.c
34624 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34625 return -ENODEV;
34626
34627 sysfs_bin_attr_init(&image_attr);
34628 - image_attr.private = bgrt_image;
34629 - image_attr.size = bgrt_image_size;
34630 + pax_open_kernel();
34631 + *(void **)&image_attr.private = bgrt_image;
34632 + *(size_t *)&image_attr.size = bgrt_image_size;
34633 + pax_close_kernel();
34634
34635 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34636 if (!bgrt_kobj)
34637 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34638 index cb96296..b81293b 100644
34639 --- a/drivers/acpi/blacklist.c
34640 +++ b/drivers/acpi/blacklist.c
34641 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34642 u32 is_critical_error;
34643 };
34644
34645 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34646 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34647
34648 /*
34649 * POLICY: If *anything* doesn't work, put it on the blacklist.
34650 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34651 return 0;
34652 }
34653
34654 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34655 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34656 {
34657 .callback = dmi_disable_osi_vista,
34658 .ident = "Fujitsu Siemens",
34659 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34660 index f98dd00..7b69865 100644
34661 --- a/drivers/acpi/processor_idle.c
34662 +++ b/drivers/acpi/processor_idle.c
34663 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34664 {
34665 int i, count = CPUIDLE_DRIVER_STATE_START;
34666 struct acpi_processor_cx *cx;
34667 - struct cpuidle_state *state;
34668 + cpuidle_state_no_const *state;
34669 struct cpuidle_driver *drv = &acpi_idle_driver;
34670
34671 if (!pr->flags.power_setup_done)
34672 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34673 index 05306a5..733d1f0 100644
34674 --- a/drivers/acpi/sysfs.c
34675 +++ b/drivers/acpi/sysfs.c
34676 @@ -423,11 +423,11 @@ static u32 num_counters;
34677 static struct attribute **all_attrs;
34678 static u32 acpi_gpe_count;
34679
34680 -static struct attribute_group interrupt_stats_attr_group = {
34681 +static attribute_group_no_const interrupt_stats_attr_group = {
34682 .name = "interrupts",
34683 };
34684
34685 -static struct kobj_attribute *counter_attrs;
34686 +static kobj_attribute_no_const *counter_attrs;
34687
34688 static void delete_gpe_attr_array(void)
34689 {
34690 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34691 index acfd0f7..e5acb08 100644
34692 --- a/drivers/ata/libahci.c
34693 +++ b/drivers/ata/libahci.c
34694 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34695 }
34696 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34697
34698 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34699 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34700 struct ata_taskfile *tf, int is_cmd, u16 flags,
34701 unsigned long timeout_msec)
34702 {
34703 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34704 index c24354d..335c975 100644
34705 --- a/drivers/ata/libata-core.c
34706 +++ b/drivers/ata/libata-core.c
34707 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34708 static void ata_dev_xfermask(struct ata_device *dev);
34709 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34710
34711 -atomic_t ata_print_id = ATOMIC_INIT(0);
34712 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34713
34714 struct ata_force_param {
34715 const char *name;
34716 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34717 struct ata_port *ap;
34718 unsigned int tag;
34719
34720 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34721 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34722 ap = qc->ap;
34723
34724 qc->flags = 0;
34725 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34726 struct ata_port *ap;
34727 struct ata_link *link;
34728
34729 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34730 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34731 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34732 ap = qc->ap;
34733 link = qc->dev->link;
34734 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34735 return;
34736
34737 spin_lock(&lock);
34738 + pax_open_kernel();
34739
34740 for (cur = ops->inherits; cur; cur = cur->inherits) {
34741 void **inherit = (void **)cur;
34742 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34743 if (IS_ERR(*pp))
34744 *pp = NULL;
34745
34746 - ops->inherits = NULL;
34747 + *(struct ata_port_operations **)&ops->inherits = NULL;
34748
34749 + pax_close_kernel();
34750 spin_unlock(&lock);
34751 }
34752
34753 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34754
34755 /* give ports names and add SCSI hosts */
34756 for (i = 0; i < host->n_ports; i++) {
34757 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34758 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34759 host->ports[i]->local_port_no = i + 1;
34760 }
34761
34762 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34763 index b1e880a..8cf82e1 100644
34764 --- a/drivers/ata/libata-scsi.c
34765 +++ b/drivers/ata/libata-scsi.c
34766 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34767
34768 if (rc)
34769 return rc;
34770 - ap->print_id = atomic_inc_return(&ata_print_id);
34771 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34772 return 0;
34773 }
34774 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34775 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34776 index 577d902b..cb4781e 100644
34777 --- a/drivers/ata/libata.h
34778 +++ b/drivers/ata/libata.h
34779 @@ -53,7 +53,7 @@ enum {
34780 ATA_DNXFER_QUIET = (1 << 31),
34781 };
34782
34783 -extern atomic_t ata_print_id;
34784 +extern atomic_unchecked_t ata_print_id;
34785 extern int atapi_passthru16;
34786 extern int libata_fua;
34787 extern int libata_noacpi;
34788 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34789 index 848ed32..132f39d 100644
34790 --- a/drivers/ata/pata_arasan_cf.c
34791 +++ b/drivers/ata/pata_arasan_cf.c
34792 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34793 /* Handle platform specific quirks */
34794 if (quirk) {
34795 if (quirk & CF_BROKEN_PIO) {
34796 - ap->ops->set_piomode = NULL;
34797 + pax_open_kernel();
34798 + *(void **)&ap->ops->set_piomode = NULL;
34799 + pax_close_kernel();
34800 ap->pio_mask = 0;
34801 }
34802 if (quirk & CF_BROKEN_MWDMA)
34803 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34804 index f9b983a..887b9d8 100644
34805 --- a/drivers/atm/adummy.c
34806 +++ b/drivers/atm/adummy.c
34807 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34808 vcc->pop(vcc, skb);
34809 else
34810 dev_kfree_skb_any(skb);
34811 - atomic_inc(&vcc->stats->tx);
34812 + atomic_inc_unchecked(&vcc->stats->tx);
34813
34814 return 0;
34815 }
34816 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34817 index 62a7607..cc4be104 100644
34818 --- a/drivers/atm/ambassador.c
34819 +++ b/drivers/atm/ambassador.c
34820 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34821 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34822
34823 // VC layer stats
34824 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34825 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34826
34827 // free the descriptor
34828 kfree (tx_descr);
34829 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34830 dump_skb ("<<<", vc, skb);
34831
34832 // VC layer stats
34833 - atomic_inc(&atm_vcc->stats->rx);
34834 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34835 __net_timestamp(skb);
34836 // end of our responsibility
34837 atm_vcc->push (atm_vcc, skb);
34838 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34839 } else {
34840 PRINTK (KERN_INFO, "dropped over-size frame");
34841 // should we count this?
34842 - atomic_inc(&atm_vcc->stats->rx_drop);
34843 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34844 }
34845
34846 } else {
34847 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34848 }
34849
34850 if (check_area (skb->data, skb->len)) {
34851 - atomic_inc(&atm_vcc->stats->tx_err);
34852 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34853 return -ENOMEM; // ?
34854 }
34855
34856 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34857 index 0e3f8f9..765a7a5 100644
34858 --- a/drivers/atm/atmtcp.c
34859 +++ b/drivers/atm/atmtcp.c
34860 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34861 if (vcc->pop) vcc->pop(vcc,skb);
34862 else dev_kfree_skb(skb);
34863 if (dev_data) return 0;
34864 - atomic_inc(&vcc->stats->tx_err);
34865 + atomic_inc_unchecked(&vcc->stats->tx_err);
34866 return -ENOLINK;
34867 }
34868 size = skb->len+sizeof(struct atmtcp_hdr);
34869 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34870 if (!new_skb) {
34871 if (vcc->pop) vcc->pop(vcc,skb);
34872 else dev_kfree_skb(skb);
34873 - atomic_inc(&vcc->stats->tx_err);
34874 + atomic_inc_unchecked(&vcc->stats->tx_err);
34875 return -ENOBUFS;
34876 }
34877 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34878 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34879 if (vcc->pop) vcc->pop(vcc,skb);
34880 else dev_kfree_skb(skb);
34881 out_vcc->push(out_vcc,new_skb);
34882 - atomic_inc(&vcc->stats->tx);
34883 - atomic_inc(&out_vcc->stats->rx);
34884 + atomic_inc_unchecked(&vcc->stats->tx);
34885 + atomic_inc_unchecked(&out_vcc->stats->rx);
34886 return 0;
34887 }
34888
34889 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34890 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34891 read_unlock(&vcc_sklist_lock);
34892 if (!out_vcc) {
34893 - atomic_inc(&vcc->stats->tx_err);
34894 + atomic_inc_unchecked(&vcc->stats->tx_err);
34895 goto done;
34896 }
34897 skb_pull(skb,sizeof(struct atmtcp_hdr));
34898 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34899 __net_timestamp(new_skb);
34900 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34901 out_vcc->push(out_vcc,new_skb);
34902 - atomic_inc(&vcc->stats->tx);
34903 - atomic_inc(&out_vcc->stats->rx);
34904 + atomic_inc_unchecked(&vcc->stats->tx);
34905 + atomic_inc_unchecked(&out_vcc->stats->rx);
34906 done:
34907 if (vcc->pop) vcc->pop(vcc,skb);
34908 else dev_kfree_skb(skb);
34909 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34910 index b1955ba..b179940 100644
34911 --- a/drivers/atm/eni.c
34912 +++ b/drivers/atm/eni.c
34913 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34914 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34915 vcc->dev->number);
34916 length = 0;
34917 - atomic_inc(&vcc->stats->rx_err);
34918 + atomic_inc_unchecked(&vcc->stats->rx_err);
34919 }
34920 else {
34921 length = ATM_CELL_SIZE-1; /* no HEC */
34922 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34923 size);
34924 }
34925 eff = length = 0;
34926 - atomic_inc(&vcc->stats->rx_err);
34927 + atomic_inc_unchecked(&vcc->stats->rx_err);
34928 }
34929 else {
34930 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34931 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34932 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34933 vcc->dev->number,vcc->vci,length,size << 2,descr);
34934 length = eff = 0;
34935 - atomic_inc(&vcc->stats->rx_err);
34936 + atomic_inc_unchecked(&vcc->stats->rx_err);
34937 }
34938 }
34939 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34940 @@ -767,7 +767,7 @@ rx_dequeued++;
34941 vcc->push(vcc,skb);
34942 pushed++;
34943 }
34944 - atomic_inc(&vcc->stats->rx);
34945 + atomic_inc_unchecked(&vcc->stats->rx);
34946 }
34947 wake_up(&eni_dev->rx_wait);
34948 }
34949 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34950 PCI_DMA_TODEVICE);
34951 if (vcc->pop) vcc->pop(vcc,skb);
34952 else dev_kfree_skb_irq(skb);
34953 - atomic_inc(&vcc->stats->tx);
34954 + atomic_inc_unchecked(&vcc->stats->tx);
34955 wake_up(&eni_dev->tx_wait);
34956 dma_complete++;
34957 }
34958 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34959 index b41c948..a002b17 100644
34960 --- a/drivers/atm/firestream.c
34961 +++ b/drivers/atm/firestream.c
34962 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34963 }
34964 }
34965
34966 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34967 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34968
34969 fs_dprintk (FS_DEBUG_TXMEM, "i");
34970 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34971 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34972 #endif
34973 skb_put (skb, qe->p1 & 0xffff);
34974 ATM_SKB(skb)->vcc = atm_vcc;
34975 - atomic_inc(&atm_vcc->stats->rx);
34976 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34977 __net_timestamp(skb);
34978 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34979 atm_vcc->push (atm_vcc, skb);
34980 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34981 kfree (pe);
34982 }
34983 if (atm_vcc)
34984 - atomic_inc(&atm_vcc->stats->rx_drop);
34985 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34986 break;
34987 case 0x1f: /* Reassembly abort: no buffers. */
34988 /* Silently increment error counter. */
34989 if (atm_vcc)
34990 - atomic_inc(&atm_vcc->stats->rx_drop);
34991 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34992 break;
34993 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34994 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34995 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34996 index 204814e..cede831 100644
34997 --- a/drivers/atm/fore200e.c
34998 +++ b/drivers/atm/fore200e.c
34999 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35000 #endif
35001 /* check error condition */
35002 if (*entry->status & STATUS_ERROR)
35003 - atomic_inc(&vcc->stats->tx_err);
35004 + atomic_inc_unchecked(&vcc->stats->tx_err);
35005 else
35006 - atomic_inc(&vcc->stats->tx);
35007 + atomic_inc_unchecked(&vcc->stats->tx);
35008 }
35009 }
35010
35011 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35012 if (skb == NULL) {
35013 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35014
35015 - atomic_inc(&vcc->stats->rx_drop);
35016 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35017 return -ENOMEM;
35018 }
35019
35020 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35021
35022 dev_kfree_skb_any(skb);
35023
35024 - atomic_inc(&vcc->stats->rx_drop);
35025 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35026 return -ENOMEM;
35027 }
35028
35029 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35030
35031 vcc->push(vcc, skb);
35032 - atomic_inc(&vcc->stats->rx);
35033 + atomic_inc_unchecked(&vcc->stats->rx);
35034
35035 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35036
35037 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35038 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35039 fore200e->atm_dev->number,
35040 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35041 - atomic_inc(&vcc->stats->rx_err);
35042 + atomic_inc_unchecked(&vcc->stats->rx_err);
35043 }
35044 }
35045
35046 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35047 goto retry_here;
35048 }
35049
35050 - atomic_inc(&vcc->stats->tx_err);
35051 + atomic_inc_unchecked(&vcc->stats->tx_err);
35052
35053 fore200e->tx_sat++;
35054 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35055 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35056 index 507362a..a845e57 100644
35057 --- a/drivers/atm/he.c
35058 +++ b/drivers/atm/he.c
35059 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35060
35061 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35062 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35063 - atomic_inc(&vcc->stats->rx_drop);
35064 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35065 goto return_host_buffers;
35066 }
35067
35068 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35069 RBRQ_LEN_ERR(he_dev->rbrq_head)
35070 ? "LEN_ERR" : "",
35071 vcc->vpi, vcc->vci);
35072 - atomic_inc(&vcc->stats->rx_err);
35073 + atomic_inc_unchecked(&vcc->stats->rx_err);
35074 goto return_host_buffers;
35075 }
35076
35077 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35078 vcc->push(vcc, skb);
35079 spin_lock(&he_dev->global_lock);
35080
35081 - atomic_inc(&vcc->stats->rx);
35082 + atomic_inc_unchecked(&vcc->stats->rx);
35083
35084 return_host_buffers:
35085 ++pdus_assembled;
35086 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35087 tpd->vcc->pop(tpd->vcc, tpd->skb);
35088 else
35089 dev_kfree_skb_any(tpd->skb);
35090 - atomic_inc(&tpd->vcc->stats->tx_err);
35091 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35092 }
35093 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35094 return;
35095 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35096 vcc->pop(vcc, skb);
35097 else
35098 dev_kfree_skb_any(skb);
35099 - atomic_inc(&vcc->stats->tx_err);
35100 + atomic_inc_unchecked(&vcc->stats->tx_err);
35101 return -EINVAL;
35102 }
35103
35104 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35105 vcc->pop(vcc, skb);
35106 else
35107 dev_kfree_skb_any(skb);
35108 - atomic_inc(&vcc->stats->tx_err);
35109 + atomic_inc_unchecked(&vcc->stats->tx_err);
35110 return -EINVAL;
35111 }
35112 #endif
35113 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35114 vcc->pop(vcc, skb);
35115 else
35116 dev_kfree_skb_any(skb);
35117 - atomic_inc(&vcc->stats->tx_err);
35118 + atomic_inc_unchecked(&vcc->stats->tx_err);
35119 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35120 return -ENOMEM;
35121 }
35122 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35123 vcc->pop(vcc, skb);
35124 else
35125 dev_kfree_skb_any(skb);
35126 - atomic_inc(&vcc->stats->tx_err);
35127 + atomic_inc_unchecked(&vcc->stats->tx_err);
35128 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35129 return -ENOMEM;
35130 }
35131 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35132 __enqueue_tpd(he_dev, tpd, cid);
35133 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35134
35135 - atomic_inc(&vcc->stats->tx);
35136 + atomic_inc_unchecked(&vcc->stats->tx);
35137
35138 return 0;
35139 }
35140 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35141 index 1dc0519..1aadaf7 100644
35142 --- a/drivers/atm/horizon.c
35143 +++ b/drivers/atm/horizon.c
35144 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35145 {
35146 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35147 // VC layer stats
35148 - atomic_inc(&vcc->stats->rx);
35149 + atomic_inc_unchecked(&vcc->stats->rx);
35150 __net_timestamp(skb);
35151 // end of our responsibility
35152 vcc->push (vcc, skb);
35153 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35154 dev->tx_iovec = NULL;
35155
35156 // VC layer stats
35157 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35158 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35159
35160 // free the skb
35161 hrz_kfree_skb (skb);
35162 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35163 index 272f009..a18ba55 100644
35164 --- a/drivers/atm/idt77252.c
35165 +++ b/drivers/atm/idt77252.c
35166 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35167 else
35168 dev_kfree_skb(skb);
35169
35170 - atomic_inc(&vcc->stats->tx);
35171 + atomic_inc_unchecked(&vcc->stats->tx);
35172 }
35173
35174 atomic_dec(&scq->used);
35175 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35176 if ((sb = dev_alloc_skb(64)) == NULL) {
35177 printk("%s: Can't allocate buffers for aal0.\n",
35178 card->name);
35179 - atomic_add(i, &vcc->stats->rx_drop);
35180 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35181 break;
35182 }
35183 if (!atm_charge(vcc, sb->truesize)) {
35184 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35185 card->name);
35186 - atomic_add(i - 1, &vcc->stats->rx_drop);
35187 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35188 dev_kfree_skb(sb);
35189 break;
35190 }
35191 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35192 ATM_SKB(sb)->vcc = vcc;
35193 __net_timestamp(sb);
35194 vcc->push(vcc, sb);
35195 - atomic_inc(&vcc->stats->rx);
35196 + atomic_inc_unchecked(&vcc->stats->rx);
35197
35198 cell += ATM_CELL_PAYLOAD;
35199 }
35200 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35201 "(CDC: %08x)\n",
35202 card->name, len, rpp->len, readl(SAR_REG_CDC));
35203 recycle_rx_pool_skb(card, rpp);
35204 - atomic_inc(&vcc->stats->rx_err);
35205 + atomic_inc_unchecked(&vcc->stats->rx_err);
35206 return;
35207 }
35208 if (stat & SAR_RSQE_CRC) {
35209 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35210 recycle_rx_pool_skb(card, rpp);
35211 - atomic_inc(&vcc->stats->rx_err);
35212 + atomic_inc_unchecked(&vcc->stats->rx_err);
35213 return;
35214 }
35215 if (skb_queue_len(&rpp->queue) > 1) {
35216 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35217 RXPRINTK("%s: Can't alloc RX skb.\n",
35218 card->name);
35219 recycle_rx_pool_skb(card, rpp);
35220 - atomic_inc(&vcc->stats->rx_err);
35221 + atomic_inc_unchecked(&vcc->stats->rx_err);
35222 return;
35223 }
35224 if (!atm_charge(vcc, skb->truesize)) {
35225 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35226 __net_timestamp(skb);
35227
35228 vcc->push(vcc, skb);
35229 - atomic_inc(&vcc->stats->rx);
35230 + atomic_inc_unchecked(&vcc->stats->rx);
35231
35232 return;
35233 }
35234 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35235 __net_timestamp(skb);
35236
35237 vcc->push(vcc, skb);
35238 - atomic_inc(&vcc->stats->rx);
35239 + atomic_inc_unchecked(&vcc->stats->rx);
35240
35241 if (skb->truesize > SAR_FB_SIZE_3)
35242 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35243 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35244 if (vcc->qos.aal != ATM_AAL0) {
35245 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35246 card->name, vpi, vci);
35247 - atomic_inc(&vcc->stats->rx_drop);
35248 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35249 goto drop;
35250 }
35251
35252 if ((sb = dev_alloc_skb(64)) == NULL) {
35253 printk("%s: Can't allocate buffers for AAL0.\n",
35254 card->name);
35255 - atomic_inc(&vcc->stats->rx_err);
35256 + atomic_inc_unchecked(&vcc->stats->rx_err);
35257 goto drop;
35258 }
35259
35260 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35261 ATM_SKB(sb)->vcc = vcc;
35262 __net_timestamp(sb);
35263 vcc->push(vcc, sb);
35264 - atomic_inc(&vcc->stats->rx);
35265 + atomic_inc_unchecked(&vcc->stats->rx);
35266
35267 drop:
35268 skb_pull(queue, 64);
35269 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35270
35271 if (vc == NULL) {
35272 printk("%s: NULL connection in send().\n", card->name);
35273 - atomic_inc(&vcc->stats->tx_err);
35274 + atomic_inc_unchecked(&vcc->stats->tx_err);
35275 dev_kfree_skb(skb);
35276 return -EINVAL;
35277 }
35278 if (!test_bit(VCF_TX, &vc->flags)) {
35279 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35280 - atomic_inc(&vcc->stats->tx_err);
35281 + atomic_inc_unchecked(&vcc->stats->tx_err);
35282 dev_kfree_skb(skb);
35283 return -EINVAL;
35284 }
35285 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35286 break;
35287 default:
35288 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35289 - atomic_inc(&vcc->stats->tx_err);
35290 + atomic_inc_unchecked(&vcc->stats->tx_err);
35291 dev_kfree_skb(skb);
35292 return -EINVAL;
35293 }
35294
35295 if (skb_shinfo(skb)->nr_frags != 0) {
35296 printk("%s: No scatter-gather yet.\n", card->name);
35297 - atomic_inc(&vcc->stats->tx_err);
35298 + atomic_inc_unchecked(&vcc->stats->tx_err);
35299 dev_kfree_skb(skb);
35300 return -EINVAL;
35301 }
35302 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35303
35304 err = queue_skb(card, vc, skb, oam);
35305 if (err) {
35306 - atomic_inc(&vcc->stats->tx_err);
35307 + atomic_inc_unchecked(&vcc->stats->tx_err);
35308 dev_kfree_skb(skb);
35309 return err;
35310 }
35311 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35312 skb = dev_alloc_skb(64);
35313 if (!skb) {
35314 printk("%s: Out of memory in send_oam().\n", card->name);
35315 - atomic_inc(&vcc->stats->tx_err);
35316 + atomic_inc_unchecked(&vcc->stats->tx_err);
35317 return -ENOMEM;
35318 }
35319 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35320 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35321 index 4217f29..88f547a 100644
35322 --- a/drivers/atm/iphase.c
35323 +++ b/drivers/atm/iphase.c
35324 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35325 status = (u_short) (buf_desc_ptr->desc_mode);
35326 if (status & (RX_CER | RX_PTE | RX_OFL))
35327 {
35328 - atomic_inc(&vcc->stats->rx_err);
35329 + atomic_inc_unchecked(&vcc->stats->rx_err);
35330 IF_ERR(printk("IA: bad packet, dropping it");)
35331 if (status & RX_CER) {
35332 IF_ERR(printk(" cause: packet CRC error\n");)
35333 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35334 len = dma_addr - buf_addr;
35335 if (len > iadev->rx_buf_sz) {
35336 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35337 - atomic_inc(&vcc->stats->rx_err);
35338 + atomic_inc_unchecked(&vcc->stats->rx_err);
35339 goto out_free_desc;
35340 }
35341
35342 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35343 ia_vcc = INPH_IA_VCC(vcc);
35344 if (ia_vcc == NULL)
35345 {
35346 - atomic_inc(&vcc->stats->rx_err);
35347 + atomic_inc_unchecked(&vcc->stats->rx_err);
35348 atm_return(vcc, skb->truesize);
35349 dev_kfree_skb_any(skb);
35350 goto INCR_DLE;
35351 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35352 if ((length > iadev->rx_buf_sz) || (length >
35353 (skb->len - sizeof(struct cpcs_trailer))))
35354 {
35355 - atomic_inc(&vcc->stats->rx_err);
35356 + atomic_inc_unchecked(&vcc->stats->rx_err);
35357 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35358 length, skb->len);)
35359 atm_return(vcc, skb->truesize);
35360 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35361
35362 IF_RX(printk("rx_dle_intr: skb push");)
35363 vcc->push(vcc,skb);
35364 - atomic_inc(&vcc->stats->rx);
35365 + atomic_inc_unchecked(&vcc->stats->rx);
35366 iadev->rx_pkt_cnt++;
35367 }
35368 INCR_DLE:
35369 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35370 {
35371 struct k_sonet_stats *stats;
35372 stats = &PRIV(_ia_dev[board])->sonet_stats;
35373 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35374 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35375 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35376 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35377 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35378 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35379 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35380 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35381 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35382 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35383 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35384 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35385 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35386 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35387 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35388 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35389 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35390 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35391 }
35392 ia_cmds.status = 0;
35393 break;
35394 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35395 if ((desc == 0) || (desc > iadev->num_tx_desc))
35396 {
35397 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35398 - atomic_inc(&vcc->stats->tx);
35399 + atomic_inc_unchecked(&vcc->stats->tx);
35400 if (vcc->pop)
35401 vcc->pop(vcc, skb);
35402 else
35403 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35404 ATM_DESC(skb) = vcc->vci;
35405 skb_queue_tail(&iadev->tx_dma_q, skb);
35406
35407 - atomic_inc(&vcc->stats->tx);
35408 + atomic_inc_unchecked(&vcc->stats->tx);
35409 iadev->tx_pkt_cnt++;
35410 /* Increment transaction counter */
35411 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35412
35413 #if 0
35414 /* add flow control logic */
35415 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35416 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35417 if (iavcc->vc_desc_cnt > 10) {
35418 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35419 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35420 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35421 index fa7d701..1e404c7 100644
35422 --- a/drivers/atm/lanai.c
35423 +++ b/drivers/atm/lanai.c
35424 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35425 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35426 lanai_endtx(lanai, lvcc);
35427 lanai_free_skb(lvcc->tx.atmvcc, skb);
35428 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35429 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35430 }
35431
35432 /* Try to fill the buffer - don't call unless there is backlog */
35433 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35434 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35435 __net_timestamp(skb);
35436 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35437 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35438 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35439 out:
35440 lvcc->rx.buf.ptr = end;
35441 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35442 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35443 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35444 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35445 lanai->stats.service_rxnotaal5++;
35446 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35447 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35448 return 0;
35449 }
35450 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35451 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35452 int bytes;
35453 read_unlock(&vcc_sklist_lock);
35454 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35455 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35456 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35457 lvcc->stats.x.aal5.service_trash++;
35458 bytes = (SERVICE_GET_END(s) * 16) -
35459 (((unsigned long) lvcc->rx.buf.ptr) -
35460 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35461 }
35462 if (s & SERVICE_STREAM) {
35463 read_unlock(&vcc_sklist_lock);
35464 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35465 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35466 lvcc->stats.x.aal5.service_stream++;
35467 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35468 "PDU on VCI %d!\n", lanai->number, vci);
35469 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35470 return 0;
35471 }
35472 DPRINTK("got rx crc error on vci %d\n", vci);
35473 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35474 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35475 lvcc->stats.x.aal5.service_rxcrc++;
35476 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35477 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35478 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35479 index 6587dc2..149833d 100644
35480 --- a/drivers/atm/nicstar.c
35481 +++ b/drivers/atm/nicstar.c
35482 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35483 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35484 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35485 card->index);
35486 - atomic_inc(&vcc->stats->tx_err);
35487 + atomic_inc_unchecked(&vcc->stats->tx_err);
35488 dev_kfree_skb_any(skb);
35489 return -EINVAL;
35490 }
35491 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35492 if (!vc->tx) {
35493 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35494 card->index);
35495 - atomic_inc(&vcc->stats->tx_err);
35496 + atomic_inc_unchecked(&vcc->stats->tx_err);
35497 dev_kfree_skb_any(skb);
35498 return -EINVAL;
35499 }
35500 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35501 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35502 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35503 card->index);
35504 - atomic_inc(&vcc->stats->tx_err);
35505 + atomic_inc_unchecked(&vcc->stats->tx_err);
35506 dev_kfree_skb_any(skb);
35507 return -EINVAL;
35508 }
35509
35510 if (skb_shinfo(skb)->nr_frags != 0) {
35511 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35512 - atomic_inc(&vcc->stats->tx_err);
35513 + atomic_inc_unchecked(&vcc->stats->tx_err);
35514 dev_kfree_skb_any(skb);
35515 return -EINVAL;
35516 }
35517 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35518 }
35519
35520 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35521 - atomic_inc(&vcc->stats->tx_err);
35522 + atomic_inc_unchecked(&vcc->stats->tx_err);
35523 dev_kfree_skb_any(skb);
35524 return -EIO;
35525 }
35526 - atomic_inc(&vcc->stats->tx);
35527 + atomic_inc_unchecked(&vcc->stats->tx);
35528
35529 return 0;
35530 }
35531 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35532 printk
35533 ("nicstar%d: Can't allocate buffers for aal0.\n",
35534 card->index);
35535 - atomic_add(i, &vcc->stats->rx_drop);
35536 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35537 break;
35538 }
35539 if (!atm_charge(vcc, sb->truesize)) {
35540 RXPRINTK
35541 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35542 card->index);
35543 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35544 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35545 dev_kfree_skb_any(sb);
35546 break;
35547 }
35548 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35549 ATM_SKB(sb)->vcc = vcc;
35550 __net_timestamp(sb);
35551 vcc->push(vcc, sb);
35552 - atomic_inc(&vcc->stats->rx);
35553 + atomic_inc_unchecked(&vcc->stats->rx);
35554 cell += ATM_CELL_PAYLOAD;
35555 }
35556
35557 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35558 if (iovb == NULL) {
35559 printk("nicstar%d: Out of iovec buffers.\n",
35560 card->index);
35561 - atomic_inc(&vcc->stats->rx_drop);
35562 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35563 recycle_rx_buf(card, skb);
35564 return;
35565 }
35566 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35567 small or large buffer itself. */
35568 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35569 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35570 - atomic_inc(&vcc->stats->rx_err);
35571 + atomic_inc_unchecked(&vcc->stats->rx_err);
35572 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35573 NS_MAX_IOVECS);
35574 NS_PRV_IOVCNT(iovb) = 0;
35575 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35576 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35577 card->index);
35578 which_list(card, skb);
35579 - atomic_inc(&vcc->stats->rx_err);
35580 + atomic_inc_unchecked(&vcc->stats->rx_err);
35581 recycle_rx_buf(card, skb);
35582 vc->rx_iov = NULL;
35583 recycle_iov_buf(card, iovb);
35584 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35585 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35586 card->index);
35587 which_list(card, skb);
35588 - atomic_inc(&vcc->stats->rx_err);
35589 + atomic_inc_unchecked(&vcc->stats->rx_err);
35590 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35591 NS_PRV_IOVCNT(iovb));
35592 vc->rx_iov = NULL;
35593 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35594 printk(" - PDU size mismatch.\n");
35595 else
35596 printk(".\n");
35597 - atomic_inc(&vcc->stats->rx_err);
35598 + atomic_inc_unchecked(&vcc->stats->rx_err);
35599 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35600 NS_PRV_IOVCNT(iovb));
35601 vc->rx_iov = NULL;
35602 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35603 /* skb points to a small buffer */
35604 if (!atm_charge(vcc, skb->truesize)) {
35605 push_rxbufs(card, skb);
35606 - atomic_inc(&vcc->stats->rx_drop);
35607 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35608 } else {
35609 skb_put(skb, len);
35610 dequeue_sm_buf(card, skb);
35611 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35612 ATM_SKB(skb)->vcc = vcc;
35613 __net_timestamp(skb);
35614 vcc->push(vcc, skb);
35615 - atomic_inc(&vcc->stats->rx);
35616 + atomic_inc_unchecked(&vcc->stats->rx);
35617 }
35618 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35619 struct sk_buff *sb;
35620 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35621 if (len <= NS_SMBUFSIZE) {
35622 if (!atm_charge(vcc, sb->truesize)) {
35623 push_rxbufs(card, sb);
35624 - atomic_inc(&vcc->stats->rx_drop);
35625 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35626 } else {
35627 skb_put(sb, len);
35628 dequeue_sm_buf(card, sb);
35629 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35630 ATM_SKB(sb)->vcc = vcc;
35631 __net_timestamp(sb);
35632 vcc->push(vcc, sb);
35633 - atomic_inc(&vcc->stats->rx);
35634 + atomic_inc_unchecked(&vcc->stats->rx);
35635 }
35636
35637 push_rxbufs(card, skb);
35638 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35639
35640 if (!atm_charge(vcc, skb->truesize)) {
35641 push_rxbufs(card, skb);
35642 - atomic_inc(&vcc->stats->rx_drop);
35643 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35644 } else {
35645 dequeue_lg_buf(card, skb);
35646 #ifdef NS_USE_DESTRUCTORS
35647 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35648 ATM_SKB(skb)->vcc = vcc;
35649 __net_timestamp(skb);
35650 vcc->push(vcc, skb);
35651 - atomic_inc(&vcc->stats->rx);
35652 + atomic_inc_unchecked(&vcc->stats->rx);
35653 }
35654
35655 push_rxbufs(card, sb);
35656 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35657 printk
35658 ("nicstar%d: Out of huge buffers.\n",
35659 card->index);
35660 - atomic_inc(&vcc->stats->rx_drop);
35661 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35662 recycle_iovec_rx_bufs(card,
35663 (struct iovec *)
35664 iovb->data,
35665 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35666 card->hbpool.count++;
35667 } else
35668 dev_kfree_skb_any(hb);
35669 - atomic_inc(&vcc->stats->rx_drop);
35670 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35671 } else {
35672 /* Copy the small buffer to the huge buffer */
35673 sb = (struct sk_buff *)iov->iov_base;
35674 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35675 #endif /* NS_USE_DESTRUCTORS */
35676 __net_timestamp(hb);
35677 vcc->push(vcc, hb);
35678 - atomic_inc(&vcc->stats->rx);
35679 + atomic_inc_unchecked(&vcc->stats->rx);
35680 }
35681 }
35682
35683 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35684 index 32784d1..4a8434a 100644
35685 --- a/drivers/atm/solos-pci.c
35686 +++ b/drivers/atm/solos-pci.c
35687 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35688 }
35689 atm_charge(vcc, skb->truesize);
35690 vcc->push(vcc, skb);
35691 - atomic_inc(&vcc->stats->rx);
35692 + atomic_inc_unchecked(&vcc->stats->rx);
35693 break;
35694
35695 case PKT_STATUS:
35696 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35697 vcc = SKB_CB(oldskb)->vcc;
35698
35699 if (vcc) {
35700 - atomic_inc(&vcc->stats->tx);
35701 + atomic_inc_unchecked(&vcc->stats->tx);
35702 solos_pop(vcc, oldskb);
35703 } else {
35704 dev_kfree_skb_irq(oldskb);
35705 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35706 index 0215934..ce9f5b1 100644
35707 --- a/drivers/atm/suni.c
35708 +++ b/drivers/atm/suni.c
35709 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35710
35711
35712 #define ADD_LIMITED(s,v) \
35713 - atomic_add((v),&stats->s); \
35714 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35715 + atomic_add_unchecked((v),&stats->s); \
35716 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35717
35718
35719 static void suni_hz(unsigned long from_timer)
35720 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35721 index 5120a96..e2572bd 100644
35722 --- a/drivers/atm/uPD98402.c
35723 +++ b/drivers/atm/uPD98402.c
35724 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35725 struct sonet_stats tmp;
35726 int error = 0;
35727
35728 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35729 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35730 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35731 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35732 if (zero && !error) {
35733 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35734
35735
35736 #define ADD_LIMITED(s,v) \
35737 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35738 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35739 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35740 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35741 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35742 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35743
35744
35745 static void stat_event(struct atm_dev *dev)
35746 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35747 if (reason & uPD98402_INT_PFM) stat_event(dev);
35748 if (reason & uPD98402_INT_PCO) {
35749 (void) GET(PCOCR); /* clear interrupt cause */
35750 - atomic_add(GET(HECCT),
35751 + atomic_add_unchecked(GET(HECCT),
35752 &PRIV(dev)->sonet_stats.uncorr_hcs);
35753 }
35754 if ((reason & uPD98402_INT_RFO) &&
35755 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35756 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35757 uPD98402_INT_LOS),PIMR); /* enable them */
35758 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35759 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35760 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35761 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35762 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35763 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35764 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35765 return 0;
35766 }
35767
35768 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35769 index 969c3c2..9b72956 100644
35770 --- a/drivers/atm/zatm.c
35771 +++ b/drivers/atm/zatm.c
35772 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35773 }
35774 if (!size) {
35775 dev_kfree_skb_irq(skb);
35776 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35777 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35778 continue;
35779 }
35780 if (!atm_charge(vcc,skb->truesize)) {
35781 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35782 skb->len = size;
35783 ATM_SKB(skb)->vcc = vcc;
35784 vcc->push(vcc,skb);
35785 - atomic_inc(&vcc->stats->rx);
35786 + atomic_inc_unchecked(&vcc->stats->rx);
35787 }
35788 zout(pos & 0xffff,MTA(mbx));
35789 #if 0 /* probably a stupid idea */
35790 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35791 skb_queue_head(&zatm_vcc->backlog,skb);
35792 break;
35793 }
35794 - atomic_inc(&vcc->stats->tx);
35795 + atomic_inc_unchecked(&vcc->stats->tx);
35796 wake_up(&zatm_vcc->tx_wait);
35797 }
35798
35799 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35800 index d414331..b4dd4ba 100644
35801 --- a/drivers/base/bus.c
35802 +++ b/drivers/base/bus.c
35803 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35804 return -EINVAL;
35805
35806 mutex_lock(&subsys->p->mutex);
35807 - list_add_tail(&sif->node, &subsys->p->interfaces);
35808 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35809 if (sif->add_dev) {
35810 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35811 while ((dev = subsys_dev_iter_next(&iter)))
35812 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35813 subsys = sif->subsys;
35814
35815 mutex_lock(&subsys->p->mutex);
35816 - list_del_init(&sif->node);
35817 + pax_list_del_init((struct list_head *)&sif->node);
35818 if (sif->remove_dev) {
35819 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35820 while ((dev = subsys_dev_iter_next(&iter)))
35821 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35822 index 7413d06..79155fa 100644
35823 --- a/drivers/base/devtmpfs.c
35824 +++ b/drivers/base/devtmpfs.c
35825 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35826 if (!thread)
35827 return 0;
35828
35829 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35830 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35831 if (err)
35832 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35833 else
35834 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35835 *err = sys_unshare(CLONE_NEWNS);
35836 if (*err)
35837 goto out;
35838 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35839 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35840 if (*err)
35841 goto out;
35842 - sys_chdir("/.."); /* will traverse into overmounted root */
35843 - sys_chroot(".");
35844 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35845 + sys_chroot((char __force_user *)".");
35846 complete(&setup_done);
35847 while (1) {
35848 spin_lock(&req_lock);
35849 diff --git a/drivers/base/node.c b/drivers/base/node.c
35850 index 7616a77c..8f57f51 100644
35851 --- a/drivers/base/node.c
35852 +++ b/drivers/base/node.c
35853 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35854 struct node_attr {
35855 struct device_attribute attr;
35856 enum node_states state;
35857 -};
35858 +} __do_const;
35859
35860 static ssize_t show_node_state(struct device *dev,
35861 struct device_attribute *attr, char *buf)
35862 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35863 index bfb8955..42c9b9a 100644
35864 --- a/drivers/base/power/domain.c
35865 +++ b/drivers/base/power/domain.c
35866 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35867 {
35868 struct cpuidle_driver *cpuidle_drv;
35869 struct gpd_cpu_data *cpu_data;
35870 - struct cpuidle_state *idle_state;
35871 + cpuidle_state_no_const *idle_state;
35872 int ret = 0;
35873
35874 if (IS_ERR_OR_NULL(genpd) || state < 0)
35875 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35876 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35877 {
35878 struct gpd_cpu_data *cpu_data;
35879 - struct cpuidle_state *idle_state;
35880 + cpuidle_state_no_const *idle_state;
35881 int ret = 0;
35882
35883 if (IS_ERR_OR_NULL(genpd))
35884 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35885 index a53ebd2..8f73eeb 100644
35886 --- a/drivers/base/power/sysfs.c
35887 +++ b/drivers/base/power/sysfs.c
35888 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35889 return -EIO;
35890 }
35891 }
35892 - return sprintf(buf, p);
35893 + return sprintf(buf, "%s", p);
35894 }
35895
35896 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35897 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35898 index 2d56f41..8830f19 100644
35899 --- a/drivers/base/power/wakeup.c
35900 +++ b/drivers/base/power/wakeup.c
35901 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35902 * They need to be modified together atomically, so it's better to use one
35903 * atomic variable to hold them both.
35904 */
35905 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35906 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35907
35908 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35909 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35910
35911 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35912 {
35913 - unsigned int comb = atomic_read(&combined_event_count);
35914 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35915
35916 *cnt = (comb >> IN_PROGRESS_BITS);
35917 *inpr = comb & MAX_IN_PROGRESS;
35918 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35919 ws->start_prevent_time = ws->last_time;
35920
35921 /* Increment the counter of events in progress. */
35922 - cec = atomic_inc_return(&combined_event_count);
35923 + cec = atomic_inc_return_unchecked(&combined_event_count);
35924
35925 trace_wakeup_source_activate(ws->name, cec);
35926 }
35927 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35928 * Increment the counter of registered wakeup events and decrement the
35929 * couter of wakeup events in progress simultaneously.
35930 */
35931 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35932 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35933 trace_wakeup_source_deactivate(ws->name, cec);
35934
35935 split_counters(&cnt, &inpr);
35936 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35937 index e8d11b6..7b1b36f 100644
35938 --- a/drivers/base/syscore.c
35939 +++ b/drivers/base/syscore.c
35940 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35941 void register_syscore_ops(struct syscore_ops *ops)
35942 {
35943 mutex_lock(&syscore_ops_lock);
35944 - list_add_tail(&ops->node, &syscore_ops_list);
35945 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35946 mutex_unlock(&syscore_ops_lock);
35947 }
35948 EXPORT_SYMBOL_GPL(register_syscore_ops);
35949 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35950 void unregister_syscore_ops(struct syscore_ops *ops)
35951 {
35952 mutex_lock(&syscore_ops_lock);
35953 - list_del(&ops->node);
35954 + pax_list_del((struct list_head *)&ops->node);
35955 mutex_unlock(&syscore_ops_lock);
35956 }
35957 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35958 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35959 index 90a4e6b..002d10f 100644
35960 --- a/drivers/block/cciss.c
35961 +++ b/drivers/block/cciss.c
35962 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35963 while (!list_empty(&h->reqQ)) {
35964 c = list_entry(h->reqQ.next, CommandList_struct, list);
35965 /* can't do anything if fifo is full */
35966 - if ((h->access.fifo_full(h))) {
35967 + if ((h->access->fifo_full(h))) {
35968 dev_warn(&h->pdev->dev, "fifo full\n");
35969 break;
35970 }
35971 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35972 h->Qdepth--;
35973
35974 /* Tell the controller execute command */
35975 - h->access.submit_command(h, c);
35976 + h->access->submit_command(h, c);
35977
35978 /* Put job onto the completed Q */
35979 addQ(&h->cmpQ, c);
35980 @@ -3447,17 +3447,17 @@ startio:
35981
35982 static inline unsigned long get_next_completion(ctlr_info_t *h)
35983 {
35984 - return h->access.command_completed(h);
35985 + return h->access->command_completed(h);
35986 }
35987
35988 static inline int interrupt_pending(ctlr_info_t *h)
35989 {
35990 - return h->access.intr_pending(h);
35991 + return h->access->intr_pending(h);
35992 }
35993
35994 static inline long interrupt_not_for_us(ctlr_info_t *h)
35995 {
35996 - return ((h->access.intr_pending(h) == 0) ||
35997 + return ((h->access->intr_pending(h) == 0) ||
35998 (h->interrupts_enabled == 0));
35999 }
36000
36001 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36002 u32 a;
36003
36004 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36005 - return h->access.command_completed(h);
36006 + return h->access->command_completed(h);
36007
36008 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36009 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36010 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36011 trans_support & CFGTBL_Trans_use_short_tags);
36012
36013 /* Change the access methods to the performant access methods */
36014 - h->access = SA5_performant_access;
36015 + h->access = &SA5_performant_access;
36016 h->transMethod = CFGTBL_Trans_Performant;
36017
36018 return;
36019 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36020 if (prod_index < 0)
36021 return -ENODEV;
36022 h->product_name = products[prod_index].product_name;
36023 - h->access = *(products[prod_index].access);
36024 + h->access = products[prod_index].access;
36025
36026 if (cciss_board_disabled(h)) {
36027 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36028 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36029 }
36030
36031 /* make sure the board interrupts are off */
36032 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36033 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36034 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36035 if (rc)
36036 goto clean2;
36037 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36038 * fake ones to scoop up any residual completions.
36039 */
36040 spin_lock_irqsave(&h->lock, flags);
36041 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36042 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36043 spin_unlock_irqrestore(&h->lock, flags);
36044 free_irq(h->intr[h->intr_mode], h);
36045 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36046 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36047 dev_info(&h->pdev->dev, "Board READY.\n");
36048 dev_info(&h->pdev->dev,
36049 "Waiting for stale completions to drain.\n");
36050 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36051 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36052 msleep(10000);
36053 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36054 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36055
36056 rc = controller_reset_failed(h->cfgtable);
36057 if (rc)
36058 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36059 cciss_scsi_setup(h);
36060
36061 /* Turn the interrupts on so we can service requests */
36062 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36063 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36064
36065 /* Get the firmware version */
36066 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36067 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36068 kfree(flush_buf);
36069 if (return_code != IO_OK)
36070 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36071 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36072 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36073 free_irq(h->intr[h->intr_mode], h);
36074 }
36075
36076 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36077 index 7fda30e..eb5dfe0 100644
36078 --- a/drivers/block/cciss.h
36079 +++ b/drivers/block/cciss.h
36080 @@ -101,7 +101,7 @@ struct ctlr_info
36081 /* information about each logical volume */
36082 drive_info_struct *drv[CISS_MAX_LUN];
36083
36084 - struct access_method access;
36085 + struct access_method *access;
36086
36087 /* queue and queue Info */
36088 struct list_head reqQ;
36089 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36090 index 2b94403..fd6ad1f 100644
36091 --- a/drivers/block/cpqarray.c
36092 +++ b/drivers/block/cpqarray.c
36093 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36094 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36095 goto Enomem4;
36096 }
36097 - hba[i]->access.set_intr_mask(hba[i], 0);
36098 + hba[i]->access->set_intr_mask(hba[i], 0);
36099 if (request_irq(hba[i]->intr, do_ida_intr,
36100 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36101 {
36102 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36103 add_timer(&hba[i]->timer);
36104
36105 /* Enable IRQ now that spinlock and rate limit timer are set up */
36106 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36107 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36108
36109 for(j=0; j<NWD; j++) {
36110 struct gendisk *disk = ida_gendisk[i][j];
36111 @@ -694,7 +694,7 @@ DBGINFO(
36112 for(i=0; i<NR_PRODUCTS; i++) {
36113 if (board_id == products[i].board_id) {
36114 c->product_name = products[i].product_name;
36115 - c->access = *(products[i].access);
36116 + c->access = products[i].access;
36117 break;
36118 }
36119 }
36120 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36121 hba[ctlr]->intr = intr;
36122 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36123 hba[ctlr]->product_name = products[j].product_name;
36124 - hba[ctlr]->access = *(products[j].access);
36125 + hba[ctlr]->access = products[j].access;
36126 hba[ctlr]->ctlr = ctlr;
36127 hba[ctlr]->board_id = board_id;
36128 hba[ctlr]->pci_dev = NULL; /* not PCI */
36129 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36130
36131 while((c = h->reqQ) != NULL) {
36132 /* Can't do anything if we're busy */
36133 - if (h->access.fifo_full(h) == 0)
36134 + if (h->access->fifo_full(h) == 0)
36135 return;
36136
36137 /* Get the first entry from the request Q */
36138 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36139 h->Qdepth--;
36140
36141 /* Tell the controller to do our bidding */
36142 - h->access.submit_command(h, c);
36143 + h->access->submit_command(h, c);
36144
36145 /* Get onto the completion Q */
36146 addQ(&h->cmpQ, c);
36147 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36148 unsigned long flags;
36149 __u32 a,a1;
36150
36151 - istat = h->access.intr_pending(h);
36152 + istat = h->access->intr_pending(h);
36153 /* Is this interrupt for us? */
36154 if (istat == 0)
36155 return IRQ_NONE;
36156 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36157 */
36158 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36159 if (istat & FIFO_NOT_EMPTY) {
36160 - while((a = h->access.command_completed(h))) {
36161 + while((a = h->access->command_completed(h))) {
36162 a1 = a; a &= ~3;
36163 if ((c = h->cmpQ) == NULL)
36164 {
36165 @@ -1448,11 +1448,11 @@ static int sendcmd(
36166 /*
36167 * Disable interrupt
36168 */
36169 - info_p->access.set_intr_mask(info_p, 0);
36170 + info_p->access->set_intr_mask(info_p, 0);
36171 /* Make sure there is room in the command FIFO */
36172 /* Actually it should be completely empty at this time. */
36173 for (i = 200000; i > 0; i--) {
36174 - temp = info_p->access.fifo_full(info_p);
36175 + temp = info_p->access->fifo_full(info_p);
36176 if (temp != 0) {
36177 break;
36178 }
36179 @@ -1465,7 +1465,7 @@ DBG(
36180 /*
36181 * Send the cmd
36182 */
36183 - info_p->access.submit_command(info_p, c);
36184 + info_p->access->submit_command(info_p, c);
36185 complete = pollcomplete(ctlr);
36186
36187 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36188 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36189 * we check the new geometry. Then turn interrupts back on when
36190 * we're done.
36191 */
36192 - host->access.set_intr_mask(host, 0);
36193 + host->access->set_intr_mask(host, 0);
36194 getgeometry(ctlr);
36195 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36196 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36197
36198 for(i=0; i<NWD; i++) {
36199 struct gendisk *disk = ida_gendisk[ctlr][i];
36200 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36201 /* Wait (up to 2 seconds) for a command to complete */
36202
36203 for (i = 200000; i > 0; i--) {
36204 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36205 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36206 if (done == 0) {
36207 udelay(10); /* a short fixed delay */
36208 } else
36209 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36210 index be73e9d..7fbf140 100644
36211 --- a/drivers/block/cpqarray.h
36212 +++ b/drivers/block/cpqarray.h
36213 @@ -99,7 +99,7 @@ struct ctlr_info {
36214 drv_info_t drv[NWD];
36215 struct proc_dir_entry *proc;
36216
36217 - struct access_method access;
36218 + struct access_method *access;
36219
36220 cmdlist_t *reqQ;
36221 cmdlist_t *cmpQ;
36222 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36223 index 2d7f608..11245fe 100644
36224 --- a/drivers/block/drbd/drbd_int.h
36225 +++ b/drivers/block/drbd/drbd_int.h
36226 @@ -582,7 +582,7 @@ struct drbd_epoch {
36227 struct drbd_tconn *tconn;
36228 struct list_head list;
36229 unsigned int barrier_nr;
36230 - atomic_t epoch_size; /* increased on every request added. */
36231 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36232 atomic_t active; /* increased on every req. added, and dec on every finished. */
36233 unsigned long flags;
36234 };
36235 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36236 unsigned int al_tr_number;
36237 int al_tr_cycle;
36238 wait_queue_head_t seq_wait;
36239 - atomic_t packet_seq;
36240 + atomic_unchecked_t packet_seq;
36241 unsigned int peer_seq;
36242 spinlock_t peer_seq_lock;
36243 unsigned int minor;
36244 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36245 char __user *uoptval;
36246 int err;
36247
36248 - uoptval = (char __user __force *)optval;
36249 + uoptval = (char __force_user *)optval;
36250
36251 set_fs(KERNEL_DS);
36252 if (level == SOL_SOCKET)
36253 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36254 index 55635ed..40e837c 100644
36255 --- a/drivers/block/drbd/drbd_main.c
36256 +++ b/drivers/block/drbd/drbd_main.c
36257 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36258 p->sector = sector;
36259 p->block_id = block_id;
36260 p->blksize = blksize;
36261 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36262 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36263 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36264 }
36265
36266 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36267 return -EIO;
36268 p->sector = cpu_to_be64(req->i.sector);
36269 p->block_id = (unsigned long)req;
36270 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36271 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36272 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36273 if (mdev->state.conn >= C_SYNC_SOURCE &&
36274 mdev->state.conn <= C_PAUSED_SYNC_T)
36275 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36276 {
36277 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36278
36279 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36280 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36281 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36282 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36283 kfree(tconn->current_epoch);
36284
36285 idr_destroy(&tconn->volumes);
36286 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36287 index 8cc1e64..ba7ffa9 100644
36288 --- a/drivers/block/drbd/drbd_nl.c
36289 +++ b/drivers/block/drbd/drbd_nl.c
36290 @@ -3440,7 +3440,7 @@ out:
36291
36292 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36293 {
36294 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36295 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36296 struct sk_buff *msg;
36297 struct drbd_genlmsghdr *d_out;
36298 unsigned seq;
36299 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36300 return;
36301 }
36302
36303 - seq = atomic_inc_return(&drbd_genl_seq);
36304 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36305 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36306 if (!msg)
36307 goto failed;
36308 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36309 index cc29cd3..d4b058b 100644
36310 --- a/drivers/block/drbd/drbd_receiver.c
36311 +++ b/drivers/block/drbd/drbd_receiver.c
36312 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36313 {
36314 int err;
36315
36316 - atomic_set(&mdev->packet_seq, 0);
36317 + atomic_set_unchecked(&mdev->packet_seq, 0);
36318 mdev->peer_seq = 0;
36319
36320 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36321 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36322 do {
36323 next_epoch = NULL;
36324
36325 - epoch_size = atomic_read(&epoch->epoch_size);
36326 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36327
36328 switch (ev & ~EV_CLEANUP) {
36329 case EV_PUT:
36330 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36331 rv = FE_DESTROYED;
36332 } else {
36333 epoch->flags = 0;
36334 - atomic_set(&epoch->epoch_size, 0);
36335 + atomic_set_unchecked(&epoch->epoch_size, 0);
36336 /* atomic_set(&epoch->active, 0); is already zero */
36337 if (rv == FE_STILL_LIVE)
36338 rv = FE_RECYCLED;
36339 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36340 conn_wait_active_ee_empty(tconn);
36341 drbd_flush(tconn);
36342
36343 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36344 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36345 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36346 if (epoch)
36347 break;
36348 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36349 }
36350
36351 epoch->flags = 0;
36352 - atomic_set(&epoch->epoch_size, 0);
36353 + atomic_set_unchecked(&epoch->epoch_size, 0);
36354 atomic_set(&epoch->active, 0);
36355
36356 spin_lock(&tconn->epoch_lock);
36357 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36358 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36359 list_add(&epoch->list, &tconn->current_epoch->list);
36360 tconn->current_epoch = epoch;
36361 tconn->epochs++;
36362 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36363
36364 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36365 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36366 - atomic_inc(&tconn->current_epoch->epoch_size);
36367 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36368 err2 = drbd_drain_block(mdev, pi->size);
36369 if (!err)
36370 err = err2;
36371 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36372
36373 spin_lock(&tconn->epoch_lock);
36374 peer_req->epoch = tconn->current_epoch;
36375 - atomic_inc(&peer_req->epoch->epoch_size);
36376 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36377 atomic_inc(&peer_req->epoch->active);
36378 spin_unlock(&tconn->epoch_lock);
36379
36380 @@ -4347,7 +4347,7 @@ struct data_cmd {
36381 int expect_payload;
36382 size_t pkt_size;
36383 int (*fn)(struct drbd_tconn *, struct packet_info *);
36384 -};
36385 +} __do_const;
36386
36387 static struct data_cmd drbd_cmd_handler[] = {
36388 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36389 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36390 if (!list_empty(&tconn->current_epoch->list))
36391 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36392 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36393 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36394 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36395 tconn->send.seen_any_write_yet = false;
36396
36397 conn_info(tconn, "Connection closed\n");
36398 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36399 struct asender_cmd {
36400 size_t pkt_size;
36401 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36402 -};
36403 +} __do_const;
36404
36405 static struct asender_cmd asender_tbl[] = {
36406 [P_PING] = { 0, got_Ping },
36407 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36408 index 40e7155..df5c79a 100644
36409 --- a/drivers/block/loop.c
36410 +++ b/drivers/block/loop.c
36411 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36412
36413 file_start_write(file);
36414 set_fs(get_ds());
36415 - bw = file->f_op->write(file, buf, len, &pos);
36416 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36417 set_fs(old_fs);
36418 file_end_write(file);
36419 if (likely(bw == len))
36420 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36421 index f5d0ea1..c62380a 100644
36422 --- a/drivers/block/pktcdvd.c
36423 +++ b/drivers/block/pktcdvd.c
36424 @@ -84,7 +84,7 @@
36425 #define MAX_SPEED 0xffff
36426
36427 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36428 - ~(sector_t)((pd)->settings.size - 1))
36429 + ~(sector_t)((pd)->settings.size - 1UL))
36430
36431 static DEFINE_MUTEX(pktcdvd_mutex);
36432 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36433 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36434 index 7332889..9ece19e 100644
36435 --- a/drivers/bus/arm-cci.c
36436 +++ b/drivers/bus/arm-cci.c
36437 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36438
36439 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36440
36441 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36442 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36443 if (!ports)
36444 return -ENOMEM;
36445
36446 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36447 index 8a3aff7..d7538c2 100644
36448 --- a/drivers/cdrom/cdrom.c
36449 +++ b/drivers/cdrom/cdrom.c
36450 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36451 ENSURE(reset, CDC_RESET);
36452 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36453 cdi->mc_flags = 0;
36454 - cdo->n_minors = 0;
36455 cdi->options = CDO_USE_FFLAGS;
36456
36457 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36458 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36459 else
36460 cdi->cdda_method = CDDA_OLD;
36461
36462 - if (!cdo->generic_packet)
36463 - cdo->generic_packet = cdrom_dummy_generic_packet;
36464 + if (!cdo->generic_packet) {
36465 + pax_open_kernel();
36466 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36467 + pax_close_kernel();
36468 + }
36469
36470 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36471 mutex_lock(&cdrom_mutex);
36472 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36473 if (cdi->exit)
36474 cdi->exit(cdi);
36475
36476 - cdi->ops->n_minors--;
36477 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36478 }
36479
36480 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36481 */
36482 nr = nframes;
36483 do {
36484 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36485 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36486 if (cgc.buffer)
36487 break;
36488
36489 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36490 struct cdrom_device_info *cdi;
36491 int ret;
36492
36493 - ret = scnprintf(info + *pos, max_size - *pos, header);
36494 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36495 if (!ret)
36496 return 1;
36497
36498 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36499 index 5980cb9..6d7bd7e 100644
36500 --- a/drivers/cdrom/gdrom.c
36501 +++ b/drivers/cdrom/gdrom.c
36502 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36503 .audio_ioctl = gdrom_audio_ioctl,
36504 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36505 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36506 - .n_minors = 1,
36507 };
36508
36509 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36510 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36511 index 1421997..33f5d6d 100644
36512 --- a/drivers/char/Kconfig
36513 +++ b/drivers/char/Kconfig
36514 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36515
36516 config DEVKMEM
36517 bool "/dev/kmem virtual device support"
36518 - default y
36519 + default n
36520 + depends on !GRKERNSEC_KMEM
36521 help
36522 Say Y here if you want to support the /dev/kmem device. The
36523 /dev/kmem device is rarely used, but can be used for certain
36524 @@ -570,6 +571,7 @@ config DEVPORT
36525 bool
36526 depends on !M68K
36527 depends on ISA || PCI
36528 + depends on !GRKERNSEC_KMEM
36529 default y
36530
36531 source "drivers/s390/char/Kconfig"
36532 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36533 index a48e05b..6bac831 100644
36534 --- a/drivers/char/agp/compat_ioctl.c
36535 +++ b/drivers/char/agp/compat_ioctl.c
36536 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36537 return -ENOMEM;
36538 }
36539
36540 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36541 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36542 sizeof(*usegment) * ureserve.seg_count)) {
36543 kfree(usegment);
36544 kfree(ksegment);
36545 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36546 index 1b19239..b87b143 100644
36547 --- a/drivers/char/agp/frontend.c
36548 +++ b/drivers/char/agp/frontend.c
36549 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36550 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36551 return -EFAULT;
36552
36553 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36554 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36555 return -EFAULT;
36556
36557 client = agp_find_client_by_pid(reserve.pid);
36558 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36559 if (segment == NULL)
36560 return -ENOMEM;
36561
36562 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36563 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36564 sizeof(struct agp_segment) * reserve.seg_count)) {
36565 kfree(segment);
36566 return -EFAULT;
36567 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36568 index 4f94375..413694e 100644
36569 --- a/drivers/char/genrtc.c
36570 +++ b/drivers/char/genrtc.c
36571 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36572 switch (cmd) {
36573
36574 case RTC_PLL_GET:
36575 + memset(&pll, 0, sizeof(pll));
36576 if (get_rtc_pll(&pll))
36577 return -EINVAL;
36578 else
36579 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36580 index 448ce5e..3a76625 100644
36581 --- a/drivers/char/hpet.c
36582 +++ b/drivers/char/hpet.c
36583 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36584 }
36585
36586 static int
36587 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36588 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36589 struct hpet_info *info)
36590 {
36591 struct hpet_timer __iomem *timer;
36592 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36593 index 86fe45c..c0ea948 100644
36594 --- a/drivers/char/hw_random/intel-rng.c
36595 +++ b/drivers/char/hw_random/intel-rng.c
36596 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36597
36598 if (no_fwh_detect)
36599 return -ENODEV;
36600 - printk(warning);
36601 + printk("%s", warning);
36602 return -EBUSY;
36603 }
36604
36605 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36606 index 4445fa1..7c6de37 100644
36607 --- a/drivers/char/ipmi/ipmi_msghandler.c
36608 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36609 @@ -420,7 +420,7 @@ struct ipmi_smi {
36610 struct proc_dir_entry *proc_dir;
36611 char proc_dir_name[10];
36612
36613 - atomic_t stats[IPMI_NUM_STATS];
36614 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36615
36616 /*
36617 * run_to_completion duplicate of smb_info, smi_info
36618 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36619
36620
36621 #define ipmi_inc_stat(intf, stat) \
36622 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36623 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36624 #define ipmi_get_stat(intf, stat) \
36625 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36626 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36627
36628 static int is_lan_addr(struct ipmi_addr *addr)
36629 {
36630 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36631 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36632 init_waitqueue_head(&intf->waitq);
36633 for (i = 0; i < IPMI_NUM_STATS; i++)
36634 - atomic_set(&intf->stats[i], 0);
36635 + atomic_set_unchecked(&intf->stats[i], 0);
36636
36637 intf->proc_dir = NULL;
36638
36639 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36640 index af4b23f..79806fc 100644
36641 --- a/drivers/char/ipmi/ipmi_si_intf.c
36642 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36643 @@ -275,7 +275,7 @@ struct smi_info {
36644 unsigned char slave_addr;
36645
36646 /* Counters and things for the proc filesystem. */
36647 - atomic_t stats[SI_NUM_STATS];
36648 + atomic_unchecked_t stats[SI_NUM_STATS];
36649
36650 struct task_struct *thread;
36651
36652 @@ -284,9 +284,9 @@ struct smi_info {
36653 };
36654
36655 #define smi_inc_stat(smi, stat) \
36656 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36657 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36658 #define smi_get_stat(smi, stat) \
36659 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36660 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36661
36662 #define SI_MAX_PARMS 4
36663
36664 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36665 atomic_set(&new_smi->req_events, 0);
36666 new_smi->run_to_completion = 0;
36667 for (i = 0; i < SI_NUM_STATS; i++)
36668 - atomic_set(&new_smi->stats[i], 0);
36669 + atomic_set_unchecked(&new_smi->stats[i], 0);
36670
36671 new_smi->interrupt_disabled = 1;
36672 atomic_set(&new_smi->stop_operation, 0);
36673 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36674 index f895a8c..2bc9147 100644
36675 --- a/drivers/char/mem.c
36676 +++ b/drivers/char/mem.c
36677 @@ -18,6 +18,7 @@
36678 #include <linux/raw.h>
36679 #include <linux/tty.h>
36680 #include <linux/capability.h>
36681 +#include <linux/security.h>
36682 #include <linux/ptrace.h>
36683 #include <linux/device.h>
36684 #include <linux/highmem.h>
36685 @@ -37,6 +38,10 @@
36686
36687 #define DEVPORT_MINOR 4
36688
36689 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36690 +extern const struct file_operations grsec_fops;
36691 +#endif
36692 +
36693 static inline unsigned long size_inside_page(unsigned long start,
36694 unsigned long size)
36695 {
36696 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36697
36698 while (cursor < to) {
36699 if (!devmem_is_allowed(pfn)) {
36700 +#ifdef CONFIG_GRKERNSEC_KMEM
36701 + gr_handle_mem_readwrite(from, to);
36702 +#else
36703 printk(KERN_INFO
36704 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36705 current->comm, from, to);
36706 +#endif
36707 return 0;
36708 }
36709 cursor += PAGE_SIZE;
36710 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36711 }
36712 return 1;
36713 }
36714 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36715 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36716 +{
36717 + return 0;
36718 +}
36719 #else
36720 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36721 {
36722 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36723
36724 while (count > 0) {
36725 unsigned long remaining;
36726 + char *temp;
36727
36728 sz = size_inside_page(p, count);
36729
36730 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36731 if (!ptr)
36732 return -EFAULT;
36733
36734 - remaining = copy_to_user(buf, ptr, sz);
36735 +#ifdef CONFIG_PAX_USERCOPY
36736 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36737 + if (!temp) {
36738 + unxlate_dev_mem_ptr(p, ptr);
36739 + return -ENOMEM;
36740 + }
36741 + memcpy(temp, ptr, sz);
36742 +#else
36743 + temp = ptr;
36744 +#endif
36745 +
36746 + remaining = copy_to_user(buf, temp, sz);
36747 +
36748 +#ifdef CONFIG_PAX_USERCOPY
36749 + kfree(temp);
36750 +#endif
36751 +
36752 unxlate_dev_mem_ptr(p, ptr);
36753 if (remaining)
36754 return -EFAULT;
36755 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36756 size_t count, loff_t *ppos)
36757 {
36758 unsigned long p = *ppos;
36759 - ssize_t low_count, read, sz;
36760 + ssize_t low_count, read, sz, err = 0;
36761 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36762 - int err = 0;
36763
36764 read = 0;
36765 if (p < (unsigned long) high_memory) {
36766 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36767 }
36768 #endif
36769 while (low_count > 0) {
36770 + char *temp;
36771 +
36772 sz = size_inside_page(p, low_count);
36773
36774 /*
36775 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36776 */
36777 kbuf = xlate_dev_kmem_ptr((char *)p);
36778
36779 - if (copy_to_user(buf, kbuf, sz))
36780 +#ifdef CONFIG_PAX_USERCOPY
36781 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36782 + if (!temp)
36783 + return -ENOMEM;
36784 + memcpy(temp, kbuf, sz);
36785 +#else
36786 + temp = kbuf;
36787 +#endif
36788 +
36789 + err = copy_to_user(buf, temp, sz);
36790 +
36791 +#ifdef CONFIG_PAX_USERCOPY
36792 + kfree(temp);
36793 +#endif
36794 +
36795 + if (err)
36796 return -EFAULT;
36797 buf += sz;
36798 p += sz;
36799 @@ -822,6 +869,9 @@ static const struct memdev {
36800 #ifdef CONFIG_PRINTK
36801 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36802 #endif
36803 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36804 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36805 +#endif
36806 };
36807
36808 static int memory_open(struct inode *inode, struct file *filp)
36809 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36810 continue;
36811
36812 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36813 - NULL, devlist[minor].name);
36814 + NULL, "%s", devlist[minor].name);
36815 }
36816
36817 return tty_init();
36818 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36819 index 9df78e2..01ba9ae 100644
36820 --- a/drivers/char/nvram.c
36821 +++ b/drivers/char/nvram.c
36822 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36823
36824 spin_unlock_irq(&rtc_lock);
36825
36826 - if (copy_to_user(buf, contents, tmp - contents))
36827 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36828 return -EFAULT;
36829
36830 *ppos = i;
36831 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36832 index 5c5cc00..ac9edb7 100644
36833 --- a/drivers/char/pcmcia/synclink_cs.c
36834 +++ b/drivers/char/pcmcia/synclink_cs.c
36835 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36836
36837 if (debug_level >= DEBUG_LEVEL_INFO)
36838 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36839 - __FILE__, __LINE__, info->device_name, port->count);
36840 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36841
36842 - WARN_ON(!port->count);
36843 + WARN_ON(!atomic_read(&port->count));
36844
36845 if (tty_port_close_start(port, tty, filp) == 0)
36846 goto cleanup;
36847 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36848 cleanup:
36849 if (debug_level >= DEBUG_LEVEL_INFO)
36850 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36851 - tty->driver->name, port->count);
36852 + tty->driver->name, atomic_read(&port->count));
36853 }
36854
36855 /* Wait until the transmitter is empty.
36856 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36857
36858 if (debug_level >= DEBUG_LEVEL_INFO)
36859 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36860 - __FILE__, __LINE__, tty->driver->name, port->count);
36861 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36862
36863 /* If port is closing, signal caller to try again */
36864 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36865 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36866 goto cleanup;
36867 }
36868 spin_lock(&port->lock);
36869 - port->count++;
36870 + atomic_inc(&port->count);
36871 spin_unlock(&port->lock);
36872 spin_unlock_irqrestore(&info->netlock, flags);
36873
36874 - if (port->count == 1) {
36875 + if (atomic_read(&port->count) == 1) {
36876 /* 1st open on this device, init hardware */
36877 retval = startup(info, tty);
36878 if (retval < 0)
36879 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36880 unsigned short new_crctype;
36881
36882 /* return error if TTY interface open */
36883 - if (info->port.count)
36884 + if (atomic_read(&info->port.count))
36885 return -EBUSY;
36886
36887 switch (encoding)
36888 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36889
36890 /* arbitrate between network and tty opens */
36891 spin_lock_irqsave(&info->netlock, flags);
36892 - if (info->port.count != 0 || info->netcount != 0) {
36893 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36894 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36895 spin_unlock_irqrestore(&info->netlock, flags);
36896 return -EBUSY;
36897 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36898 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36899
36900 /* return error if TTY interface open */
36901 - if (info->port.count)
36902 + if (atomic_read(&info->port.count))
36903 return -EBUSY;
36904
36905 if (cmd != SIOCWANDEV)
36906 diff --git a/drivers/char/random.c b/drivers/char/random.c
36907 index 92e6c67..c640ec3 100644
36908 --- a/drivers/char/random.c
36909 +++ b/drivers/char/random.c
36910 @@ -272,8 +272,13 @@
36911 /*
36912 * Configuration information
36913 */
36914 +#ifdef CONFIG_GRKERNSEC_RANDNET
36915 +#define INPUT_POOL_WORDS 512
36916 +#define OUTPUT_POOL_WORDS 128
36917 +#else
36918 #define INPUT_POOL_WORDS 128
36919 #define OUTPUT_POOL_WORDS 32
36920 +#endif
36921 #define SEC_XFER_SIZE 512
36922 #define EXTRACT_SIZE 10
36923
36924 @@ -313,10 +318,17 @@ static struct poolinfo {
36925 int poolwords;
36926 int tap1, tap2, tap3, tap4, tap5;
36927 } poolinfo_table[] = {
36928 +#ifdef CONFIG_GRKERNSEC_RANDNET
36929 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36930 + { 512, 411, 308, 208, 104, 1 },
36931 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36932 + { 128, 103, 76, 51, 25, 1 },
36933 +#else
36934 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36935 { 128, 103, 76, 51, 25, 1 },
36936 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36937 { 32, 26, 20, 14, 7, 1 },
36938 +#endif
36939 #if 0
36940 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36941 { 2048, 1638, 1231, 819, 411, 1 },
36942 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36943 input_rotate += i ? 7 : 14;
36944 }
36945
36946 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36947 - ACCESS_ONCE(r->add_ptr) = i;
36948 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36949 + ACCESS_ONCE_RW(r->add_ptr) = i;
36950 smp_wmb();
36951
36952 if (out)
36953 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36954
36955 extract_buf(r, tmp);
36956 i = min_t(int, nbytes, EXTRACT_SIZE);
36957 - if (copy_to_user(buf, tmp, i)) {
36958 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36959 ret = -EFAULT;
36960 break;
36961 }
36962 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36963 #include <linux/sysctl.h>
36964
36965 static int min_read_thresh = 8, min_write_thresh;
36966 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36967 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36968 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36969 static char sysctl_bootid[16];
36970
36971 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36972 static int proc_do_uuid(struct ctl_table *table, int write,
36973 void __user *buffer, size_t *lenp, loff_t *ppos)
36974 {
36975 - struct ctl_table fake_table;
36976 + ctl_table_no_const fake_table;
36977 unsigned char buf[64], tmp_uuid[16], *uuid;
36978
36979 uuid = table->data;
36980 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36981 index bf2349db..5456d53 100644
36982 --- a/drivers/char/sonypi.c
36983 +++ b/drivers/char/sonypi.c
36984 @@ -54,6 +54,7 @@
36985
36986 #include <asm/uaccess.h>
36987 #include <asm/io.h>
36988 +#include <asm/local.h>
36989
36990 #include <linux/sonypi.h>
36991
36992 @@ -490,7 +491,7 @@ static struct sonypi_device {
36993 spinlock_t fifo_lock;
36994 wait_queue_head_t fifo_proc_list;
36995 struct fasync_struct *fifo_async;
36996 - int open_count;
36997 + local_t open_count;
36998 int model;
36999 struct input_dev *input_jog_dev;
37000 struct input_dev *input_key_dev;
37001 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37002 static int sonypi_misc_release(struct inode *inode, struct file *file)
37003 {
37004 mutex_lock(&sonypi_device.lock);
37005 - sonypi_device.open_count--;
37006 + local_dec(&sonypi_device.open_count);
37007 mutex_unlock(&sonypi_device.lock);
37008 return 0;
37009 }
37010 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37011 {
37012 mutex_lock(&sonypi_device.lock);
37013 /* Flush input queue on first open */
37014 - if (!sonypi_device.open_count)
37015 + if (!local_read(&sonypi_device.open_count))
37016 kfifo_reset(&sonypi_device.fifo);
37017 - sonypi_device.open_count++;
37018 + local_inc(&sonypi_device.open_count);
37019 mutex_unlock(&sonypi_device.lock);
37020
37021 return 0;
37022 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37023 index 64420b3..5c40b56 100644
37024 --- a/drivers/char/tpm/tpm_acpi.c
37025 +++ b/drivers/char/tpm/tpm_acpi.c
37026 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37027 virt = acpi_os_map_memory(start, len);
37028 if (!virt) {
37029 kfree(log->bios_event_log);
37030 + log->bios_event_log = NULL;
37031 printk("%s: ERROR - Unable to map memory\n", __func__);
37032 return -EIO;
37033 }
37034
37035 - memcpy_fromio(log->bios_event_log, virt, len);
37036 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37037
37038 acpi_os_unmap_memory(virt, len);
37039 return 0;
37040 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37041 index 84ddc55..1d32f1e 100644
37042 --- a/drivers/char/tpm/tpm_eventlog.c
37043 +++ b/drivers/char/tpm/tpm_eventlog.c
37044 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37045 event = addr;
37046
37047 if ((event->event_type == 0 && event->event_size == 0) ||
37048 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37049 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37050 return NULL;
37051
37052 return addr;
37053 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37054 return NULL;
37055
37056 if ((event->event_type == 0 && event->event_size == 0) ||
37057 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37058 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37059 return NULL;
37060
37061 (*pos)++;
37062 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37063 int i;
37064
37065 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37066 - seq_putc(m, data[i]);
37067 + if (!seq_putc(m, data[i]))
37068 + return -EFAULT;
37069
37070 return 0;
37071 }
37072 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37073 index fc45567..fa2a590 100644
37074 --- a/drivers/char/virtio_console.c
37075 +++ b/drivers/char/virtio_console.c
37076 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37077 if (to_user) {
37078 ssize_t ret;
37079
37080 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37081 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37082 if (ret)
37083 return -EFAULT;
37084 } else {
37085 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37086 if (!port_has_data(port) && !port->host_connected)
37087 return 0;
37088
37089 - return fill_readbuf(port, ubuf, count, true);
37090 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37091 }
37092
37093 static int wait_port_writable(struct port *port, bool nonblock)
37094 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37095 index a33f46f..a720eed 100644
37096 --- a/drivers/clk/clk-composite.c
37097 +++ b/drivers/clk/clk-composite.c
37098 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37099 struct clk *clk;
37100 struct clk_init_data init;
37101 struct clk_composite *composite;
37102 - struct clk_ops *clk_composite_ops;
37103 + clk_ops_no_const *clk_composite_ops;
37104
37105 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37106 if (!composite) {
37107 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37108 index 5bb848c..f1d4fc9 100644
37109 --- a/drivers/clk/socfpga/clk.c
37110 +++ b/drivers/clk/socfpga/clk.c
37111 @@ -22,6 +22,7 @@
37112 #include <linux/clk-provider.h>
37113 #include <linux/io.h>
37114 #include <linux/of.h>
37115 +#include <asm/pgtable.h>
37116
37117 /* Clock Manager offsets */
37118 #define CLKMGR_CTRL 0x0
37119 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37120 streq(clk_name, "periph_pll") ||
37121 streq(clk_name, "sdram_pll")) {
37122 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37123 - clk_pll_ops.enable = clk_gate_ops.enable;
37124 - clk_pll_ops.disable = clk_gate_ops.disable;
37125 + pax_open_kernel();
37126 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37127 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37128 + pax_close_kernel();
37129 }
37130
37131 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37132 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37133 return parent_rate / div;
37134 }
37135
37136 -static struct clk_ops gateclk_ops = {
37137 +static clk_ops_no_const gateclk_ops __read_only = {
37138 .recalc_rate = socfpga_clk_recalc_rate,
37139 .get_parent = socfpga_clk_get_parent,
37140 .set_parent = socfpga_clk_set_parent,
37141 diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
37142 index 08ae128..c73fc2b 100644
37143 --- a/drivers/connector/cn_proc.c
37144 +++ b/drivers/connector/cn_proc.c
37145 @@ -65,6 +65,7 @@ void proc_fork_connector(struct task_struct *task)
37146
37147 msg = (struct cn_msg *)buffer;
37148 ev = (struct proc_event *)msg->data;
37149 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37150 get_seq(&msg->seq, &ev->cpu);
37151 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37152 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37153 @@ -80,6 +81,7 @@ void proc_fork_connector(struct task_struct *task)
37154 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37155 msg->ack = 0; /* not used */
37156 msg->len = sizeof(*ev);
37157 + msg->flags = 0; /* not used */
37158 /* If cn_netlink_send() failed, the data is not sent */
37159 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37160 }
37161 @@ -96,6 +98,7 @@ void proc_exec_connector(struct task_struct *task)
37162
37163 msg = (struct cn_msg *)buffer;
37164 ev = (struct proc_event *)msg->data;
37165 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37166 get_seq(&msg->seq, &ev->cpu);
37167 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37168 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37169 @@ -106,6 +109,7 @@ void proc_exec_connector(struct task_struct *task)
37170 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37171 msg->ack = 0; /* not used */
37172 msg->len = sizeof(*ev);
37173 + msg->flags = 0; /* not used */
37174 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37175 }
37176
37177 @@ -122,6 +126,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
37178
37179 msg = (struct cn_msg *)buffer;
37180 ev = (struct proc_event *)msg->data;
37181 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37182 ev->what = which_id;
37183 ev->event_data.id.process_pid = task->pid;
37184 ev->event_data.id.process_tgid = task->tgid;
37185 @@ -145,6 +150,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
37186 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37187 msg->ack = 0; /* not used */
37188 msg->len = sizeof(*ev);
37189 + msg->flags = 0; /* not used */
37190 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37191 }
37192
37193 @@ -160,6 +166,7 @@ void proc_sid_connector(struct task_struct *task)
37194
37195 msg = (struct cn_msg *)buffer;
37196 ev = (struct proc_event *)msg->data;
37197 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37198 get_seq(&msg->seq, &ev->cpu);
37199 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37200 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37201 @@ -170,6 +177,7 @@ void proc_sid_connector(struct task_struct *task)
37202 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37203 msg->ack = 0; /* not used */
37204 msg->len = sizeof(*ev);
37205 + msg->flags = 0; /* not used */
37206 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37207 }
37208
37209 @@ -185,6 +193,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
37210
37211 msg = (struct cn_msg *)buffer;
37212 ev = (struct proc_event *)msg->data;
37213 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37214 get_seq(&msg->seq, &ev->cpu);
37215 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37216 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37217 @@ -203,6 +212,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
37218 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37219 msg->ack = 0; /* not used */
37220 msg->len = sizeof(*ev);
37221 + msg->flags = 0; /* not used */
37222 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37223 }
37224
37225 @@ -218,6 +228,7 @@ void proc_comm_connector(struct task_struct *task)
37226
37227 msg = (struct cn_msg *)buffer;
37228 ev = (struct proc_event *)msg->data;
37229 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37230 get_seq(&msg->seq, &ev->cpu);
37231 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37232 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37233 @@ -229,6 +240,7 @@ void proc_comm_connector(struct task_struct *task)
37234 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37235 msg->ack = 0; /* not used */
37236 msg->len = sizeof(*ev);
37237 + msg->flags = 0; /* not used */
37238 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37239 }
37240
37241 @@ -244,6 +256,7 @@ void proc_coredump_connector(struct task_struct *task)
37242
37243 msg = (struct cn_msg *)buffer;
37244 ev = (struct proc_event *)msg->data;
37245 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37246 get_seq(&msg->seq, &ev->cpu);
37247 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37248 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37249 @@ -254,6 +267,7 @@ void proc_coredump_connector(struct task_struct *task)
37250 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37251 msg->ack = 0; /* not used */
37252 msg->len = sizeof(*ev);
37253 + msg->flags = 0; /* not used */
37254 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37255 }
37256
37257 @@ -269,6 +283,7 @@ void proc_exit_connector(struct task_struct *task)
37258
37259 msg = (struct cn_msg *)buffer;
37260 ev = (struct proc_event *)msg->data;
37261 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37262 get_seq(&msg->seq, &ev->cpu);
37263 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37264 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37265 @@ -281,6 +296,7 @@ void proc_exit_connector(struct task_struct *task)
37266 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37267 msg->ack = 0; /* not used */
37268 msg->len = sizeof(*ev);
37269 + msg->flags = 0; /* not used */
37270 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37271 }
37272
37273 @@ -304,6 +320,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
37274
37275 msg = (struct cn_msg *)buffer;
37276 ev = (struct proc_event *)msg->data;
37277 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37278 msg->seq = rcvd_seq;
37279 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37280 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37281 @@ -313,6 +330,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
37282 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37283 msg->ack = rcvd_ack + 1;
37284 msg->len = sizeof(*ev);
37285 + msg->flags = 0; /* not used */
37286 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37287 }
37288
37289 diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
37290 index 6ecfa75..0daa11e 100644
37291 --- a/drivers/connector/connector.c
37292 +++ b/drivers/connector/connector.c
37293 @@ -157,17 +157,18 @@ static int cn_call_callback(struct sk_buff *skb)
37294 static void cn_rx_skb(struct sk_buff *__skb)
37295 {
37296 struct nlmsghdr *nlh;
37297 - int err;
37298 struct sk_buff *skb;
37299 + int len, err;
37300
37301 skb = skb_get(__skb);
37302
37303 if (skb->len >= NLMSG_HDRLEN) {
37304 nlh = nlmsg_hdr(skb);
37305 + len = nlmsg_len(nlh);
37306
37307 - if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
37308 + if (len < (int)sizeof(struct cn_msg) ||
37309 skb->len < nlh->nlmsg_len ||
37310 - nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
37311 + len > CONNECTOR_MAX_MSG_SIZE) {
37312 kfree_skb(skb);
37313 return;
37314 }
37315 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37316 index 3926402..37b580d 100644
37317 --- a/drivers/cpufreq/acpi-cpufreq.c
37318 +++ b/drivers/cpufreq/acpi-cpufreq.c
37319 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37320 return sprintf(buf, "%u\n", boost_enabled);
37321 }
37322
37323 -static struct global_attr global_boost = __ATTR(boost, 0644,
37324 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37325 show_global_boost,
37326 store_global_boost);
37327
37328 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37329 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37330 per_cpu(acfreq_data, cpu) = data;
37331
37332 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37333 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37334 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37335 + pax_open_kernel();
37336 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37337 + pax_close_kernel();
37338 + }
37339
37340 result = acpi_processor_register_performance(data->acpi_data, cpu);
37341 if (result)
37342 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37343 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37344 break;
37345 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37346 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37347 + pax_open_kernel();
37348 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37349 + pax_close_kernel();
37350 policy->cur = get_cur_freq_on_cpu(cpu);
37351 break;
37352 default:
37353 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37354 acpi_processor_notify_smm(THIS_MODULE);
37355
37356 /* Check for APERF/MPERF support in hardware */
37357 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37358 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37359 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37360 + pax_open_kernel();
37361 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37362 + pax_close_kernel();
37363 + }
37364
37365 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37366 for (i = 0; i < perf->state_count; i++)
37367 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37368 index f0a5e2b..0a7ee46 100644
37369 --- a/drivers/cpufreq/cpufreq.c
37370 +++ b/drivers/cpufreq/cpufreq.c
37371 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37372 return NOTIFY_OK;
37373 }
37374
37375 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37376 +static struct notifier_block cpufreq_cpu_notifier = {
37377 .notifier_call = cpufreq_cpu_callback,
37378 };
37379
37380 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37381
37382 pr_debug("trying to register driver %s\n", driver_data->name);
37383
37384 - if (driver_data->setpolicy)
37385 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37386 + if (driver_data->setpolicy) {
37387 + pax_open_kernel();
37388 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37389 + pax_close_kernel();
37390 + }
37391
37392 write_lock_irqsave(&cpufreq_driver_lock, flags);
37393 if (cpufreq_driver) {
37394 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37395 index e59afaa..a53a3ff 100644
37396 --- a/drivers/cpufreq/cpufreq_governor.c
37397 +++ b/drivers/cpufreq/cpufreq_governor.c
37398 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37399 struct dbs_data *dbs_data;
37400 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37401 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37402 - struct od_ops *od_ops = NULL;
37403 + const struct od_ops *od_ops = NULL;
37404 struct od_dbs_tuners *od_tuners = NULL;
37405 struct cs_dbs_tuners *cs_tuners = NULL;
37406 struct cpu_dbs_common_info *cpu_cdbs;
37407 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37408
37409 if ((cdata->governor == GOV_CONSERVATIVE) &&
37410 (!policy->governor->initialized)) {
37411 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37412 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37413
37414 cpufreq_register_notifier(cs_ops->notifier_block,
37415 CPUFREQ_TRANSITION_NOTIFIER);
37416 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37417
37418 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37419 (policy->governor->initialized == 1)) {
37420 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37421 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37422
37423 cpufreq_unregister_notifier(cs_ops->notifier_block,
37424 CPUFREQ_TRANSITION_NOTIFIER);
37425 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37426 index d5f12b4..eb30af1 100644
37427 --- a/drivers/cpufreq/cpufreq_governor.h
37428 +++ b/drivers/cpufreq/cpufreq_governor.h
37429 @@ -204,7 +204,7 @@ struct common_dbs_data {
37430 void (*exit)(struct dbs_data *dbs_data);
37431
37432 /* Governor specific ops, see below */
37433 - void *gov_ops;
37434 + const void *gov_ops;
37435 };
37436
37437 /* Governer Per policy data */
37438 @@ -224,7 +224,7 @@ struct od_ops {
37439 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37440 unsigned int freq_next, unsigned int relation);
37441 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37442 -};
37443 +} __no_const;
37444
37445 struct cs_ops {
37446 struct notifier_block *notifier_block;
37447 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37448 index c087347..989aa2e 100644
37449 --- a/drivers/cpufreq/cpufreq_ondemand.c
37450 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37451 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37452
37453 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37454
37455 -static struct od_ops od_ops = {
37456 +static struct od_ops od_ops __read_only = {
37457 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37458 .powersave_bias_target = generic_powersave_bias_target,
37459 .freq_increase = dbs_freq_increase,
37460 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37461 (struct cpufreq_policy *, unsigned int, unsigned int),
37462 unsigned int powersave_bias)
37463 {
37464 - od_ops.powersave_bias_target = f;
37465 + pax_open_kernel();
37466 + *(void **)&od_ops.powersave_bias_target = f;
37467 + pax_close_kernel();
37468 od_set_powersave_bias(powersave_bias);
37469 }
37470 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37471
37472 void od_unregister_powersave_bias_handler(void)
37473 {
37474 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37475 + pax_open_kernel();
37476 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37477 + pax_close_kernel();
37478 od_set_powersave_bias(0);
37479 }
37480 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37481 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37482 index d37568c..fbb19a1 100644
37483 --- a/drivers/cpufreq/cpufreq_stats.c
37484 +++ b/drivers/cpufreq/cpufreq_stats.c
37485 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37486 }
37487
37488 /* priority=1 so this will get called before cpufreq_remove_dev */
37489 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37490 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37491 .notifier_call = cpufreq_stat_cpu_callback,
37492 .priority = 1,
37493 };
37494 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37495 index 9ee7817..17b658e 100644
37496 --- a/drivers/cpufreq/p4-clockmod.c
37497 +++ b/drivers/cpufreq/p4-clockmod.c
37498 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37499 case 0x0F: /* Core Duo */
37500 case 0x16: /* Celeron Core */
37501 case 0x1C: /* Atom */
37502 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37503 + pax_open_kernel();
37504 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37505 + pax_close_kernel();
37506 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37507 case 0x0D: /* Pentium M (Dothan) */
37508 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37509 + pax_open_kernel();
37510 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37511 + pax_close_kernel();
37512 /* fall through */
37513 case 0x09: /* Pentium M (Banias) */
37514 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37515 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37516
37517 /* on P-4s, the TSC runs with constant frequency independent whether
37518 * throttling is active or not. */
37519 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37520 + pax_open_kernel();
37521 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37522 + pax_close_kernel();
37523
37524 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37525 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37526 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37527 index 880ee29..2445bc6 100644
37528 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37529 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37530 @@ -18,14 +18,12 @@
37531 #include <asm/head.h>
37532 #include <asm/timer.h>
37533
37534 -static struct cpufreq_driver *cpufreq_us3_driver;
37535 -
37536 struct us3_freq_percpu_info {
37537 struct cpufreq_frequency_table table[4];
37538 };
37539
37540 /* Indexed by cpu number. */
37541 -static struct us3_freq_percpu_info *us3_freq_table;
37542 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37543
37544 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37545 * in the Safari config register.
37546 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37547
37548 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37549 {
37550 - if (cpufreq_us3_driver)
37551 - us3_set_cpu_divider_index(policy, 0);
37552 + us3_set_cpu_divider_index(policy->cpu, 0);
37553
37554 return 0;
37555 }
37556
37557 +static int __init us3_freq_init(void);
37558 +static void __exit us3_freq_exit(void);
37559 +
37560 +static struct cpufreq_driver cpufreq_us3_driver = {
37561 + .init = us3_freq_cpu_init,
37562 + .verify = us3_freq_verify,
37563 + .target = us3_freq_target,
37564 + .get = us3_freq_get,
37565 + .exit = us3_freq_cpu_exit,
37566 + .owner = THIS_MODULE,
37567 + .name = "UltraSPARC-III",
37568 +
37569 +};
37570 +
37571 static int __init us3_freq_init(void)
37572 {
37573 unsigned long manuf, impl, ver;
37574 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37575 (impl == CHEETAH_IMPL ||
37576 impl == CHEETAH_PLUS_IMPL ||
37577 impl == JAGUAR_IMPL ||
37578 - impl == PANTHER_IMPL)) {
37579 - struct cpufreq_driver *driver;
37580 -
37581 - ret = -ENOMEM;
37582 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37583 - if (!driver)
37584 - goto err_out;
37585 -
37586 - us3_freq_table = kzalloc(
37587 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37588 - GFP_KERNEL);
37589 - if (!us3_freq_table)
37590 - goto err_out;
37591 -
37592 - driver->init = us3_freq_cpu_init;
37593 - driver->verify = us3_freq_verify;
37594 - driver->target = us3_freq_target;
37595 - driver->get = us3_freq_get;
37596 - driver->exit = us3_freq_cpu_exit;
37597 - driver->owner = THIS_MODULE,
37598 - strcpy(driver->name, "UltraSPARC-III");
37599 -
37600 - cpufreq_us3_driver = driver;
37601 - ret = cpufreq_register_driver(driver);
37602 - if (ret)
37603 - goto err_out;
37604 -
37605 - return 0;
37606 -
37607 -err_out:
37608 - if (driver) {
37609 - kfree(driver);
37610 - cpufreq_us3_driver = NULL;
37611 - }
37612 - kfree(us3_freq_table);
37613 - us3_freq_table = NULL;
37614 - return ret;
37615 - }
37616 + impl == PANTHER_IMPL))
37617 + return cpufreq_register_driver(&cpufreq_us3_driver);
37618
37619 return -ENODEV;
37620 }
37621
37622 static void __exit us3_freq_exit(void)
37623 {
37624 - if (cpufreq_us3_driver) {
37625 - cpufreq_unregister_driver(cpufreq_us3_driver);
37626 - kfree(cpufreq_us3_driver);
37627 - cpufreq_us3_driver = NULL;
37628 - kfree(us3_freq_table);
37629 - us3_freq_table = NULL;
37630 - }
37631 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37632 }
37633
37634 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37635 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37636 index 0915e71..53376ed 100644
37637 --- a/drivers/cpufreq/speedstep-centrino.c
37638 +++ b/drivers/cpufreq/speedstep-centrino.c
37639 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37640 !cpu_has(cpu, X86_FEATURE_EST))
37641 return -ENODEV;
37642
37643 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37644 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37645 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37646 + pax_open_kernel();
37647 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37648 + pax_close_kernel();
37649 + }
37650
37651 if (policy->cpu != 0)
37652 return -ENODEV;
37653 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37654 index fdc432f..98e64e2 100644
37655 --- a/drivers/cpuidle/cpuidle.c
37656 +++ b/drivers/cpuidle/cpuidle.c
37657 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37658
37659 static void poll_idle_init(struct cpuidle_driver *drv)
37660 {
37661 - struct cpuidle_state *state = &drv->states[0];
37662 + cpuidle_state_no_const *state = &drv->states[0];
37663
37664 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37665 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37666 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37667 index ea2f8e7..70ac501 100644
37668 --- a/drivers/cpuidle/governor.c
37669 +++ b/drivers/cpuidle/governor.c
37670 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37671 mutex_lock(&cpuidle_lock);
37672 if (__cpuidle_find_governor(gov->name) == NULL) {
37673 ret = 0;
37674 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37675 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37676 if (!cpuidle_curr_governor ||
37677 cpuidle_curr_governor->rating < gov->rating)
37678 cpuidle_switch_governor(gov);
37679 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37680 new_gov = cpuidle_replace_governor(gov->rating);
37681 cpuidle_switch_governor(new_gov);
37682 }
37683 - list_del(&gov->governor_list);
37684 + pax_list_del((struct list_head *)&gov->governor_list);
37685 mutex_unlock(&cpuidle_lock);
37686 }
37687
37688 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37689 index 428754a..8bdf9cc 100644
37690 --- a/drivers/cpuidle/sysfs.c
37691 +++ b/drivers/cpuidle/sysfs.c
37692 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37693 NULL
37694 };
37695
37696 -static struct attribute_group cpuidle_attr_group = {
37697 +static attribute_group_no_const cpuidle_attr_group = {
37698 .attrs = cpuidle_default_attrs,
37699 .name = "cpuidle",
37700 };
37701 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37702 index 12fea3e..1e28f47 100644
37703 --- a/drivers/crypto/hifn_795x.c
37704 +++ b/drivers/crypto/hifn_795x.c
37705 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37706 MODULE_PARM_DESC(hifn_pll_ref,
37707 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37708
37709 -static atomic_t hifn_dev_number;
37710 +static atomic_unchecked_t hifn_dev_number;
37711
37712 #define ACRYPTO_OP_DECRYPT 0
37713 #define ACRYPTO_OP_ENCRYPT 1
37714 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37715 goto err_out_disable_pci_device;
37716
37717 snprintf(name, sizeof(name), "hifn%d",
37718 - atomic_inc_return(&hifn_dev_number)-1);
37719 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37720
37721 err = pci_request_regions(pdev, name);
37722 if (err)
37723 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37724 index e94e619..f7e249c 100644
37725 --- a/drivers/devfreq/devfreq.c
37726 +++ b/drivers/devfreq/devfreq.c
37727 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37728 goto err_out;
37729 }
37730
37731 - list_add(&governor->node, &devfreq_governor_list);
37732 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37733
37734 list_for_each_entry(devfreq, &devfreq_list, node) {
37735 int ret = 0;
37736 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37737 }
37738 }
37739
37740 - list_del(&governor->node);
37741 + pax_list_del((struct list_head *)&governor->node);
37742 err_out:
37743 mutex_unlock(&devfreq_list_lock);
37744
37745 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37746 index 5039fbc..841169f 100644
37747 --- a/drivers/dma/sh/shdma.c
37748 +++ b/drivers/dma/sh/shdma.c
37749 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37750 return ret;
37751 }
37752
37753 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37754 +static struct notifier_block sh_dmae_nmi_notifier = {
37755 .notifier_call = sh_dmae_nmi_handler,
37756
37757 /* Run before NMI debug handler and KGDB */
37758 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37759 index 211021d..201d47f 100644
37760 --- a/drivers/edac/edac_device.c
37761 +++ b/drivers/edac/edac_device.c
37762 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37763 */
37764 int edac_device_alloc_index(void)
37765 {
37766 - static atomic_t device_indexes = ATOMIC_INIT(0);
37767 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37768
37769 - return atomic_inc_return(&device_indexes) - 1;
37770 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37771 }
37772 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37773
37774 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37775 index e7c32c4..6397af1 100644
37776 --- a/drivers/edac/edac_mc_sysfs.c
37777 +++ b/drivers/edac/edac_mc_sysfs.c
37778 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37779 struct dev_ch_attribute {
37780 struct device_attribute attr;
37781 int channel;
37782 -};
37783 +} __do_const;
37784
37785 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37786 struct dev_ch_attribute dev_attr_legacy_##_name = \
37787 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37788 }
37789
37790 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37791 + pax_open_kernel();
37792 if (mci->get_sdram_scrub_rate) {
37793 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37794 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37795 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37796 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37797 }
37798 if (mci->set_sdram_scrub_rate) {
37799 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37800 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37801 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37802 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37803 }
37804 + pax_close_kernel();
37805 err = device_create_file(&mci->dev,
37806 &dev_attr_sdram_scrub_rate);
37807 if (err) {
37808 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37809 index dd370f9..0281629 100644
37810 --- a/drivers/edac/edac_pci.c
37811 +++ b/drivers/edac/edac_pci.c
37812 @@ -29,7 +29,7 @@
37813
37814 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37815 static LIST_HEAD(edac_pci_list);
37816 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37817 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37818
37819 /*
37820 * edac_pci_alloc_ctl_info
37821 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37822 */
37823 int edac_pci_alloc_index(void)
37824 {
37825 - return atomic_inc_return(&pci_indexes) - 1;
37826 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37827 }
37828 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37829
37830 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37831 index e8658e4..22746d6 100644
37832 --- a/drivers/edac/edac_pci_sysfs.c
37833 +++ b/drivers/edac/edac_pci_sysfs.c
37834 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37835 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37836 static int edac_pci_poll_msec = 1000; /* one second workq period */
37837
37838 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37839 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37840 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37841 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37842
37843 static struct kobject *edac_pci_top_main_kobj;
37844 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37845 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37846 void *value;
37847 ssize_t(*show) (void *, char *);
37848 ssize_t(*store) (void *, const char *, size_t);
37849 -};
37850 +} __do_const;
37851
37852 /* Set of show/store abstract level functions for PCI Parity object */
37853 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37854 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37855 edac_printk(KERN_CRIT, EDAC_PCI,
37856 "Signaled System Error on %s\n",
37857 pci_name(dev));
37858 - atomic_inc(&pci_nonparity_count);
37859 + atomic_inc_unchecked(&pci_nonparity_count);
37860 }
37861
37862 if (status & (PCI_STATUS_PARITY)) {
37863 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37864 "Master Data Parity Error on %s\n",
37865 pci_name(dev));
37866
37867 - atomic_inc(&pci_parity_count);
37868 + atomic_inc_unchecked(&pci_parity_count);
37869 }
37870
37871 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37872 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37873 "Detected Parity Error on %s\n",
37874 pci_name(dev));
37875
37876 - atomic_inc(&pci_parity_count);
37877 + atomic_inc_unchecked(&pci_parity_count);
37878 }
37879 }
37880
37881 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37882 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37883 "Signaled System Error on %s\n",
37884 pci_name(dev));
37885 - atomic_inc(&pci_nonparity_count);
37886 + atomic_inc_unchecked(&pci_nonparity_count);
37887 }
37888
37889 if (status & (PCI_STATUS_PARITY)) {
37890 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37891 "Master Data Parity Error on "
37892 "%s\n", pci_name(dev));
37893
37894 - atomic_inc(&pci_parity_count);
37895 + atomic_inc_unchecked(&pci_parity_count);
37896 }
37897
37898 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37899 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37900 "Detected Parity Error on %s\n",
37901 pci_name(dev));
37902
37903 - atomic_inc(&pci_parity_count);
37904 + atomic_inc_unchecked(&pci_parity_count);
37905 }
37906 }
37907 }
37908 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37909 if (!check_pci_errors)
37910 return;
37911
37912 - before_count = atomic_read(&pci_parity_count);
37913 + before_count = atomic_read_unchecked(&pci_parity_count);
37914
37915 /* scan all PCI devices looking for a Parity Error on devices and
37916 * bridges.
37917 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37918 /* Only if operator has selected panic on PCI Error */
37919 if (edac_pci_get_panic_on_pe()) {
37920 /* If the count is different 'after' from 'before' */
37921 - if (before_count != atomic_read(&pci_parity_count))
37922 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37923 panic("EDAC: PCI Parity Error");
37924 }
37925 }
37926 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37927 index 51b7e3a..aa8a3e8 100644
37928 --- a/drivers/edac/mce_amd.h
37929 +++ b/drivers/edac/mce_amd.h
37930 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37931 bool (*mc0_mce)(u16, u8);
37932 bool (*mc1_mce)(u16, u8);
37933 bool (*mc2_mce)(u16, u8);
37934 -};
37935 +} __no_const;
37936
37937 void amd_report_gart_errors(bool);
37938 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37939 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37940 index 57ea7f4..af06b76 100644
37941 --- a/drivers/firewire/core-card.c
37942 +++ b/drivers/firewire/core-card.c
37943 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37944 const struct fw_card_driver *driver,
37945 struct device *device)
37946 {
37947 - static atomic_t index = ATOMIC_INIT(-1);
37948 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37949
37950 - card->index = atomic_inc_return(&index);
37951 + card->index = atomic_inc_return_unchecked(&index);
37952 card->driver = driver;
37953 card->device = device;
37954 card->current_tlabel = 0;
37955 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37956
37957 void fw_core_remove_card(struct fw_card *card)
37958 {
37959 - struct fw_card_driver dummy_driver = dummy_driver_template;
37960 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37961
37962 card->driver->update_phy_reg(card, 4,
37963 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37964 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37965 index de4aa40..49ab1f2 100644
37966 --- a/drivers/firewire/core-device.c
37967 +++ b/drivers/firewire/core-device.c
37968 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37969 struct config_rom_attribute {
37970 struct device_attribute attr;
37971 u32 key;
37972 -};
37973 +} __do_const;
37974
37975 static ssize_t show_immediate(struct device *dev,
37976 struct device_attribute *dattr, char *buf)
37977 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37978 index 28a94c7..58da63a 100644
37979 --- a/drivers/firewire/core-transaction.c
37980 +++ b/drivers/firewire/core-transaction.c
37981 @@ -38,6 +38,7 @@
37982 #include <linux/timer.h>
37983 #include <linux/types.h>
37984 #include <linux/workqueue.h>
37985 +#include <linux/sched.h>
37986
37987 #include <asm/byteorder.h>
37988
37989 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37990 index 515a42c..5ecf3ba 100644
37991 --- a/drivers/firewire/core.h
37992 +++ b/drivers/firewire/core.h
37993 @@ -111,6 +111,7 @@ struct fw_card_driver {
37994
37995 int (*stop_iso)(struct fw_iso_context *ctx);
37996 };
37997 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37998
37999 void fw_card_initialize(struct fw_card *card,
38000 const struct fw_card_driver *driver, struct device *device);
38001 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38002 index 94a58a0..f5eba42 100644
38003 --- a/drivers/firmware/dmi-id.c
38004 +++ b/drivers/firmware/dmi-id.c
38005 @@ -16,7 +16,7 @@
38006 struct dmi_device_attribute{
38007 struct device_attribute dev_attr;
38008 int field;
38009 -};
38010 +} __do_const;
38011 #define to_dmi_dev_attr(_dev_attr) \
38012 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38013
38014 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38015 index 232fa8f..386c255 100644
38016 --- a/drivers/firmware/dmi_scan.c
38017 +++ b/drivers/firmware/dmi_scan.c
38018 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
38019 }
38020 }
38021 else {
38022 - /*
38023 - * no iounmap() for that ioremap(); it would be a no-op, but
38024 - * it's so early in setup that sucker gets confused into doing
38025 - * what it shouldn't if we actually call it.
38026 - */
38027 p = dmi_ioremap(0xF0000, 0x10000);
38028 if (p == NULL)
38029 goto error;
38030 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38031 if (buf == NULL)
38032 return -1;
38033
38034 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38035 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38036
38037 iounmap(buf);
38038 return 0;
38039 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38040 index 5145fa3..0d3babd 100644
38041 --- a/drivers/firmware/efi/efi.c
38042 +++ b/drivers/firmware/efi/efi.c
38043 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38044 };
38045
38046 static struct efivars generic_efivars;
38047 -static struct efivar_operations generic_ops;
38048 +static efivar_operations_no_const generic_ops __read_only;
38049
38050 static int generic_ops_register(void)
38051 {
38052 - generic_ops.get_variable = efi.get_variable;
38053 - generic_ops.set_variable = efi.set_variable;
38054 - generic_ops.get_next_variable = efi.get_next_variable;
38055 - generic_ops.query_variable_store = efi_query_variable_store;
38056 + pax_open_kernel();
38057 + *(void **)&generic_ops.get_variable = efi.get_variable;
38058 + *(void **)&generic_ops.set_variable = efi.set_variable;
38059 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38060 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38061 + pax_close_kernel();
38062
38063 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38064 }
38065 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38066 index 8a7432a..28fb839 100644
38067 --- a/drivers/firmware/efi/efivars.c
38068 +++ b/drivers/firmware/efi/efivars.c
38069 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38070 static int
38071 create_efivars_bin_attributes(void)
38072 {
38073 - struct bin_attribute *attr;
38074 + bin_attribute_no_const *attr;
38075 int error;
38076
38077 /* new_var */
38078 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38079 index 2a90ba6..07f3733 100644
38080 --- a/drivers/firmware/google/memconsole.c
38081 +++ b/drivers/firmware/google/memconsole.c
38082 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38083 if (!found_memconsole())
38084 return -ENODEV;
38085
38086 - memconsole_bin_attr.size = memconsole_length;
38087 + pax_open_kernel();
38088 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38089 + pax_close_kernel();
38090
38091 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38092
38093 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38094 index 2729e3d..f9deca1 100644
38095 --- a/drivers/gpio/gpio-ich.c
38096 +++ b/drivers/gpio/gpio-ich.c
38097 @@ -71,7 +71,7 @@ struct ichx_desc {
38098 /* Some chipsets have quirks, let these use their own request/get */
38099 int (*request)(struct gpio_chip *chip, unsigned offset);
38100 int (*get)(struct gpio_chip *chip, unsigned offset);
38101 -};
38102 +} __do_const;
38103
38104 static struct {
38105 spinlock_t lock;
38106 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38107 index 9902732..64b62dd 100644
38108 --- a/drivers/gpio/gpio-vr41xx.c
38109 +++ b/drivers/gpio/gpio-vr41xx.c
38110 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38111 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38112 maskl, pendl, maskh, pendh);
38113
38114 - atomic_inc(&irq_err_count);
38115 + atomic_inc_unchecked(&irq_err_count);
38116
38117 return -EINVAL;
38118 }
38119 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38120 index 6a64749..0767a9f 100644
38121 --- a/drivers/gpu/drm/drm_crtc_helper.c
38122 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38123 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38124 struct drm_crtc *tmp;
38125 int crtc_mask = 1;
38126
38127 - WARN(!crtc, "checking null crtc?\n");
38128 + BUG_ON(!crtc);
38129
38130 dev = crtc->dev;
38131
38132 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38133 index 99fcd7c..13cf6c5 100644
38134 --- a/drivers/gpu/drm/drm_drv.c
38135 +++ b/drivers/gpu/drm/drm_drv.c
38136 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
38137 /**
38138 * Copy and IOCTL return string to user space
38139 */
38140 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38141 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38142 {
38143 int len;
38144
38145 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
38146 struct drm_file *file_priv = filp->private_data;
38147 struct drm_device *dev;
38148 const struct drm_ioctl_desc *ioctl = NULL;
38149 - drm_ioctl_t *func;
38150 + drm_ioctl_no_const_t func;
38151 unsigned int nr = DRM_IOCTL_NR(cmd);
38152 int retcode = -EINVAL;
38153 char stack_kdata[128];
38154 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
38155 return -ENODEV;
38156
38157 atomic_inc(&dev->ioctl_count);
38158 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38159 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38160 ++file_priv->ioctl_count;
38161
38162 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38163 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38164 index 3a24385..4e426e0 100644
38165 --- a/drivers/gpu/drm/drm_fops.c
38166 +++ b/drivers/gpu/drm/drm_fops.c
38167 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
38168 }
38169
38170 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38171 - atomic_set(&dev->counts[i], 0);
38172 + atomic_set_unchecked(&dev->counts[i], 0);
38173
38174 dev->sigdata.lock = NULL;
38175
38176 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
38177 if (drm_device_is_unplugged(dev))
38178 return -ENODEV;
38179
38180 - if (!dev->open_count++)
38181 + if (local_inc_return(&dev->open_count) == 1)
38182 need_setup = 1;
38183 mutex_lock(&dev->struct_mutex);
38184 old_imapping = inode->i_mapping;
38185 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38186 retcode = drm_open_helper(inode, filp, dev);
38187 if (retcode)
38188 goto err_undo;
38189 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38190 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38191 if (need_setup) {
38192 retcode = drm_setup(dev);
38193 if (retcode)
38194 @@ -166,7 +166,7 @@ err_undo:
38195 iput(container_of(dev->dev_mapping, struct inode, i_data));
38196 dev->dev_mapping = old_mapping;
38197 mutex_unlock(&dev->struct_mutex);
38198 - dev->open_count--;
38199 + local_dec(&dev->open_count);
38200 return retcode;
38201 }
38202 EXPORT_SYMBOL(drm_open);
38203 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38204
38205 mutex_lock(&drm_global_mutex);
38206
38207 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38208 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38209
38210 if (dev->driver->preclose)
38211 dev->driver->preclose(dev, file_priv);
38212 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38213 * Begin inline drm_release
38214 */
38215
38216 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38217 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38218 task_pid_nr(current),
38219 (long)old_encode_dev(file_priv->minor->device),
38220 - dev->open_count);
38221 + local_read(&dev->open_count));
38222
38223 /* Release any auth tokens that might point to this file_priv,
38224 (do that under the drm_global_mutex) */
38225 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38226 * End inline drm_release
38227 */
38228
38229 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38230 - if (!--dev->open_count) {
38231 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38232 + if (local_dec_and_test(&dev->open_count)) {
38233 if (atomic_read(&dev->ioctl_count)) {
38234 DRM_ERROR("Device busy: %d\n",
38235 atomic_read(&dev->ioctl_count));
38236 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38237 index f731116..629842c 100644
38238 --- a/drivers/gpu/drm/drm_global.c
38239 +++ b/drivers/gpu/drm/drm_global.c
38240 @@ -36,7 +36,7 @@
38241 struct drm_global_item {
38242 struct mutex mutex;
38243 void *object;
38244 - int refcount;
38245 + atomic_t refcount;
38246 };
38247
38248 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38249 @@ -49,7 +49,7 @@ void drm_global_init(void)
38250 struct drm_global_item *item = &glob[i];
38251 mutex_init(&item->mutex);
38252 item->object = NULL;
38253 - item->refcount = 0;
38254 + atomic_set(&item->refcount, 0);
38255 }
38256 }
38257
38258 @@ -59,7 +59,7 @@ void drm_global_release(void)
38259 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38260 struct drm_global_item *item = &glob[i];
38261 BUG_ON(item->object != NULL);
38262 - BUG_ON(item->refcount != 0);
38263 + BUG_ON(atomic_read(&item->refcount) != 0);
38264 }
38265 }
38266
38267 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38268 void *object;
38269
38270 mutex_lock(&item->mutex);
38271 - if (item->refcount == 0) {
38272 + if (atomic_read(&item->refcount) == 0) {
38273 item->object = kzalloc(ref->size, GFP_KERNEL);
38274 if (unlikely(item->object == NULL)) {
38275 ret = -ENOMEM;
38276 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38277 goto out_err;
38278
38279 }
38280 - ++item->refcount;
38281 + atomic_inc(&item->refcount);
38282 ref->object = item->object;
38283 object = item->object;
38284 mutex_unlock(&item->mutex);
38285 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38286 struct drm_global_item *item = &glob[ref->global_type];
38287
38288 mutex_lock(&item->mutex);
38289 - BUG_ON(item->refcount == 0);
38290 + BUG_ON(atomic_read(&item->refcount) == 0);
38291 BUG_ON(ref->object != item->object);
38292 - if (--item->refcount == 0) {
38293 + if (atomic_dec_and_test(&item->refcount)) {
38294 ref->release(ref);
38295 item->object = NULL;
38296 }
38297 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38298 index d4b20ce..77a8d41 100644
38299 --- a/drivers/gpu/drm/drm_info.c
38300 +++ b/drivers/gpu/drm/drm_info.c
38301 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38302 struct drm_local_map *map;
38303 struct drm_map_list *r_list;
38304
38305 - /* Hardcoded from _DRM_FRAME_BUFFER,
38306 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38307 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38308 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38309 + static const char * const types[] = {
38310 + [_DRM_FRAME_BUFFER] = "FB",
38311 + [_DRM_REGISTERS] = "REG",
38312 + [_DRM_SHM] = "SHM",
38313 + [_DRM_AGP] = "AGP",
38314 + [_DRM_SCATTER_GATHER] = "SG",
38315 + [_DRM_CONSISTENT] = "PCI",
38316 + [_DRM_GEM] = "GEM" };
38317 const char *type;
38318 int i;
38319
38320 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38321 map = r_list->map;
38322 if (!map)
38323 continue;
38324 - if (map->type < 0 || map->type > 5)
38325 + if (map->type >= ARRAY_SIZE(types))
38326 type = "??";
38327 else
38328 type = types[map->type];
38329 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38330 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38331 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38332 vma->vm_flags & VM_IO ? 'i' : '-',
38333 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38334 + 0);
38335 +#else
38336 vma->vm_pgoff);
38337 +#endif
38338
38339 #if defined(__i386__)
38340 pgprot = pgprot_val(vma->vm_page_prot);
38341 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38342 index 2f4c434..dd12cd2 100644
38343 --- a/drivers/gpu/drm/drm_ioc32.c
38344 +++ b/drivers/gpu/drm/drm_ioc32.c
38345 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38346 request = compat_alloc_user_space(nbytes);
38347 if (!access_ok(VERIFY_WRITE, request, nbytes))
38348 return -EFAULT;
38349 - list = (struct drm_buf_desc *) (request + 1);
38350 + list = (struct drm_buf_desc __user *) (request + 1);
38351
38352 if (__put_user(count, &request->count)
38353 || __put_user(list, &request->list))
38354 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38355 request = compat_alloc_user_space(nbytes);
38356 if (!access_ok(VERIFY_WRITE, request, nbytes))
38357 return -EFAULT;
38358 - list = (struct drm_buf_pub *) (request + 1);
38359 + list = (struct drm_buf_pub __user *) (request + 1);
38360
38361 if (__put_user(count, &request->count)
38362 || __put_user(list, &request->list))
38363 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38364 return 0;
38365 }
38366
38367 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38368 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38369 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38370 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38371 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38372 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38373 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38374 {
38375 unsigned int nr = DRM_IOCTL_NR(cmd);
38376 - drm_ioctl_compat_t *fn;
38377 int ret;
38378
38379 /* Assume that ioctls without an explicit compat routine will just
38380 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38381 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38382 return drm_ioctl(filp, cmd, arg);
38383
38384 - fn = drm_compat_ioctls[nr];
38385 -
38386 - if (fn != NULL)
38387 - ret = (*fn) (filp, cmd, arg);
38388 + if (drm_compat_ioctls[nr] != NULL)
38389 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38390 else
38391 ret = drm_ioctl(filp, cmd, arg);
38392
38393 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38394 index ffd7a7b..a64643e 100644
38395 --- a/drivers/gpu/drm/drm_ioctl.c
38396 +++ b/drivers/gpu/drm/drm_ioctl.c
38397 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38398 stats->data[i].value =
38399 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38400 else
38401 - stats->data[i].value = atomic_read(&dev->counts[i]);
38402 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38403 stats->data[i].type = dev->types[i];
38404 }
38405
38406 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38407 index d752c96..fe08455 100644
38408 --- a/drivers/gpu/drm/drm_lock.c
38409 +++ b/drivers/gpu/drm/drm_lock.c
38410 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38411 if (drm_lock_take(&master->lock, lock->context)) {
38412 master->lock.file_priv = file_priv;
38413 master->lock.lock_time = jiffies;
38414 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38415 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38416 break; /* Got lock */
38417 }
38418
38419 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38420 return -EINVAL;
38421 }
38422
38423 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38424 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38425
38426 if (drm_lock_free(&master->lock, lock->context)) {
38427 /* FIXME: Should really bail out here. */
38428 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38429 index 327ca19..684d3c0 100644
38430 --- a/drivers/gpu/drm/drm_stub.c
38431 +++ b/drivers/gpu/drm/drm_stub.c
38432 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38433
38434 drm_device_set_unplugged(dev);
38435
38436 - if (dev->open_count == 0) {
38437 + if (local_read(&dev->open_count) == 0) {
38438 drm_put_dev(dev);
38439 }
38440 mutex_unlock(&drm_global_mutex);
38441 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38442 index 2290b3b..22056a1 100644
38443 --- a/drivers/gpu/drm/drm_sysfs.c
38444 +++ b/drivers/gpu/drm/drm_sysfs.c
38445 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38446 int drm_sysfs_device_add(struct drm_minor *minor)
38447 {
38448 int err;
38449 - char *minor_str;
38450 + const char *minor_str;
38451
38452 minor->kdev.parent = minor->dev->dev;
38453
38454 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38455 index ada49ed..29275a0 100644
38456 --- a/drivers/gpu/drm/i810/i810_dma.c
38457 +++ b/drivers/gpu/drm/i810/i810_dma.c
38458 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38459 dma->buflist[vertex->idx],
38460 vertex->discard, vertex->used);
38461
38462 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38463 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38464 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38465 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38466 sarea_priv->last_enqueue = dev_priv->counter - 1;
38467 sarea_priv->last_dispatch = (int)hw_status[5];
38468
38469 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38470 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38471 mc->last_render);
38472
38473 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38474 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38475 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38476 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38477 sarea_priv->last_enqueue = dev_priv->counter - 1;
38478 sarea_priv->last_dispatch = (int)hw_status[5];
38479
38480 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38481 index 6e0acad..93c8289 100644
38482 --- a/drivers/gpu/drm/i810/i810_drv.h
38483 +++ b/drivers/gpu/drm/i810/i810_drv.h
38484 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38485 int page_flipping;
38486
38487 wait_queue_head_t irq_queue;
38488 - atomic_t irq_received;
38489 - atomic_t irq_emitted;
38490 + atomic_unchecked_t irq_received;
38491 + atomic_unchecked_t irq_emitted;
38492
38493 int front_offset;
38494 } drm_i810_private_t;
38495 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38496 index 47d6c74..279123f 100644
38497 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38498 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38499 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38500 I915_READ(GTIMR));
38501 }
38502 seq_printf(m, "Interrupts received: %d\n",
38503 - atomic_read(&dev_priv->irq_received));
38504 + atomic_read_unchecked(&dev_priv->irq_received));
38505 for_each_ring(ring, dev_priv, i) {
38506 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38507 seq_printf(m,
38508 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38509 index f466980..8f2883f 100644
38510 --- a/drivers/gpu/drm/i915/i915_dma.c
38511 +++ b/drivers/gpu/drm/i915/i915_dma.c
38512 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38513 bool can_switch;
38514
38515 spin_lock(&dev->count_lock);
38516 - can_switch = (dev->open_count == 0);
38517 + can_switch = (local_read(&dev->open_count) == 0);
38518 spin_unlock(&dev->count_lock);
38519 return can_switch;
38520 }
38521 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38522 index 2f09e80..077876d 100644
38523 --- a/drivers/gpu/drm/i915/i915_drv.h
38524 +++ b/drivers/gpu/drm/i915/i915_drv.h
38525 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38526 drm_dma_handle_t *status_page_dmah;
38527 struct resource mch_res;
38528
38529 - atomic_t irq_received;
38530 + atomic_unchecked_t irq_received;
38531
38532 /* protects the irq masks */
38533 spinlock_t irq_lock;
38534 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38535 index 87a3227..cd13d8f 100644
38536 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38537 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38538 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38539
38540 static int
38541 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38542 - int count)
38543 + unsigned int count)
38544 {
38545 - int i;
38546 + unsigned int i;
38547 int relocs_total = 0;
38548 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38549
38550 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38551 index 3c59584..500f2e9 100644
38552 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38553 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38554 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38555 (unsigned long)request);
38556 }
38557
38558 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38559 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38560 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38561 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38562 [DRM_I915_GETPARAM] = compat_i915_getparam,
38563 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38564 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38565 {
38566 unsigned int nr = DRM_IOCTL_NR(cmd);
38567 - drm_ioctl_compat_t *fn = NULL;
38568 int ret;
38569
38570 if (nr < DRM_COMMAND_BASE)
38571 return drm_compat_ioctl(filp, cmd, arg);
38572
38573 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38574 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38575 -
38576 - if (fn != NULL)
38577 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38578 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38579 ret = (*fn) (filp, cmd, arg);
38580 - else
38581 + } else
38582 ret = drm_ioctl(filp, cmd, arg);
38583
38584 return ret;
38585 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38586 index 46d46ba..6e49848 100644
38587 --- a/drivers/gpu/drm/i915/i915_irq.c
38588 +++ b/drivers/gpu/drm/i915/i915_irq.c
38589 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38590 int pipe;
38591 u32 pipe_stats[I915_MAX_PIPES];
38592
38593 - atomic_inc(&dev_priv->irq_received);
38594 + atomic_inc_unchecked(&dev_priv->irq_received);
38595
38596 while (true) {
38597 iir = I915_READ(VLV_IIR);
38598 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38599 irqreturn_t ret = IRQ_NONE;
38600 int i;
38601
38602 - atomic_inc(&dev_priv->irq_received);
38603 + atomic_inc_unchecked(&dev_priv->irq_received);
38604
38605 /* We get interrupts on unclaimed registers, so check for this before we
38606 * do any I915_{READ,WRITE}. */
38607 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38608 int ret = IRQ_NONE;
38609 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38610
38611 - atomic_inc(&dev_priv->irq_received);
38612 + atomic_inc_unchecked(&dev_priv->irq_received);
38613
38614 /* disable master interrupt before clearing iir */
38615 de_ier = I915_READ(DEIER);
38616 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38617 {
38618 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38619
38620 - atomic_set(&dev_priv->irq_received, 0);
38621 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38622
38623 I915_WRITE(HWSTAM, 0xeffe);
38624
38625 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38626 {
38627 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38628
38629 - atomic_set(&dev_priv->irq_received, 0);
38630 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38631
38632 I915_WRITE(HWSTAM, 0xeffe);
38633
38634 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38635 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38636 int pipe;
38637
38638 - atomic_set(&dev_priv->irq_received, 0);
38639 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38640
38641 /* VLV magic */
38642 I915_WRITE(VLV_IMR, 0);
38643 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38644 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38645 int pipe;
38646
38647 - atomic_set(&dev_priv->irq_received, 0);
38648 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38649
38650 for_each_pipe(pipe)
38651 I915_WRITE(PIPESTAT(pipe), 0);
38652 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38653 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38654 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38655
38656 - atomic_inc(&dev_priv->irq_received);
38657 + atomic_inc_unchecked(&dev_priv->irq_received);
38658
38659 iir = I915_READ16(IIR);
38660 if (iir == 0)
38661 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38662 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38663 int pipe;
38664
38665 - atomic_set(&dev_priv->irq_received, 0);
38666 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38667
38668 if (I915_HAS_HOTPLUG(dev)) {
38669 I915_WRITE(PORT_HOTPLUG_EN, 0);
38670 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38671 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38672 int pipe, ret = IRQ_NONE;
38673
38674 - atomic_inc(&dev_priv->irq_received);
38675 + atomic_inc_unchecked(&dev_priv->irq_received);
38676
38677 iir = I915_READ(IIR);
38678 do {
38679 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38680 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38681 int pipe;
38682
38683 - atomic_set(&dev_priv->irq_received, 0);
38684 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38685
38686 I915_WRITE(PORT_HOTPLUG_EN, 0);
38687 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38688 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38689 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38690 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38691
38692 - atomic_inc(&dev_priv->irq_received);
38693 + atomic_inc_unchecked(&dev_priv->irq_received);
38694
38695 iir = I915_READ(IIR);
38696
38697 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38698 index 90a7c17..ecedc6a 100644
38699 --- a/drivers/gpu/drm/i915/intel_display.c
38700 +++ b/drivers/gpu/drm/i915/intel_display.c
38701 @@ -9424,13 +9424,13 @@ struct intel_quirk {
38702 int subsystem_vendor;
38703 int subsystem_device;
38704 void (*hook)(struct drm_device *dev);
38705 -};
38706 +} __do_const;
38707
38708 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38709 struct intel_dmi_quirk {
38710 void (*hook)(struct drm_device *dev);
38711 const struct dmi_system_id (*dmi_id_list)[];
38712 -};
38713 +} __do_const;
38714
38715 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38716 {
38717 @@ -9438,18 +9438,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38718 return 1;
38719 }
38720
38721 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38722 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38723 {
38724 - .dmi_id_list = &(const struct dmi_system_id[]) {
38725 - {
38726 - .callback = intel_dmi_reverse_brightness,
38727 - .ident = "NCR Corporation",
38728 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38729 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38730 - },
38731 - },
38732 - { } /* terminating entry */
38733 + .callback = intel_dmi_reverse_brightness,
38734 + .ident = "NCR Corporation",
38735 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38736 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38737 },
38738 + },
38739 + { } /* terminating entry */
38740 +};
38741 +
38742 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38743 + {
38744 + .dmi_id_list = &intel_dmi_quirks_table,
38745 .hook = quirk_invert_brightness,
38746 },
38747 };
38748 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38749 index 54558a0..2d97005 100644
38750 --- a/drivers/gpu/drm/mga/mga_drv.h
38751 +++ b/drivers/gpu/drm/mga/mga_drv.h
38752 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38753 u32 clear_cmd;
38754 u32 maccess;
38755
38756 - atomic_t vbl_received; /**< Number of vblanks received. */
38757 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38758 wait_queue_head_t fence_queue;
38759 - atomic_t last_fence_retired;
38760 + atomic_unchecked_t last_fence_retired;
38761 u32 next_fence_to_post;
38762
38763 unsigned int fb_cpp;
38764 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38765 index 709e90d..89a1c0d 100644
38766 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38767 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38768 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38769 return 0;
38770 }
38771
38772 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38773 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38774 [DRM_MGA_INIT] = compat_mga_init,
38775 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38776 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38777 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38778 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38779 {
38780 unsigned int nr = DRM_IOCTL_NR(cmd);
38781 - drm_ioctl_compat_t *fn = NULL;
38782 int ret;
38783
38784 if (nr < DRM_COMMAND_BASE)
38785 return drm_compat_ioctl(filp, cmd, arg);
38786
38787 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38788 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38789 -
38790 - if (fn != NULL)
38791 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38792 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38793 ret = (*fn) (filp, cmd, arg);
38794 - else
38795 + } else
38796 ret = drm_ioctl(filp, cmd, arg);
38797
38798 return ret;
38799 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38800 index 598c281..60d590e 100644
38801 --- a/drivers/gpu/drm/mga/mga_irq.c
38802 +++ b/drivers/gpu/drm/mga/mga_irq.c
38803 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38804 if (crtc != 0)
38805 return 0;
38806
38807 - return atomic_read(&dev_priv->vbl_received);
38808 + return atomic_read_unchecked(&dev_priv->vbl_received);
38809 }
38810
38811
38812 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38813 /* VBLANK interrupt */
38814 if (status & MGA_VLINEPEN) {
38815 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38816 - atomic_inc(&dev_priv->vbl_received);
38817 + atomic_inc_unchecked(&dev_priv->vbl_received);
38818 drm_handle_vblank(dev, 0);
38819 handled = 1;
38820 }
38821 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38822 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38823 MGA_WRITE(MGA_PRIMEND, prim_end);
38824
38825 - atomic_inc(&dev_priv->last_fence_retired);
38826 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38827 DRM_WAKEUP(&dev_priv->fence_queue);
38828 handled = 1;
38829 }
38830 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38831 * using fences.
38832 */
38833 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38834 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38835 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38836 - *sequence) <= (1 << 23)));
38837
38838 *sequence = cur_fence;
38839 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38840 index 3e72876..d1c15ad 100644
38841 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38842 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38843 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38844 struct bit_table {
38845 const char id;
38846 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38847 -};
38848 +} __no_const;
38849
38850 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38851
38852 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38853 index 41ff7e0..fa854ef 100644
38854 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38855 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38856 @@ -92,7 +92,6 @@ struct nouveau_drm {
38857 struct drm_global_reference mem_global_ref;
38858 struct ttm_bo_global_ref bo_global_ref;
38859 struct ttm_bo_device bdev;
38860 - atomic_t validate_sequence;
38861 int (*move)(struct nouveau_channel *,
38862 struct ttm_buffer_object *,
38863 struct ttm_mem_reg *, struct ttm_mem_reg *);
38864 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38865 index 08214bc..9208577 100644
38866 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38867 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38868 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38869 unsigned long arg)
38870 {
38871 unsigned int nr = DRM_IOCTL_NR(cmd);
38872 - drm_ioctl_compat_t *fn = NULL;
38873 + drm_ioctl_compat_t fn = NULL;
38874 int ret;
38875
38876 if (nr < DRM_COMMAND_BASE)
38877 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38878 index 25d3495..d81aaf6 100644
38879 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38880 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38881 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38882 bool can_switch;
38883
38884 spin_lock(&dev->count_lock);
38885 - can_switch = (dev->open_count == 0);
38886 + can_switch = (local_read(&dev->open_count) == 0);
38887 spin_unlock(&dev->count_lock);
38888 return can_switch;
38889 }
38890 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38891 index 1dfd84c..104896c 100644
38892 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38893 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38894 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38895 }
38896 }
38897
38898 -static struct vm_operations_struct qxl_ttm_vm_ops;
38899 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38900 static const struct vm_operations_struct *ttm_vm_ops;
38901
38902 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38903 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38904 return r;
38905 if (unlikely(ttm_vm_ops == NULL)) {
38906 ttm_vm_ops = vma->vm_ops;
38907 + pax_open_kernel();
38908 qxl_ttm_vm_ops = *ttm_vm_ops;
38909 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38910 + pax_close_kernel();
38911 }
38912 vma->vm_ops = &qxl_ttm_vm_ops;
38913 return 0;
38914 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38915 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38916 {
38917 #if defined(CONFIG_DEBUG_FS)
38918 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38919 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38920 - unsigned i;
38921 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38922 + {
38923 + .name = "qxl_mem_mm",
38924 + .show = &qxl_mm_dump_table,
38925 + },
38926 + {
38927 + .name = "qxl_surf_mm",
38928 + .show = &qxl_mm_dump_table,
38929 + }
38930 + };
38931
38932 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38933 - if (i == 0)
38934 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38935 - else
38936 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38937 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38938 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38939 - qxl_mem_types_list[i].driver_features = 0;
38940 - if (i == 0)
38941 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38942 - else
38943 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38944 + pax_open_kernel();
38945 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38946 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38947 + pax_close_kernel();
38948
38949 - }
38950 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38951 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38952 #else
38953 return 0;
38954 #endif
38955 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38956 index d4660cf..70dbe65 100644
38957 --- a/drivers/gpu/drm/r128/r128_cce.c
38958 +++ b/drivers/gpu/drm/r128/r128_cce.c
38959 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38960
38961 /* GH: Simple idle check.
38962 */
38963 - atomic_set(&dev_priv->idle_count, 0);
38964 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38965
38966 /* We don't support anything other than bus-mastering ring mode,
38967 * but the ring can be in either AGP or PCI space for the ring
38968 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38969 index 930c71b..499aded 100644
38970 --- a/drivers/gpu/drm/r128/r128_drv.h
38971 +++ b/drivers/gpu/drm/r128/r128_drv.h
38972 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38973 int is_pci;
38974 unsigned long cce_buffers_offset;
38975
38976 - atomic_t idle_count;
38977 + atomic_unchecked_t idle_count;
38978
38979 int page_flipping;
38980 int current_page;
38981 u32 crtc_offset;
38982 u32 crtc_offset_cntl;
38983
38984 - atomic_t vbl_received;
38985 + atomic_unchecked_t vbl_received;
38986
38987 u32 color_fmt;
38988 unsigned int front_offset;
38989 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38990 index a954c54..9cc595c 100644
38991 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38992 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38993 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38994 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38995 }
38996
38997 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38998 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38999 [DRM_R128_INIT] = compat_r128_init,
39000 [DRM_R128_DEPTH] = compat_r128_depth,
39001 [DRM_R128_STIPPLE] = compat_r128_stipple,
39002 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39003 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39004 {
39005 unsigned int nr = DRM_IOCTL_NR(cmd);
39006 - drm_ioctl_compat_t *fn = NULL;
39007 int ret;
39008
39009 if (nr < DRM_COMMAND_BASE)
39010 return drm_compat_ioctl(filp, cmd, arg);
39011
39012 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39013 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39014 -
39015 - if (fn != NULL)
39016 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39017 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39018 ret = (*fn) (filp, cmd, arg);
39019 - else
39020 + } else
39021 ret = drm_ioctl(filp, cmd, arg);
39022
39023 return ret;
39024 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39025 index 2ea4f09..d391371 100644
39026 --- a/drivers/gpu/drm/r128/r128_irq.c
39027 +++ b/drivers/gpu/drm/r128/r128_irq.c
39028 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39029 if (crtc != 0)
39030 return 0;
39031
39032 - return atomic_read(&dev_priv->vbl_received);
39033 + return atomic_read_unchecked(&dev_priv->vbl_received);
39034 }
39035
39036 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39037 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39038 /* VBLANK interrupt */
39039 if (status & R128_CRTC_VBLANK_INT) {
39040 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39041 - atomic_inc(&dev_priv->vbl_received);
39042 + atomic_inc_unchecked(&dev_priv->vbl_received);
39043 drm_handle_vblank(dev, 0);
39044 return IRQ_HANDLED;
39045 }
39046 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39047 index 19bb7e6..de7e2a2 100644
39048 --- a/drivers/gpu/drm/r128/r128_state.c
39049 +++ b/drivers/gpu/drm/r128/r128_state.c
39050 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39051
39052 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39053 {
39054 - if (atomic_read(&dev_priv->idle_count) == 0)
39055 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39056 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39057 else
39058 - atomic_set(&dev_priv->idle_count, 0);
39059 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39060 }
39061
39062 #endif
39063 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39064 index af85299..ed9ac8d 100644
39065 --- a/drivers/gpu/drm/radeon/mkregtable.c
39066 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39067 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39068 regex_t mask_rex;
39069 regmatch_t match[4];
39070 char buf[1024];
39071 - size_t end;
39072 + long end;
39073 int len;
39074 int done = 0;
39075 int r;
39076 unsigned o;
39077 struct offset *offset;
39078 char last_reg_s[10];
39079 - int last_reg;
39080 + unsigned long last_reg;
39081
39082 if (regcomp
39083 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39084 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39085 index d15f27e..ef11ffc 100644
39086 --- a/drivers/gpu/drm/radeon/radeon_device.c
39087 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39088 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39089 bool can_switch;
39090
39091 spin_lock(&dev->count_lock);
39092 - can_switch = (dev->open_count == 0);
39093 + can_switch = (local_read(&dev->open_count) == 0);
39094 spin_unlock(&dev->count_lock);
39095 return can_switch;
39096 }
39097 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39098 index b369d42..8dd04eb 100644
39099 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39100 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39101 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39102
39103 /* SW interrupt */
39104 wait_queue_head_t swi_queue;
39105 - atomic_t swi_emitted;
39106 + atomic_unchecked_t swi_emitted;
39107 int vblank_crtc;
39108 uint32_t irq_enable_reg;
39109 uint32_t r500_disp_irq_reg;
39110 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39111 index c180df8..5fd8186 100644
39112 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39113 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39114 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39115 request = compat_alloc_user_space(sizeof(*request));
39116 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39117 || __put_user(req32.param, &request->param)
39118 - || __put_user((void __user *)(unsigned long)req32.value,
39119 + || __put_user((unsigned long)req32.value,
39120 &request->value))
39121 return -EFAULT;
39122
39123 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39124 #define compat_radeon_cp_setparam NULL
39125 #endif /* X86_64 || IA64 */
39126
39127 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39128 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39129 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39130 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39131 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39132 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39133 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39134 {
39135 unsigned int nr = DRM_IOCTL_NR(cmd);
39136 - drm_ioctl_compat_t *fn = NULL;
39137 int ret;
39138
39139 if (nr < DRM_COMMAND_BASE)
39140 return drm_compat_ioctl(filp, cmd, arg);
39141
39142 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39143 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39144 -
39145 - if (fn != NULL)
39146 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39147 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39148 ret = (*fn) (filp, cmd, arg);
39149 - else
39150 + } else
39151 ret = drm_ioctl(filp, cmd, arg);
39152
39153 return ret;
39154 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39155 index 8d68e97..9dcfed8 100644
39156 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39157 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39158 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39159 unsigned int ret;
39160 RING_LOCALS;
39161
39162 - atomic_inc(&dev_priv->swi_emitted);
39163 - ret = atomic_read(&dev_priv->swi_emitted);
39164 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39165 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39166
39167 BEGIN_RING(4);
39168 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39169 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39170 drm_radeon_private_t *dev_priv =
39171 (drm_radeon_private_t *) dev->dev_private;
39172
39173 - atomic_set(&dev_priv->swi_emitted, 0);
39174 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39175 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39176
39177 dev->max_vblank_count = 0x001fffff;
39178 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39179 index 4d20910..6726b6d 100644
39180 --- a/drivers/gpu/drm/radeon/radeon_state.c
39181 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39182 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39183 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39184 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39185
39186 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39187 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39188 sarea_priv->nbox * sizeof(depth_boxes[0])))
39189 return -EFAULT;
39190
39191 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39192 {
39193 drm_radeon_private_t *dev_priv = dev->dev_private;
39194 drm_radeon_getparam_t *param = data;
39195 - int value;
39196 + int value = 0;
39197
39198 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39199
39200 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39201 index 6c0ce89..57a2529 100644
39202 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39203 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39204 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39205 man->size = size >> PAGE_SHIFT;
39206 }
39207
39208 -static struct vm_operations_struct radeon_ttm_vm_ops;
39209 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39210 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39211
39212 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39213 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39214 }
39215 if (unlikely(ttm_vm_ops == NULL)) {
39216 ttm_vm_ops = vma->vm_ops;
39217 + pax_open_kernel();
39218 radeon_ttm_vm_ops = *ttm_vm_ops;
39219 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39220 + pax_close_kernel();
39221 }
39222 vma->vm_ops = &radeon_ttm_vm_ops;
39223 return 0;
39224 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39225 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39226 {
39227 #if defined(CONFIG_DEBUG_FS)
39228 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39229 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39230 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39231 + {
39232 + .name = "radeon_vram_mm",
39233 + .show = &radeon_mm_dump_table,
39234 + },
39235 + {
39236 + .name = "radeon_gtt_mm",
39237 + .show = &radeon_mm_dump_table,
39238 + },
39239 + {
39240 + .name = "ttm_page_pool",
39241 + .show = &ttm_page_alloc_debugfs,
39242 + },
39243 + {
39244 + .name = "ttm_dma_page_pool",
39245 + .show = &ttm_dma_page_alloc_debugfs,
39246 + },
39247 + };
39248 unsigned i;
39249
39250 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39251 - if (i == 0)
39252 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39253 - else
39254 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39255 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39256 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39257 - radeon_mem_types_list[i].driver_features = 0;
39258 - if (i == 0)
39259 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39260 - else
39261 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39262 -
39263 - }
39264 - /* Add ttm page pool to debugfs */
39265 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39266 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39267 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39268 - radeon_mem_types_list[i].driver_features = 0;
39269 - radeon_mem_types_list[i++].data = NULL;
39270 + pax_open_kernel();
39271 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39272 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39273 + pax_close_kernel();
39274 #ifdef CONFIG_SWIOTLB
39275 - if (swiotlb_nr_tbl()) {
39276 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39277 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39278 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39279 - radeon_mem_types_list[i].driver_features = 0;
39280 - radeon_mem_types_list[i++].data = NULL;
39281 - }
39282 + if (swiotlb_nr_tbl())
39283 + i++;
39284 #endif
39285 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39286
39287 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39288 index d8ddfb3..609de1d 100644
39289 --- a/drivers/gpu/drm/radeon/rs690.c
39290 +++ b/drivers/gpu/drm/radeon/rs690.c
39291 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39292 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39293 rdev->pm.sideport_bandwidth.full)
39294 max_bandwidth = rdev->pm.sideport_bandwidth;
39295 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39296 + read_delay_latency.full = dfixed_const(800 * 1000);
39297 read_delay_latency.full = dfixed_div(read_delay_latency,
39298 rdev->pm.igp_sideport_mclk);
39299 + a.full = dfixed_const(370);
39300 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39301 } else {
39302 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39303 rdev->pm.k8_bandwidth.full)
39304 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39305 index dbc2def..0a9f710 100644
39306 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39307 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39308 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39309 zone->glob = glob;
39310 glob->zone_kernel = zone;
39311 ret = kobject_init_and_add(
39312 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39313 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39314 if (unlikely(ret != 0)) {
39315 kobject_put(&zone->kobj);
39316 return ret;
39317 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39318 zone->glob = glob;
39319 glob->zone_dma32 = zone;
39320 ret = kobject_init_and_add(
39321 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39322 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39323 if (unlikely(ret != 0)) {
39324 kobject_put(&zone->kobj);
39325 return ret;
39326 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39327 index bd2a3b4..122d9ad 100644
39328 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39329 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39330 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39331 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39332 struct shrink_control *sc)
39333 {
39334 - static atomic_t start_pool = ATOMIC_INIT(0);
39335 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39336 unsigned i;
39337 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39338 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39339 struct ttm_page_pool *pool;
39340 int shrink_pages = sc->nr_to_scan;
39341
39342 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39343 index 97e9d61..bf23c461 100644
39344 --- a/drivers/gpu/drm/udl/udl_fb.c
39345 +++ b/drivers/gpu/drm/udl/udl_fb.c
39346 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39347 fb_deferred_io_cleanup(info);
39348 kfree(info->fbdefio);
39349 info->fbdefio = NULL;
39350 - info->fbops->fb_mmap = udl_fb_mmap;
39351 }
39352
39353 pr_warn("released /dev/fb%d user=%d count=%d\n",
39354 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39355 index 893a650..6190d3b 100644
39356 --- a/drivers/gpu/drm/via/via_drv.h
39357 +++ b/drivers/gpu/drm/via/via_drv.h
39358 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39359 typedef uint32_t maskarray_t[5];
39360
39361 typedef struct drm_via_irq {
39362 - atomic_t irq_received;
39363 + atomic_unchecked_t irq_received;
39364 uint32_t pending_mask;
39365 uint32_t enable_mask;
39366 wait_queue_head_t irq_queue;
39367 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39368 struct timeval last_vblank;
39369 int last_vblank_valid;
39370 unsigned usec_per_vblank;
39371 - atomic_t vbl_received;
39372 + atomic_unchecked_t vbl_received;
39373 drm_via_state_t hc_state;
39374 char pci_buf[VIA_PCI_BUF_SIZE];
39375 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39376 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39377 index ac98964..5dbf512 100644
39378 --- a/drivers/gpu/drm/via/via_irq.c
39379 +++ b/drivers/gpu/drm/via/via_irq.c
39380 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39381 if (crtc != 0)
39382 return 0;
39383
39384 - return atomic_read(&dev_priv->vbl_received);
39385 + return atomic_read_unchecked(&dev_priv->vbl_received);
39386 }
39387
39388 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39389 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39390
39391 status = VIA_READ(VIA_REG_INTERRUPT);
39392 if (status & VIA_IRQ_VBLANK_PENDING) {
39393 - atomic_inc(&dev_priv->vbl_received);
39394 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39395 + atomic_inc_unchecked(&dev_priv->vbl_received);
39396 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39397 do_gettimeofday(&cur_vblank);
39398 if (dev_priv->last_vblank_valid) {
39399 dev_priv->usec_per_vblank =
39400 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39401 dev_priv->last_vblank = cur_vblank;
39402 dev_priv->last_vblank_valid = 1;
39403 }
39404 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39405 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39406 DRM_DEBUG("US per vblank is: %u\n",
39407 dev_priv->usec_per_vblank);
39408 }
39409 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39410
39411 for (i = 0; i < dev_priv->num_irqs; ++i) {
39412 if (status & cur_irq->pending_mask) {
39413 - atomic_inc(&cur_irq->irq_received);
39414 + atomic_inc_unchecked(&cur_irq->irq_received);
39415 DRM_WAKEUP(&cur_irq->irq_queue);
39416 handled = 1;
39417 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39418 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39419 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39420 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39421 masks[irq][4]));
39422 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39423 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39424 } else {
39425 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39426 (((cur_irq_sequence =
39427 - atomic_read(&cur_irq->irq_received)) -
39428 + atomic_read_unchecked(&cur_irq->irq_received)) -
39429 *sequence) <= (1 << 23)));
39430 }
39431 *sequence = cur_irq_sequence;
39432 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39433 }
39434
39435 for (i = 0; i < dev_priv->num_irqs; ++i) {
39436 - atomic_set(&cur_irq->irq_received, 0);
39437 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39438 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39439 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39440 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39441 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39442 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39443 case VIA_IRQ_RELATIVE:
39444 irqwait->request.sequence +=
39445 - atomic_read(&cur_irq->irq_received);
39446 + atomic_read_unchecked(&cur_irq->irq_received);
39447 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39448 case VIA_IRQ_ABSOLUTE:
39449 break;
39450 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39451 index 13aeda7..4a952d1 100644
39452 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39453 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39454 @@ -290,7 +290,7 @@ struct vmw_private {
39455 * Fencing and IRQs.
39456 */
39457
39458 - atomic_t marker_seq;
39459 + atomic_unchecked_t marker_seq;
39460 wait_queue_head_t fence_queue;
39461 wait_queue_head_t fifo_queue;
39462 int fence_queue_waiters; /* Protected by hw_mutex */
39463 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39464 index 3eb1486..0a47ee9 100644
39465 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39466 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39467 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39468 (unsigned int) min,
39469 (unsigned int) fifo->capabilities);
39470
39471 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39472 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39473 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39474 vmw_marker_queue_init(&fifo->marker_queue);
39475 return vmw_fifo_send_fence(dev_priv, &dummy);
39476 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39477 if (reserveable)
39478 iowrite32(bytes, fifo_mem +
39479 SVGA_FIFO_RESERVED);
39480 - return fifo_mem + (next_cmd >> 2);
39481 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39482 } else {
39483 need_bounce = true;
39484 }
39485 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39486
39487 fm = vmw_fifo_reserve(dev_priv, bytes);
39488 if (unlikely(fm == NULL)) {
39489 - *seqno = atomic_read(&dev_priv->marker_seq);
39490 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39491 ret = -ENOMEM;
39492 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39493 false, 3*HZ);
39494 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39495 }
39496
39497 do {
39498 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39499 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39500 } while (*seqno == 0);
39501
39502 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39503 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39504 index c509d40..3b640c3 100644
39505 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39506 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39507 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39508 int ret;
39509
39510 num_clips = arg->num_clips;
39511 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39512 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39513
39514 if (unlikely(num_clips == 0))
39515 return 0;
39516 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39517 int ret;
39518
39519 num_clips = arg->num_clips;
39520 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39521 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39522
39523 if (unlikely(num_clips == 0))
39524 return 0;
39525 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39526 index 4640adb..e1384ed 100644
39527 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39528 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39529 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39530 * emitted. Then the fence is stale and signaled.
39531 */
39532
39533 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39534 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39535 > VMW_FENCE_WRAP);
39536
39537 return ret;
39538 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39539
39540 if (fifo_idle)
39541 down_read(&fifo_state->rwsem);
39542 - signal_seq = atomic_read(&dev_priv->marker_seq);
39543 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39544 ret = 0;
39545
39546 for (;;) {
39547 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39548 index 8a8725c2..afed796 100644
39549 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39550 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39551 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39552 while (!vmw_lag_lt(queue, us)) {
39553 spin_lock(&queue->lock);
39554 if (list_empty(&queue->head))
39555 - seqno = atomic_read(&dev_priv->marker_seq);
39556 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39557 else {
39558 marker = list_first_entry(&queue->head,
39559 struct vmw_marker, head);
39560 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39561 index 5360e5a..c2c0d26 100644
39562 --- a/drivers/gpu/host1x/drm/dc.c
39563 +++ b/drivers/gpu/host1x/drm/dc.c
39564 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39565 }
39566
39567 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39568 - dc->debugfs_files[i].data = dc;
39569 + *(void **)&dc->debugfs_files[i].data = dc;
39570
39571 err = drm_debugfs_create_files(dc->debugfs_files,
39572 ARRAY_SIZE(debugfs_files),
39573 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39574 index 9f60d63..c89e0b7 100644
39575 --- a/drivers/hid/hid-core.c
39576 +++ b/drivers/hid/hid-core.c
39577 @@ -2370,7 +2370,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39578
39579 int hid_add_device(struct hid_device *hdev)
39580 {
39581 - static atomic_t id = ATOMIC_INIT(0);
39582 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39583 int ret;
39584
39585 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39586 @@ -2404,7 +2404,7 @@ int hid_add_device(struct hid_device *hdev)
39587 /* XXX hack, any other cleaner solution after the driver core
39588 * is converted to allow more than 20 bytes as the device name? */
39589 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39590 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39591 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39592
39593 hid_debug_register(hdev, dev_name(&hdev->dev));
39594 ret = device_add(&hdev->dev);
39595 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39596 index c13fb5b..55a3802 100644
39597 --- a/drivers/hid/hid-wiimote-debug.c
39598 +++ b/drivers/hid/hid-wiimote-debug.c
39599 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39600 else if (size == 0)
39601 return -EIO;
39602
39603 - if (copy_to_user(u, buf, size))
39604 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39605 return -EFAULT;
39606
39607 *off += size;
39608 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39609 index 145a4cb..2353a3e 100644
39610 --- a/drivers/hid/uhid.c
39611 +++ b/drivers/hid/uhid.c
39612 @@ -47,7 +47,7 @@ struct uhid_device {
39613 struct mutex report_lock;
39614 wait_queue_head_t report_wait;
39615 atomic_t report_done;
39616 - atomic_t report_id;
39617 + atomic_unchecked_t report_id;
39618 struct uhid_event report_buf;
39619 };
39620
39621 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39622
39623 spin_lock_irqsave(&uhid->qlock, flags);
39624 ev->type = UHID_FEATURE;
39625 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39626 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39627 ev->u.feature.rnum = rnum;
39628 ev->u.feature.rtype = report_type;
39629
39630 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39631 spin_lock_irqsave(&uhid->qlock, flags);
39632
39633 /* id for old report; drop it silently */
39634 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39635 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39636 goto unlock;
39637 if (atomic_read(&uhid->report_done))
39638 goto unlock;
39639 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39640 index 6de6c98..18319e9 100644
39641 --- a/drivers/hv/channel.c
39642 +++ b/drivers/hv/channel.c
39643 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39644 int ret = 0;
39645 int t;
39646
39647 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39648 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39649 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39650 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39651
39652 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39653 if (ret)
39654 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39655 index 88f4096..e50452e 100644
39656 --- a/drivers/hv/hv.c
39657 +++ b/drivers/hv/hv.c
39658 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39659 u64 output_address = (output) ? virt_to_phys(output) : 0;
39660 u32 output_address_hi = output_address >> 32;
39661 u32 output_address_lo = output_address & 0xFFFFFFFF;
39662 - void *hypercall_page = hv_context.hypercall_page;
39663 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39664
39665 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39666 "=a"(hv_status_lo) : "d" (control_hi),
39667 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39668 index deb5c25..ed2d4fd 100644
39669 --- a/drivers/hv/hv_balloon.c
39670 +++ b/drivers/hv/hv_balloon.c
39671 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39672
39673 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39674 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39675 -static atomic_t trans_id = ATOMIC_INIT(0);
39676 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39677
39678 static int dm_ring_size = (5 * PAGE_SIZE);
39679
39680 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39681 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39682 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39683 resp.hdr.size = sizeof(struct dm_hot_add_response);
39684 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39685 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39686
39687 #ifdef CONFIG_MEMORY_HOTPLUG
39688 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39689 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39690 memset(&status, 0, sizeof(struct dm_status));
39691 status.hdr.type = DM_STATUS_REPORT;
39692 status.hdr.size = sizeof(struct dm_status);
39693 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39694 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39695
39696 /*
39697 * The host expects the guest to report free memory.
39698 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39699 * send the status. This can happen if we were interrupted
39700 * after we picked our transaction ID.
39701 */
39702 - if (status.hdr.trans_id != atomic_read(&trans_id))
39703 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39704 return;
39705
39706 vmbus_sendpacket(dm->dev->channel, &status,
39707 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39708 bl_resp = (struct dm_balloon_response *)send_buffer;
39709 memset(send_buffer, 0, PAGE_SIZE);
39710 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39711 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39712 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39713 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39714 bl_resp->more_pages = 1;
39715
39716 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39717
39718 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39719 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39720 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39721 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39722 resp.hdr.size = sizeof(struct dm_unballoon_response);
39723
39724 vmbus_sendpacket(dm_device.dev->channel, &resp,
39725 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39726 memset(&version_req, 0, sizeof(struct dm_version_request));
39727 version_req.hdr.type = DM_VERSION_REQUEST;
39728 version_req.hdr.size = sizeof(struct dm_version_request);
39729 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39730 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39731 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39732 version_req.is_last_attempt = 1;
39733
39734 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39735 memset(&version_req, 0, sizeof(struct dm_version_request));
39736 version_req.hdr.type = DM_VERSION_REQUEST;
39737 version_req.hdr.size = sizeof(struct dm_version_request);
39738 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39739 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39740 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39741 version_req.is_last_attempt = 0;
39742
39743 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39744 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39745 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39746 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39747 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39748 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39749
39750 cap_msg.caps.cap_bits.balloon = 1;
39751 cap_msg.caps.cap_bits.hot_add = 1;
39752 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39753 index d84918f..7f38f9f 100644
39754 --- a/drivers/hv/hyperv_vmbus.h
39755 +++ b/drivers/hv/hyperv_vmbus.h
39756 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39757 struct vmbus_connection {
39758 enum vmbus_connect_state conn_state;
39759
39760 - atomic_t next_gpadl_handle;
39761 + atomic_unchecked_t next_gpadl_handle;
39762
39763 /*
39764 * Represents channel interrupts. Each bit position represents a
39765 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39766 index e8e071f..5b4b245 100644
39767 --- a/drivers/hv/vmbus_drv.c
39768 +++ b/drivers/hv/vmbus_drv.c
39769 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39770 {
39771 int ret = 0;
39772
39773 - static atomic_t device_num = ATOMIC_INIT(0);
39774 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39775
39776 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39777 - atomic_inc_return(&device_num));
39778 + atomic_inc_return_unchecked(&device_num));
39779
39780 child_device_obj->device.bus = &hv_bus;
39781 child_device_obj->device.parent = &hv_acpi_dev->dev;
39782 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39783 index 6351aba..dc4aaf4 100644
39784 --- a/drivers/hwmon/acpi_power_meter.c
39785 +++ b/drivers/hwmon/acpi_power_meter.c
39786 @@ -117,7 +117,7 @@ struct sensor_template {
39787 struct device_attribute *devattr,
39788 const char *buf, size_t count);
39789 int index;
39790 -};
39791 +} __do_const;
39792
39793 /* Averaging interval */
39794 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39795 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39796 struct sensor_template *attrs)
39797 {
39798 struct device *dev = &resource->acpi_dev->dev;
39799 - struct sensor_device_attribute *sensors =
39800 + sensor_device_attribute_no_const *sensors =
39801 &resource->sensors[resource->num_sensors];
39802 int res = 0;
39803
39804 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39805 index 3288f13..71cfb4e 100644
39806 --- a/drivers/hwmon/applesmc.c
39807 +++ b/drivers/hwmon/applesmc.c
39808 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39809 {
39810 struct applesmc_node_group *grp;
39811 struct applesmc_dev_attr *node;
39812 - struct attribute *attr;
39813 + attribute_no_const *attr;
39814 int ret, i;
39815
39816 for (grp = groups; grp->format; grp++) {
39817 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39818 index b25c643..a13460d 100644
39819 --- a/drivers/hwmon/asus_atk0110.c
39820 +++ b/drivers/hwmon/asus_atk0110.c
39821 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39822 struct atk_sensor_data {
39823 struct list_head list;
39824 struct atk_data *data;
39825 - struct device_attribute label_attr;
39826 - struct device_attribute input_attr;
39827 - struct device_attribute limit1_attr;
39828 - struct device_attribute limit2_attr;
39829 + device_attribute_no_const label_attr;
39830 + device_attribute_no_const input_attr;
39831 + device_attribute_no_const limit1_attr;
39832 + device_attribute_no_const limit2_attr;
39833 char label_attr_name[ATTR_NAME_SIZE];
39834 char input_attr_name[ATTR_NAME_SIZE];
39835 char limit1_attr_name[ATTR_NAME_SIZE];
39836 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39837 static struct device_attribute atk_name_attr =
39838 __ATTR(name, 0444, atk_name_show, NULL);
39839
39840 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39841 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39842 sysfs_show_func show)
39843 {
39844 sysfs_attr_init(&attr->attr);
39845 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39846 index 2e5e2dc..5208b31 100644
39847 --- a/drivers/hwmon/coretemp.c
39848 +++ b/drivers/hwmon/coretemp.c
39849 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39850 return NOTIFY_OK;
39851 }
39852
39853 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39854 +static struct notifier_block coretemp_cpu_notifier = {
39855 .notifier_call = coretemp_cpu_callback,
39856 };
39857
39858 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39859 index 1429f6e..ee03d59 100644
39860 --- a/drivers/hwmon/ibmaem.c
39861 +++ b/drivers/hwmon/ibmaem.c
39862 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39863 struct aem_rw_sensor_template *rw)
39864 {
39865 struct device *dev = &data->pdev->dev;
39866 - struct sensor_device_attribute *sensors = data->sensors;
39867 + sensor_device_attribute_no_const *sensors = data->sensors;
39868 int err;
39869
39870 /* Set up read-only sensors */
39871 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39872 index 708081b..fe2d4ab 100644
39873 --- a/drivers/hwmon/iio_hwmon.c
39874 +++ b/drivers/hwmon/iio_hwmon.c
39875 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39876 {
39877 struct device *dev = &pdev->dev;
39878 struct iio_hwmon_state *st;
39879 - struct sensor_device_attribute *a;
39880 + sensor_device_attribute_no_const *a;
39881 int ret, i;
39882 int in_i = 1, temp_i = 1, curr_i = 1;
39883 enum iio_chan_type type;
39884 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39885 index 9add6092..ee7ba3f 100644
39886 --- a/drivers/hwmon/pmbus/pmbus_core.c
39887 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39888 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39889 return 0;
39890 }
39891
39892 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39893 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39894 const char *name,
39895 umode_t mode,
39896 ssize_t (*show)(struct device *dev,
39897 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39898 dev_attr->store = store;
39899 }
39900
39901 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39902 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39903 const char *name,
39904 umode_t mode,
39905 ssize_t (*show)(struct device *dev,
39906 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39907 u16 reg, u8 mask)
39908 {
39909 struct pmbus_boolean *boolean;
39910 - struct sensor_device_attribute *a;
39911 + sensor_device_attribute_no_const *a;
39912
39913 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39914 if (!boolean)
39915 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39916 bool update, bool readonly)
39917 {
39918 struct pmbus_sensor *sensor;
39919 - struct device_attribute *a;
39920 + device_attribute_no_const *a;
39921
39922 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39923 if (!sensor)
39924 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39925 const char *lstring, int index)
39926 {
39927 struct pmbus_label *label;
39928 - struct device_attribute *a;
39929 + device_attribute_no_const *a;
39930
39931 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39932 if (!label)
39933 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39934 index 2507f90..1645765 100644
39935 --- a/drivers/hwmon/sht15.c
39936 +++ b/drivers/hwmon/sht15.c
39937 @@ -169,7 +169,7 @@ struct sht15_data {
39938 int supply_uv;
39939 bool supply_uv_valid;
39940 struct work_struct update_supply_work;
39941 - atomic_t interrupt_handled;
39942 + atomic_unchecked_t interrupt_handled;
39943 };
39944
39945 /**
39946 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39947 ret = gpio_direction_input(data->pdata->gpio_data);
39948 if (ret)
39949 return ret;
39950 - atomic_set(&data->interrupt_handled, 0);
39951 + atomic_set_unchecked(&data->interrupt_handled, 0);
39952
39953 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39954 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39955 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39956 /* Only relevant if the interrupt hasn't occurred. */
39957 - if (!atomic_read(&data->interrupt_handled))
39958 + if (!atomic_read_unchecked(&data->interrupt_handled))
39959 schedule_work(&data->read_work);
39960 }
39961 ret = wait_event_timeout(data->wait_queue,
39962 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39963
39964 /* First disable the interrupt */
39965 disable_irq_nosync(irq);
39966 - atomic_inc(&data->interrupt_handled);
39967 + atomic_inc_unchecked(&data->interrupt_handled);
39968 /* Then schedule a reading work struct */
39969 if (data->state != SHT15_READING_NOTHING)
39970 schedule_work(&data->read_work);
39971 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39972 * If not, then start the interrupt again - care here as could
39973 * have gone low in meantime so verify it hasn't!
39974 */
39975 - atomic_set(&data->interrupt_handled, 0);
39976 + atomic_set_unchecked(&data->interrupt_handled, 0);
39977 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39978 /* If still not occurred or another handler was scheduled */
39979 if (gpio_get_value(data->pdata->gpio_data)
39980 - || atomic_read(&data->interrupt_handled))
39981 + || atomic_read_unchecked(&data->interrupt_handled))
39982 return;
39983 }
39984
39985 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39986 index 38944e9..ae9e5ed 100644
39987 --- a/drivers/hwmon/via-cputemp.c
39988 +++ b/drivers/hwmon/via-cputemp.c
39989 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39990 return NOTIFY_OK;
39991 }
39992
39993 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39994 +static struct notifier_block via_cputemp_cpu_notifier = {
39995 .notifier_call = via_cputemp_cpu_callback,
39996 };
39997
39998 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39999 index 07f01ac..d79ad3d 100644
40000 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40001 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40002 @@ -43,7 +43,7 @@
40003 extern struct i2c_adapter amd756_smbus;
40004
40005 static struct i2c_adapter *s4882_adapter;
40006 -static struct i2c_algorithm *s4882_algo;
40007 +static i2c_algorithm_no_const *s4882_algo;
40008
40009 /* Wrapper access functions for multiplexed SMBus */
40010 static DEFINE_MUTEX(amd756_lock);
40011 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40012 index 2ca268d..c6acbdf 100644
40013 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40014 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40015 @@ -41,7 +41,7 @@
40016 extern struct i2c_adapter *nforce2_smbus;
40017
40018 static struct i2c_adapter *s4985_adapter;
40019 -static struct i2c_algorithm *s4985_algo;
40020 +static i2c_algorithm_no_const *s4985_algo;
40021
40022 /* Wrapper access functions for multiplexed SMBus */
40023 static DEFINE_MUTEX(nforce2_lock);
40024 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40025 index c3ccdea..5b3dc1a 100644
40026 --- a/drivers/i2c/i2c-dev.c
40027 +++ b/drivers/i2c/i2c-dev.c
40028 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40029 break;
40030 }
40031
40032 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40033 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40034 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40035 if (IS_ERR(rdwr_pa[i].buf)) {
40036 res = PTR_ERR(rdwr_pa[i].buf);
40037 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40038 index 0b510ba..4fbb5085 100644
40039 --- a/drivers/ide/ide-cd.c
40040 +++ b/drivers/ide/ide-cd.c
40041 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40042 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40043 if ((unsigned long)buf & alignment
40044 || blk_rq_bytes(rq) & q->dma_pad_mask
40045 - || object_is_on_stack(buf))
40046 + || object_starts_on_stack(buf))
40047 drive->dma = 0;
40048 }
40049 }
40050 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40051 index e145931..08bfc59 100644
40052 --- a/drivers/iio/industrialio-core.c
40053 +++ b/drivers/iio/industrialio-core.c
40054 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40055 }
40056
40057 static
40058 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40059 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40060 const char *postfix,
40061 struct iio_chan_spec const *chan,
40062 ssize_t (*readfunc)(struct device *dev,
40063 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40064 index 784b97c..c9ceadf 100644
40065 --- a/drivers/infiniband/core/cm.c
40066 +++ b/drivers/infiniband/core/cm.c
40067 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40068
40069 struct cm_counter_group {
40070 struct kobject obj;
40071 - atomic_long_t counter[CM_ATTR_COUNT];
40072 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40073 };
40074
40075 struct cm_counter_attribute {
40076 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40077 struct ib_mad_send_buf *msg = NULL;
40078 int ret;
40079
40080 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40081 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40082 counter[CM_REQ_COUNTER]);
40083
40084 /* Quick state check to discard duplicate REQs. */
40085 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40086 if (!cm_id_priv)
40087 return;
40088
40089 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40090 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40091 counter[CM_REP_COUNTER]);
40092 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40093 if (ret)
40094 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40095 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40096 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40097 spin_unlock_irq(&cm_id_priv->lock);
40098 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40099 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40100 counter[CM_RTU_COUNTER]);
40101 goto out;
40102 }
40103 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40104 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40105 dreq_msg->local_comm_id);
40106 if (!cm_id_priv) {
40107 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40108 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40109 counter[CM_DREQ_COUNTER]);
40110 cm_issue_drep(work->port, work->mad_recv_wc);
40111 return -EINVAL;
40112 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40113 case IB_CM_MRA_REP_RCVD:
40114 break;
40115 case IB_CM_TIMEWAIT:
40116 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40117 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40118 counter[CM_DREQ_COUNTER]);
40119 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40120 goto unlock;
40121 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40122 cm_free_msg(msg);
40123 goto deref;
40124 case IB_CM_DREQ_RCVD:
40125 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40126 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40127 counter[CM_DREQ_COUNTER]);
40128 goto unlock;
40129 default:
40130 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40131 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40132 cm_id_priv->msg, timeout)) {
40133 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40134 - atomic_long_inc(&work->port->
40135 + atomic_long_inc_unchecked(&work->port->
40136 counter_group[CM_RECV_DUPLICATES].
40137 counter[CM_MRA_COUNTER]);
40138 goto out;
40139 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40140 break;
40141 case IB_CM_MRA_REQ_RCVD:
40142 case IB_CM_MRA_REP_RCVD:
40143 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40144 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40145 counter[CM_MRA_COUNTER]);
40146 /* fall through */
40147 default:
40148 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40149 case IB_CM_LAP_IDLE:
40150 break;
40151 case IB_CM_MRA_LAP_SENT:
40152 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40153 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40154 counter[CM_LAP_COUNTER]);
40155 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40156 goto unlock;
40157 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40158 cm_free_msg(msg);
40159 goto deref;
40160 case IB_CM_LAP_RCVD:
40161 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40162 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40163 counter[CM_LAP_COUNTER]);
40164 goto unlock;
40165 default:
40166 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40167 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40168 if (cur_cm_id_priv) {
40169 spin_unlock_irq(&cm.lock);
40170 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40171 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40172 counter[CM_SIDR_REQ_COUNTER]);
40173 goto out; /* Duplicate message. */
40174 }
40175 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40176 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40177 msg->retries = 1;
40178
40179 - atomic_long_add(1 + msg->retries,
40180 + atomic_long_add_unchecked(1 + msg->retries,
40181 &port->counter_group[CM_XMIT].counter[attr_index]);
40182 if (msg->retries)
40183 - atomic_long_add(msg->retries,
40184 + atomic_long_add_unchecked(msg->retries,
40185 &port->counter_group[CM_XMIT_RETRIES].
40186 counter[attr_index]);
40187
40188 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40189 }
40190
40191 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40192 - atomic_long_inc(&port->counter_group[CM_RECV].
40193 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40194 counter[attr_id - CM_ATTR_ID_OFFSET]);
40195
40196 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40197 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40198 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40199
40200 return sprintf(buf, "%ld\n",
40201 - atomic_long_read(&group->counter[cm_attr->index]));
40202 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40203 }
40204
40205 static const struct sysfs_ops cm_counter_ops = {
40206 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40207 index 9f5ad7c..588cd84 100644
40208 --- a/drivers/infiniband/core/fmr_pool.c
40209 +++ b/drivers/infiniband/core/fmr_pool.c
40210 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40211
40212 struct task_struct *thread;
40213
40214 - atomic_t req_ser;
40215 - atomic_t flush_ser;
40216 + atomic_unchecked_t req_ser;
40217 + atomic_unchecked_t flush_ser;
40218
40219 wait_queue_head_t force_wait;
40220 };
40221 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40222 struct ib_fmr_pool *pool = pool_ptr;
40223
40224 do {
40225 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40226 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40227 ib_fmr_batch_release(pool);
40228
40229 - atomic_inc(&pool->flush_ser);
40230 + atomic_inc_unchecked(&pool->flush_ser);
40231 wake_up_interruptible(&pool->force_wait);
40232
40233 if (pool->flush_function)
40234 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40235 }
40236
40237 set_current_state(TASK_INTERRUPTIBLE);
40238 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40239 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40240 !kthread_should_stop())
40241 schedule();
40242 __set_current_state(TASK_RUNNING);
40243 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40244 pool->dirty_watermark = params->dirty_watermark;
40245 pool->dirty_len = 0;
40246 spin_lock_init(&pool->pool_lock);
40247 - atomic_set(&pool->req_ser, 0);
40248 - atomic_set(&pool->flush_ser, 0);
40249 + atomic_set_unchecked(&pool->req_ser, 0);
40250 + atomic_set_unchecked(&pool->flush_ser, 0);
40251 init_waitqueue_head(&pool->force_wait);
40252
40253 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40254 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40255 }
40256 spin_unlock_irq(&pool->pool_lock);
40257
40258 - serial = atomic_inc_return(&pool->req_ser);
40259 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40260 wake_up_process(pool->thread);
40261
40262 if (wait_event_interruptible(pool->force_wait,
40263 - atomic_read(&pool->flush_ser) - serial >= 0))
40264 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40265 return -EINTR;
40266
40267 return 0;
40268 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40269 } else {
40270 list_add_tail(&fmr->list, &pool->dirty_list);
40271 if (++pool->dirty_len >= pool->dirty_watermark) {
40272 - atomic_inc(&pool->req_ser);
40273 + atomic_inc_unchecked(&pool->req_ser);
40274 wake_up_process(pool->thread);
40275 }
40276 }
40277 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40278 index 4cb8eb2..146bf60 100644
40279 --- a/drivers/infiniband/hw/cxgb4/mem.c
40280 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40281 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40282 int err;
40283 struct fw_ri_tpte tpt;
40284 u32 stag_idx;
40285 - static atomic_t key;
40286 + static atomic_unchecked_t key;
40287
40288 if (c4iw_fatal_error(rdev))
40289 return -EIO;
40290 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40291 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40292 rdev->stats.stag.max = rdev->stats.stag.cur;
40293 mutex_unlock(&rdev->stats.lock);
40294 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40295 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40296 }
40297 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40298 __func__, stag_state, type, pdid, stag_idx);
40299 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40300 index 79b3dbc..96e5fcc 100644
40301 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40302 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40303 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40304 struct ib_atomic_eth *ateth;
40305 struct ipath_ack_entry *e;
40306 u64 vaddr;
40307 - atomic64_t *maddr;
40308 + atomic64_unchecked_t *maddr;
40309 u64 sdata;
40310 u32 rkey;
40311 u8 next;
40312 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40313 IB_ACCESS_REMOTE_ATOMIC)))
40314 goto nack_acc_unlck;
40315 /* Perform atomic OP and save result. */
40316 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40317 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40318 sdata = be64_to_cpu(ateth->swap_data);
40319 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40320 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40321 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40322 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40323 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40324 be64_to_cpu(ateth->compare_data),
40325 sdata);
40326 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40327 index 1f95bba..9530f87 100644
40328 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40329 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40330 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40331 unsigned long flags;
40332 struct ib_wc wc;
40333 u64 sdata;
40334 - atomic64_t *maddr;
40335 + atomic64_unchecked_t *maddr;
40336 enum ib_wc_status send_status;
40337
40338 /*
40339 @@ -382,11 +382,11 @@ again:
40340 IB_ACCESS_REMOTE_ATOMIC)))
40341 goto acc_err;
40342 /* Perform atomic OP and save result. */
40343 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40344 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40345 sdata = wqe->wr.wr.atomic.compare_add;
40346 *(u64 *) sqp->s_sge.sge.vaddr =
40347 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40348 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40349 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40350 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40351 sdata, wqe->wr.wr.atomic.swap);
40352 goto send_comp;
40353 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40354 index f2a3f48..673ec79 100644
40355 --- a/drivers/infiniband/hw/mlx4/mad.c
40356 +++ b/drivers/infiniband/hw/mlx4/mad.c
40357 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40358
40359 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40360 {
40361 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40362 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40363 cpu_to_be64(0xff00000000000000LL);
40364 }
40365
40366 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40367 index 25b2cdf..099ff97 100644
40368 --- a/drivers/infiniband/hw/mlx4/mcg.c
40369 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40370 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40371 {
40372 char name[20];
40373
40374 - atomic_set(&ctx->tid, 0);
40375 + atomic_set_unchecked(&ctx->tid, 0);
40376 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40377 ctx->mcg_wq = create_singlethread_workqueue(name);
40378 if (!ctx->mcg_wq)
40379 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40380 index f61ec26..ebf72cf 100644
40381 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40382 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40383 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40384 struct list_head mcg_mgid0_list;
40385 struct workqueue_struct *mcg_wq;
40386 struct mlx4_ib_demux_pv_ctx **tun;
40387 - atomic_t tid;
40388 + atomic_unchecked_t tid;
40389 int flushing; /* flushing the work queue */
40390 };
40391
40392 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40393 index 9d3e5c1..d9afe4a 100644
40394 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40395 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40396 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40397 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40398 }
40399
40400 -int mthca_QUERY_FW(struct mthca_dev *dev)
40401 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40402 {
40403 struct mthca_mailbox *mailbox;
40404 u32 *outbox;
40405 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40406 index ed9a989..e0c5871 100644
40407 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40408 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40409 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40410 return key;
40411 }
40412
40413 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40414 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40415 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40416 {
40417 struct mthca_mailbox *mailbox;
40418 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40419 index 4291410..d2ab1fb 100644
40420 --- a/drivers/infiniband/hw/nes/nes.c
40421 +++ b/drivers/infiniband/hw/nes/nes.c
40422 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40423 LIST_HEAD(nes_adapter_list);
40424 static LIST_HEAD(nes_dev_list);
40425
40426 -atomic_t qps_destroyed;
40427 +atomic_unchecked_t qps_destroyed;
40428
40429 static unsigned int ee_flsh_adapter;
40430 static unsigned int sysfs_nonidx_addr;
40431 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40432 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40433 struct nes_adapter *nesadapter = nesdev->nesadapter;
40434
40435 - atomic_inc(&qps_destroyed);
40436 + atomic_inc_unchecked(&qps_destroyed);
40437
40438 /* Free the control structures */
40439
40440 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40441 index 33cc589..3bd6538 100644
40442 --- a/drivers/infiniband/hw/nes/nes.h
40443 +++ b/drivers/infiniband/hw/nes/nes.h
40444 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40445 extern unsigned int wqm_quanta;
40446 extern struct list_head nes_adapter_list;
40447
40448 -extern atomic_t cm_connects;
40449 -extern atomic_t cm_accepts;
40450 -extern atomic_t cm_disconnects;
40451 -extern atomic_t cm_closes;
40452 -extern atomic_t cm_connecteds;
40453 -extern atomic_t cm_connect_reqs;
40454 -extern atomic_t cm_rejects;
40455 -extern atomic_t mod_qp_timouts;
40456 -extern atomic_t qps_created;
40457 -extern atomic_t qps_destroyed;
40458 -extern atomic_t sw_qps_destroyed;
40459 +extern atomic_unchecked_t cm_connects;
40460 +extern atomic_unchecked_t cm_accepts;
40461 +extern atomic_unchecked_t cm_disconnects;
40462 +extern atomic_unchecked_t cm_closes;
40463 +extern atomic_unchecked_t cm_connecteds;
40464 +extern atomic_unchecked_t cm_connect_reqs;
40465 +extern atomic_unchecked_t cm_rejects;
40466 +extern atomic_unchecked_t mod_qp_timouts;
40467 +extern atomic_unchecked_t qps_created;
40468 +extern atomic_unchecked_t qps_destroyed;
40469 +extern atomic_unchecked_t sw_qps_destroyed;
40470 extern u32 mh_detected;
40471 extern u32 mh_pauses_sent;
40472 extern u32 cm_packets_sent;
40473 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40474 extern u32 cm_packets_received;
40475 extern u32 cm_packets_dropped;
40476 extern u32 cm_packets_retrans;
40477 -extern atomic_t cm_listens_created;
40478 -extern atomic_t cm_listens_destroyed;
40479 +extern atomic_unchecked_t cm_listens_created;
40480 +extern atomic_unchecked_t cm_listens_destroyed;
40481 extern u32 cm_backlog_drops;
40482 -extern atomic_t cm_loopbacks;
40483 -extern atomic_t cm_nodes_created;
40484 -extern atomic_t cm_nodes_destroyed;
40485 -extern atomic_t cm_accel_dropped_pkts;
40486 -extern atomic_t cm_resets_recvd;
40487 -extern atomic_t pau_qps_created;
40488 -extern atomic_t pau_qps_destroyed;
40489 +extern atomic_unchecked_t cm_loopbacks;
40490 +extern atomic_unchecked_t cm_nodes_created;
40491 +extern atomic_unchecked_t cm_nodes_destroyed;
40492 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40493 +extern atomic_unchecked_t cm_resets_recvd;
40494 +extern atomic_unchecked_t pau_qps_created;
40495 +extern atomic_unchecked_t pau_qps_destroyed;
40496
40497 extern u32 int_mod_timer_init;
40498 extern u32 int_mod_cq_depth_256;
40499 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40500 index 24b9f1a..00fd004 100644
40501 --- a/drivers/infiniband/hw/nes/nes_cm.c
40502 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40503 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40504 u32 cm_packets_retrans;
40505 u32 cm_packets_created;
40506 u32 cm_packets_received;
40507 -atomic_t cm_listens_created;
40508 -atomic_t cm_listens_destroyed;
40509 +atomic_unchecked_t cm_listens_created;
40510 +atomic_unchecked_t cm_listens_destroyed;
40511 u32 cm_backlog_drops;
40512 -atomic_t cm_loopbacks;
40513 -atomic_t cm_nodes_created;
40514 -atomic_t cm_nodes_destroyed;
40515 -atomic_t cm_accel_dropped_pkts;
40516 -atomic_t cm_resets_recvd;
40517 +atomic_unchecked_t cm_loopbacks;
40518 +atomic_unchecked_t cm_nodes_created;
40519 +atomic_unchecked_t cm_nodes_destroyed;
40520 +atomic_unchecked_t cm_accel_dropped_pkts;
40521 +atomic_unchecked_t cm_resets_recvd;
40522
40523 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40524 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40525 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40526
40527 static struct nes_cm_core *g_cm_core;
40528
40529 -atomic_t cm_connects;
40530 -atomic_t cm_accepts;
40531 -atomic_t cm_disconnects;
40532 -atomic_t cm_closes;
40533 -atomic_t cm_connecteds;
40534 -atomic_t cm_connect_reqs;
40535 -atomic_t cm_rejects;
40536 +atomic_unchecked_t cm_connects;
40537 +atomic_unchecked_t cm_accepts;
40538 +atomic_unchecked_t cm_disconnects;
40539 +atomic_unchecked_t cm_closes;
40540 +atomic_unchecked_t cm_connecteds;
40541 +atomic_unchecked_t cm_connect_reqs;
40542 +atomic_unchecked_t cm_rejects;
40543
40544 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40545 {
40546 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40547 kfree(listener);
40548 listener = NULL;
40549 ret = 0;
40550 - atomic_inc(&cm_listens_destroyed);
40551 + atomic_inc_unchecked(&cm_listens_destroyed);
40552 } else {
40553 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40554 }
40555 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40556 cm_node->rem_mac);
40557
40558 add_hte_node(cm_core, cm_node);
40559 - atomic_inc(&cm_nodes_created);
40560 + atomic_inc_unchecked(&cm_nodes_created);
40561
40562 return cm_node;
40563 }
40564 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40565 }
40566
40567 atomic_dec(&cm_core->node_cnt);
40568 - atomic_inc(&cm_nodes_destroyed);
40569 + atomic_inc_unchecked(&cm_nodes_destroyed);
40570 nesqp = cm_node->nesqp;
40571 if (nesqp) {
40572 nesqp->cm_node = NULL;
40573 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40574
40575 static void drop_packet(struct sk_buff *skb)
40576 {
40577 - atomic_inc(&cm_accel_dropped_pkts);
40578 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40579 dev_kfree_skb_any(skb);
40580 }
40581
40582 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40583 {
40584
40585 int reset = 0; /* whether to send reset in case of err.. */
40586 - atomic_inc(&cm_resets_recvd);
40587 + atomic_inc_unchecked(&cm_resets_recvd);
40588 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40589 " refcnt=%d\n", cm_node, cm_node->state,
40590 atomic_read(&cm_node->ref_count));
40591 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40592 rem_ref_cm_node(cm_node->cm_core, cm_node);
40593 return NULL;
40594 }
40595 - atomic_inc(&cm_loopbacks);
40596 + atomic_inc_unchecked(&cm_loopbacks);
40597 loopbackremotenode->loopbackpartner = cm_node;
40598 loopbackremotenode->tcp_cntxt.rcv_wscale =
40599 NES_CM_DEFAULT_RCV_WND_SCALE;
40600 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40601 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40602 else {
40603 rem_ref_cm_node(cm_core, cm_node);
40604 - atomic_inc(&cm_accel_dropped_pkts);
40605 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40606 dev_kfree_skb_any(skb);
40607 }
40608 break;
40609 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40610
40611 if ((cm_id) && (cm_id->event_handler)) {
40612 if (issue_disconn) {
40613 - atomic_inc(&cm_disconnects);
40614 + atomic_inc_unchecked(&cm_disconnects);
40615 cm_event.event = IW_CM_EVENT_DISCONNECT;
40616 cm_event.status = disconn_status;
40617 cm_event.local_addr = cm_id->local_addr;
40618 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40619 }
40620
40621 if (issue_close) {
40622 - atomic_inc(&cm_closes);
40623 + atomic_inc_unchecked(&cm_closes);
40624 nes_disconnect(nesqp, 1);
40625
40626 cm_id->provider_data = nesqp;
40627 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40628
40629 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40630 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40631 - atomic_inc(&cm_accepts);
40632 + atomic_inc_unchecked(&cm_accepts);
40633
40634 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40635 netdev_refcnt_read(nesvnic->netdev));
40636 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40637 struct nes_cm_core *cm_core;
40638 u8 *start_buff;
40639
40640 - atomic_inc(&cm_rejects);
40641 + atomic_inc_unchecked(&cm_rejects);
40642 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40643 loopback = cm_node->loopbackpartner;
40644 cm_core = cm_node->cm_core;
40645 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40646 ntohl(cm_id->local_addr.sin_addr.s_addr),
40647 ntohs(cm_id->local_addr.sin_port));
40648
40649 - atomic_inc(&cm_connects);
40650 + atomic_inc_unchecked(&cm_connects);
40651 nesqp->active_conn = 1;
40652
40653 /* cache the cm_id in the qp */
40654 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40655 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40656 return err;
40657 }
40658 - atomic_inc(&cm_listens_created);
40659 + atomic_inc_unchecked(&cm_listens_created);
40660 }
40661
40662 cm_id->add_ref(cm_id);
40663 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40664
40665 if (nesqp->destroyed)
40666 return;
40667 - atomic_inc(&cm_connecteds);
40668 + atomic_inc_unchecked(&cm_connecteds);
40669 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40670 " local port 0x%04X. jiffies = %lu.\n",
40671 nesqp->hwqp.qp_id,
40672 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40673
40674 cm_id->add_ref(cm_id);
40675 ret = cm_id->event_handler(cm_id, &cm_event);
40676 - atomic_inc(&cm_closes);
40677 + atomic_inc_unchecked(&cm_closes);
40678 cm_event.event = IW_CM_EVENT_CLOSE;
40679 cm_event.status = 0;
40680 cm_event.provider_data = cm_id->provider_data;
40681 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40682 return;
40683 cm_id = cm_node->cm_id;
40684
40685 - atomic_inc(&cm_connect_reqs);
40686 + atomic_inc_unchecked(&cm_connect_reqs);
40687 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40688 cm_node, cm_id, jiffies);
40689
40690 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40691 return;
40692 cm_id = cm_node->cm_id;
40693
40694 - atomic_inc(&cm_connect_reqs);
40695 + atomic_inc_unchecked(&cm_connect_reqs);
40696 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40697 cm_node, cm_id, jiffies);
40698
40699 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40700 index 4166452..fc952c3 100644
40701 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40702 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40703 @@ -40,8 +40,8 @@
40704 #include "nes.h"
40705 #include "nes_mgt.h"
40706
40707 -atomic_t pau_qps_created;
40708 -atomic_t pau_qps_destroyed;
40709 +atomic_unchecked_t pau_qps_created;
40710 +atomic_unchecked_t pau_qps_destroyed;
40711
40712 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40713 {
40714 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40715 {
40716 struct sk_buff *skb;
40717 unsigned long flags;
40718 - atomic_inc(&pau_qps_destroyed);
40719 + atomic_inc_unchecked(&pau_qps_destroyed);
40720
40721 /* Free packets that have not yet been forwarded */
40722 /* Lock is acquired by skb_dequeue when removing the skb */
40723 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40724 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40725 skb_queue_head_init(&nesqp->pau_list);
40726 spin_lock_init(&nesqp->pau_lock);
40727 - atomic_inc(&pau_qps_created);
40728 + atomic_inc_unchecked(&pau_qps_created);
40729 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40730 }
40731
40732 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40733 index 49eb511..a774366 100644
40734 --- a/drivers/infiniband/hw/nes/nes_nic.c
40735 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40736 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40737 target_stat_values[++index] = mh_detected;
40738 target_stat_values[++index] = mh_pauses_sent;
40739 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40740 - target_stat_values[++index] = atomic_read(&cm_connects);
40741 - target_stat_values[++index] = atomic_read(&cm_accepts);
40742 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40743 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40744 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40745 - target_stat_values[++index] = atomic_read(&cm_rejects);
40746 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40747 - target_stat_values[++index] = atomic_read(&qps_created);
40748 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40749 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40750 - target_stat_values[++index] = atomic_read(&cm_closes);
40751 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40752 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40753 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40754 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40755 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40756 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40757 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40758 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40759 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40760 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40761 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40762 target_stat_values[++index] = cm_packets_sent;
40763 target_stat_values[++index] = cm_packets_bounced;
40764 target_stat_values[++index] = cm_packets_created;
40765 target_stat_values[++index] = cm_packets_received;
40766 target_stat_values[++index] = cm_packets_dropped;
40767 target_stat_values[++index] = cm_packets_retrans;
40768 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40769 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40770 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40771 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40772 target_stat_values[++index] = cm_backlog_drops;
40773 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40774 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40775 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40776 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40777 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40778 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40779 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40780 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40781 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40782 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40783 target_stat_values[++index] = nesadapter->free_4kpbl;
40784 target_stat_values[++index] = nesadapter->free_256pbl;
40785 target_stat_values[++index] = int_mod_timer_init;
40786 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40787 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40788 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40789 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40790 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40791 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40792 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40793 }
40794
40795 /**
40796 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40797 index 5b53ca5..443da3c 100644
40798 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40799 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40800 @@ -46,9 +46,9 @@
40801
40802 #include <rdma/ib_umem.h>
40803
40804 -atomic_t mod_qp_timouts;
40805 -atomic_t qps_created;
40806 -atomic_t sw_qps_destroyed;
40807 +atomic_unchecked_t mod_qp_timouts;
40808 +atomic_unchecked_t qps_created;
40809 +atomic_unchecked_t sw_qps_destroyed;
40810
40811 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40812
40813 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40814 if (init_attr->create_flags)
40815 return ERR_PTR(-EINVAL);
40816
40817 - atomic_inc(&qps_created);
40818 + atomic_inc_unchecked(&qps_created);
40819 switch (init_attr->qp_type) {
40820 case IB_QPT_RC:
40821 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40822 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40823 struct iw_cm_event cm_event;
40824 int ret = 0;
40825
40826 - atomic_inc(&sw_qps_destroyed);
40827 + atomic_inc_unchecked(&sw_qps_destroyed);
40828 nesqp->destroyed = 1;
40829
40830 /* Blow away the connection if it exists. */
40831 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40832 index 4a9af79..b993f75 100644
40833 --- a/drivers/infiniband/hw/qib/qib.h
40834 +++ b/drivers/infiniband/hw/qib/qib.h
40835 @@ -52,6 +52,7 @@
40836 #include <linux/kref.h>
40837 #include <linux/sched.h>
40838 #include <linux/kthread.h>
40839 +#include <linux/slab.h>
40840
40841 #include "qib_common.h"
40842 #include "qib_verbs.h"
40843 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40844 index da739d9..da1c7f4 100644
40845 --- a/drivers/input/gameport/gameport.c
40846 +++ b/drivers/input/gameport/gameport.c
40847 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40848 */
40849 static void gameport_init_port(struct gameport *gameport)
40850 {
40851 - static atomic_t gameport_no = ATOMIC_INIT(0);
40852 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40853
40854 __module_get(THIS_MODULE);
40855
40856 mutex_init(&gameport->drv_mutex);
40857 device_initialize(&gameport->dev);
40858 dev_set_name(&gameport->dev, "gameport%lu",
40859 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40860 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40861 gameport->dev.bus = &gameport_bus;
40862 gameport->dev.release = gameport_release_port;
40863 if (gameport->parent)
40864 diff --git a/drivers/input/input.c b/drivers/input/input.c
40865 index c044699..174d71a 100644
40866 --- a/drivers/input/input.c
40867 +++ b/drivers/input/input.c
40868 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40869 */
40870 int input_register_device(struct input_dev *dev)
40871 {
40872 - static atomic_t input_no = ATOMIC_INIT(0);
40873 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40874 struct input_devres *devres = NULL;
40875 struct input_handler *handler;
40876 unsigned int packet_size;
40877 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40878 dev->setkeycode = input_default_setkeycode;
40879
40880 dev_set_name(&dev->dev, "input%ld",
40881 - (unsigned long) atomic_inc_return(&input_no) - 1);
40882 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40883
40884 error = device_add(&dev->dev);
40885 if (error)
40886 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40887 index 04c69af..5f92d00 100644
40888 --- a/drivers/input/joystick/sidewinder.c
40889 +++ b/drivers/input/joystick/sidewinder.c
40890 @@ -30,6 +30,7 @@
40891 #include <linux/kernel.h>
40892 #include <linux/module.h>
40893 #include <linux/slab.h>
40894 +#include <linux/sched.h>
40895 #include <linux/init.h>
40896 #include <linux/input.h>
40897 #include <linux/gameport.h>
40898 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40899 index 75e3b10..fb390fd 100644
40900 --- a/drivers/input/joystick/xpad.c
40901 +++ b/drivers/input/joystick/xpad.c
40902 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40903
40904 static int xpad_led_probe(struct usb_xpad *xpad)
40905 {
40906 - static atomic_t led_seq = ATOMIC_INIT(0);
40907 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40908 long led_no;
40909 struct xpad_led *led;
40910 struct led_classdev *led_cdev;
40911 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40912 if (!led)
40913 return -ENOMEM;
40914
40915 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40916 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40917
40918 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40919 led->xpad = xpad;
40920 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40921 index e204f26..8459f15 100644
40922 --- a/drivers/input/misc/ims-pcu.c
40923 +++ b/drivers/input/misc/ims-pcu.c
40924 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40925
40926 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40927 {
40928 - static atomic_t device_no = ATOMIC_INIT(0);
40929 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40930
40931 const struct ims_pcu_device_info *info;
40932 u8 device_id;
40933 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40934 }
40935
40936 /* Device appears to be operable, complete initialization */
40937 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40938 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40939
40940 error = ims_pcu_setup_backlight(pcu);
40941 if (error)
40942 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40943 index 2f0b39d..7370f13 100644
40944 --- a/drivers/input/mouse/psmouse.h
40945 +++ b/drivers/input/mouse/psmouse.h
40946 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40947 ssize_t (*set)(struct psmouse *psmouse, void *data,
40948 const char *buf, size_t count);
40949 bool protect;
40950 -};
40951 +} __do_const;
40952 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40953
40954 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40955 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40956 index 4c842c3..590b0bf 100644
40957 --- a/drivers/input/mousedev.c
40958 +++ b/drivers/input/mousedev.c
40959 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40960
40961 spin_unlock_irq(&client->packet_lock);
40962
40963 - if (copy_to_user(buffer, data, count))
40964 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40965 return -EFAULT;
40966
40967 return count;
40968 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40969 index 25fc597..558bf3b3 100644
40970 --- a/drivers/input/serio/serio.c
40971 +++ b/drivers/input/serio/serio.c
40972 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40973 */
40974 static void serio_init_port(struct serio *serio)
40975 {
40976 - static atomic_t serio_no = ATOMIC_INIT(0);
40977 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40978
40979 __module_get(THIS_MODULE);
40980
40981 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40982 mutex_init(&serio->drv_mutex);
40983 device_initialize(&serio->dev);
40984 dev_set_name(&serio->dev, "serio%ld",
40985 - (long)atomic_inc_return(&serio_no) - 1);
40986 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40987 serio->dev.bus = &serio_bus;
40988 serio->dev.release = serio_release_port;
40989 serio->dev.groups = serio_device_attr_groups;
40990 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40991 index 59df2e7..8f1cafb 100644
40992 --- a/drivers/input/serio/serio_raw.c
40993 +++ b/drivers/input/serio/serio_raw.c
40994 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40995
40996 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40997 {
40998 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40999 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41000 struct serio_raw *serio_raw;
41001 int err;
41002
41003 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41004 }
41005
41006 snprintf(serio_raw->name, sizeof(serio_raw->name),
41007 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41008 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41009 kref_init(&serio_raw->kref);
41010 INIT_LIST_HEAD(&serio_raw->client_list);
41011 init_waitqueue_head(&serio_raw->wait);
41012 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41013 index fbe9ca7..dbee61d 100644
41014 --- a/drivers/iommu/iommu.c
41015 +++ b/drivers/iommu/iommu.c
41016 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41017 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41018 {
41019 bus_register_notifier(bus, &iommu_bus_nb);
41020 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41021 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41022 }
41023
41024 /**
41025 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41026 index 39f81ae..2660096 100644
41027 --- a/drivers/iommu/irq_remapping.c
41028 +++ b/drivers/iommu/irq_remapping.c
41029 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41030 void panic_if_irq_remap(const char *msg)
41031 {
41032 if (irq_remapping_enabled)
41033 - panic(msg);
41034 + panic("%s", msg);
41035 }
41036
41037 static void ir_ack_apic_edge(struct irq_data *data)
41038 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41039
41040 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41041 {
41042 - chip->irq_print_chip = ir_print_prefix;
41043 - chip->irq_ack = ir_ack_apic_edge;
41044 - chip->irq_eoi = ir_ack_apic_level;
41045 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41046 + pax_open_kernel();
41047 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41048 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41049 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41050 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41051 + pax_close_kernel();
41052 }
41053
41054 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41055 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41056 index ee7c503..5d4ce08 100644
41057 --- a/drivers/irqchip/irq-gic.c
41058 +++ b/drivers/irqchip/irq-gic.c
41059 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41060 * Supported arch specific GIC irq extension.
41061 * Default make them NULL.
41062 */
41063 -struct irq_chip gic_arch_extn = {
41064 +irq_chip_no_const gic_arch_extn = {
41065 .irq_eoi = NULL,
41066 .irq_mask = NULL,
41067 .irq_unmask = NULL,
41068 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41069 chained_irq_exit(chip, desc);
41070 }
41071
41072 -static struct irq_chip gic_chip = {
41073 +static irq_chip_no_const gic_chip __read_only = {
41074 .name = "GIC",
41075 .irq_mask = gic_mask_irq,
41076 .irq_unmask = gic_unmask_irq,
41077 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41078 index ac6f72b..81150f2 100644
41079 --- a/drivers/isdn/capi/capi.c
41080 +++ b/drivers/isdn/capi/capi.c
41081 @@ -81,8 +81,8 @@ struct capiminor {
41082
41083 struct capi20_appl *ap;
41084 u32 ncci;
41085 - atomic_t datahandle;
41086 - atomic_t msgid;
41087 + atomic_unchecked_t datahandle;
41088 + atomic_unchecked_t msgid;
41089
41090 struct tty_port port;
41091 int ttyinstop;
41092 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41093 capimsg_setu16(s, 2, mp->ap->applid);
41094 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41095 capimsg_setu8 (s, 5, CAPI_RESP);
41096 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41097 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41098 capimsg_setu32(s, 8, mp->ncci);
41099 capimsg_setu16(s, 12, datahandle);
41100 }
41101 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41102 mp->outbytes -= len;
41103 spin_unlock_bh(&mp->outlock);
41104
41105 - datahandle = atomic_inc_return(&mp->datahandle);
41106 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41107 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41108 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41109 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41110 capimsg_setu16(skb->data, 2, mp->ap->applid);
41111 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41112 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41113 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41114 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41115 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41116 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41117 capimsg_setu16(skb->data, 16, len); /* Data length */
41118 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41119 index 600c79b..3752bab 100644
41120 --- a/drivers/isdn/gigaset/interface.c
41121 +++ b/drivers/isdn/gigaset/interface.c
41122 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41123 }
41124 tty->driver_data = cs;
41125
41126 - ++cs->port.count;
41127 + atomic_inc(&cs->port.count);
41128
41129 - if (cs->port.count == 1) {
41130 + if (atomic_read(&cs->port.count) == 1) {
41131 tty_port_tty_set(&cs->port, tty);
41132 cs->port.low_latency = 1;
41133 }
41134 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41135
41136 if (!cs->connected)
41137 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41138 - else if (!cs->port.count)
41139 + else if (!atomic_read(&cs->port.count))
41140 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41141 - else if (!--cs->port.count)
41142 + else if (!atomic_dec_return(&cs->port.count))
41143 tty_port_tty_set(&cs->port, NULL);
41144
41145 mutex_unlock(&cs->mutex);
41146 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41147 index d0a41cb..f0cdb8c 100644
41148 --- a/drivers/isdn/gigaset/usb-gigaset.c
41149 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41150 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41151 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41152 memcpy(cs->hw.usb->bchars, buf, 6);
41153 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41154 - 0, 0, &buf, 6, 2000);
41155 + 0, 0, buf, 6, 2000);
41156 }
41157
41158 static void gigaset_freebcshw(struct bc_state *bcs)
41159 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41160 index 4d9b195..455075c 100644
41161 --- a/drivers/isdn/hardware/avm/b1.c
41162 +++ b/drivers/isdn/hardware/avm/b1.c
41163 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41164 }
41165 if (left) {
41166 if (t4file->user) {
41167 - if (copy_from_user(buf, dp, left))
41168 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41169 return -EFAULT;
41170 } else {
41171 memcpy(buf, dp, left);
41172 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41173 }
41174 if (left) {
41175 if (config->user) {
41176 - if (copy_from_user(buf, dp, left))
41177 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41178 return -EFAULT;
41179 } else {
41180 memcpy(buf, dp, left);
41181 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41182 index 1063bab..36817e0 100644
41183 --- a/drivers/isdn/hisax/amd7930_fn.c
41184 +++ b/drivers/isdn/hisax/amd7930_fn.c
41185 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41186
41187 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41188 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41189 - debugl1(cs, cs->dlog);
41190 + debugl1(cs, "%s", cs->dlog);
41191 }
41192 /* moves received data in sk-buffer */
41193 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41194 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41195
41196 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41197 QuickHex(t, deb_ptr, count);
41198 - debugl1(cs, cs->dlog);
41199 + debugl1(cs, "%s", cs->dlog);
41200 }
41201 /* AMD interrupts on */
41202 AmdIrqOn(cs);
41203 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41204 index ee9b9a0..d1427bd 100644
41205 --- a/drivers/isdn/hisax/avm_pci.c
41206 +++ b/drivers/isdn/hisax/avm_pci.c
41207 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41208 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41209 bcs->channel ? 'B' : 'A', count);
41210 QuickHex(t, p, count);
41211 - debugl1(cs, bcs->blog);
41212 + debugl1(cs, "%s", bcs->blog);
41213 }
41214 }
41215
41216 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41217 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41218 bcs->channel ? 'B' : 'A', count);
41219 QuickHex(t, p, count);
41220 - debugl1(cs, bcs->blog);
41221 + debugl1(cs, "%s", bcs->blog);
41222 }
41223 }
41224
41225 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41226 index bf04d2a..b33f53b 100644
41227 --- a/drivers/isdn/hisax/config.c
41228 +++ b/drivers/isdn/hisax/config.c
41229 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41230 ptr--;
41231 *ptr++ = '\n';
41232 *ptr = 0;
41233 - HiSax_putstatus(cs, NULL, cs->dlog);
41234 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41235 } else
41236 HiSax_putstatus(cs, "LogEcho: ",
41237 "warning Frame too big (%d)",
41238 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41239 index 8d0cf6e..4fc90de 100644
41240 --- a/drivers/isdn/hisax/diva.c
41241 +++ b/drivers/isdn/hisax/diva.c
41242 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41243 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41244 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41245 QuickHex(t, ptr, count);
41246 - debugl1(cs, bcs->blog);
41247 + debugl1(cs, "%s", bcs->blog);
41248 }
41249 }
41250
41251 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41252 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41253 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41254 QuickHex(t, ptr, count);
41255 - debugl1(cs, bcs->blog);
41256 + debugl1(cs, "%s", bcs->blog);
41257 }
41258 }
41259
41260 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41261 index 1df6f9a..2be1c8a 100644
41262 --- a/drivers/isdn/hisax/elsa.c
41263 +++ b/drivers/isdn/hisax/elsa.c
41264 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41265 t = tmp;
41266 t += sprintf(tmp, "Arcofi data");
41267 QuickHex(t, p, cs->dc.isac.mon_rxp);
41268 - debugl1(cs, tmp);
41269 + debugl1(cs, "%s", tmp);
41270 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41271 switch (cs->dc.isac.mon_rx[1]) {
41272 case 0x80:
41273 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41274 index d4c98d3..3f84dd8 100644
41275 --- a/drivers/isdn/hisax/elsa_ser.c
41276 +++ b/drivers/isdn/hisax/elsa_ser.c
41277 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41278
41279 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41280 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41281 - debugl1(cs, tmp);
41282 + debugl1(cs, "%s", tmp);
41283 }
41284 cs->hw.elsa.rcvcnt = 0;
41285 }
41286 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41287 index 3ccd724..497bd02 100644
41288 --- a/drivers/isdn/hisax/hfc_pci.c
41289 +++ b/drivers/isdn/hisax/hfc_pci.c
41290 @@ -901,7 +901,7 @@ Begin:
41291 ptr--;
41292 *ptr++ = '\n';
41293 *ptr = 0;
41294 - HiSax_putstatus(cs, NULL, cs->dlog);
41295 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41296 } else
41297 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41298 }
41299 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41300 index dc4574f..fa1fefd 100644
41301 --- a/drivers/isdn/hisax/hfc_sx.c
41302 +++ b/drivers/isdn/hisax/hfc_sx.c
41303 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41304 ptr--;
41305 *ptr++ = '\n';
41306 *ptr = 0;
41307 - HiSax_putstatus(cs, NULL, cs->dlog);
41308 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41309 } else
41310 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41311 }
41312 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41313 index f398d48..a8d6188 100644
41314 --- a/drivers/isdn/hisax/hscx_irq.c
41315 +++ b/drivers/isdn/hisax/hscx_irq.c
41316 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41317 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41318 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41319 QuickHex(t, ptr, count);
41320 - debugl1(cs, bcs->blog);
41321 + debugl1(cs, "%s", bcs->blog);
41322 }
41323 }
41324
41325 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41326 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41327 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41328 QuickHex(t, ptr, count);
41329 - debugl1(cs, bcs->blog);
41330 + debugl1(cs, "%s", bcs->blog);
41331 }
41332 }
41333
41334 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41335 index db5321f..51dae91 100644
41336 --- a/drivers/isdn/hisax/icc.c
41337 +++ b/drivers/isdn/hisax/icc.c
41338 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41339
41340 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41341 QuickHex(t, ptr, count);
41342 - debugl1(cs, cs->dlog);
41343 + debugl1(cs, "%s", cs->dlog);
41344 }
41345 }
41346
41347 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41348
41349 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41350 QuickHex(t, ptr, count);
41351 - debugl1(cs, cs->dlog);
41352 + debugl1(cs, "%s", cs->dlog);
41353 }
41354 }
41355
41356 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41357 index 74feb5c..5faa5de 100644
41358 --- a/drivers/isdn/hisax/ipacx.c
41359 +++ b/drivers/isdn/hisax/ipacx.c
41360 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41361
41362 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41363 QuickHex(t, ptr, count);
41364 - debugl1(cs, cs->dlog);
41365 + debugl1(cs, "%s", cs->dlog);
41366 }
41367 }
41368
41369 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41370
41371 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41372 QuickHex(t, ptr, count);
41373 - debugl1(cs, cs->dlog);
41374 + debugl1(cs, "%s", cs->dlog);
41375 }
41376 }
41377
41378 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41379
41380 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41381 QuickHex(t, ptr, count);
41382 - debugl1(cs, bcs->blog);
41383 + debugl1(cs, "%s", bcs->blog);
41384 }
41385 }
41386
41387 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41388
41389 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41390 QuickHex(t, ptr, count);
41391 - debugl1(cs, bcs->blog);
41392 + debugl1(cs, "%s", bcs->blog);
41393 }
41394 }
41395
41396 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41397 index a365ccc..7fdf78f 100644
41398 --- a/drivers/isdn/hisax/isac.c
41399 +++ b/drivers/isdn/hisax/isac.c
41400 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41401
41402 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41403 QuickHex(t, ptr, count);
41404 - debugl1(cs, cs->dlog);
41405 + debugl1(cs, "%s", cs->dlog);
41406 }
41407 }
41408
41409 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41410
41411 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41412 QuickHex(t, ptr, count);
41413 - debugl1(cs, cs->dlog);
41414 + debugl1(cs, "%s", cs->dlog);
41415 }
41416 }
41417
41418 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41419 index 7fdf347..f4956c7 100644
41420 --- a/drivers/isdn/hisax/isar.c
41421 +++ b/drivers/isdn/hisax/isar.c
41422 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41423 t = tmp;
41424 t += sprintf(t, "sendmbox cnt %d", len);
41425 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41426 - debugl1(cs, tmp);
41427 + debugl1(cs, "%s", tmp);
41428 i -= 64;
41429 }
41430 }
41431 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41432 t = tmp;
41433 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41434 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41435 - debugl1(cs, tmp);
41436 + debugl1(cs, "%s", tmp);
41437 i -= 64;
41438 }
41439 }
41440 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41441 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41442 ireg->iis, ireg->cmsb);
41443 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41444 - debugl1(cs, debbuf);
41445 + debugl1(cs, "%s", debbuf);
41446 }
41447 break;
41448 case ISAR_IIS_INVMSG:
41449 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41450 index f946c58..e2ae787 100644
41451 --- a/drivers/isdn/hisax/jade.c
41452 +++ b/drivers/isdn/hisax/jade.c
41453 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41454 int jade = bcs->hw.hscx.hscx;
41455
41456 if (cs->debug & L1_DEB_HSCX) {
41457 - char tmp[40];
41458 - sprintf(tmp, "jade %c mode %d ichan %d",
41459 - 'A' + jade, mode, bc);
41460 - debugl1(cs, tmp);
41461 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41462 }
41463 bcs->mode = mode;
41464 bcs->channel = bc;
41465 @@ -257,23 +254,18 @@ void
41466 clear_pending_jade_ints(struct IsdnCardState *cs)
41467 {
41468 int val;
41469 - char tmp[64];
41470
41471 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41472 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41473
41474 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41475 - sprintf(tmp, "jade B ISTA %x", val);
41476 - debugl1(cs, tmp);
41477 + debugl1(cs, "jade B ISTA %x", val);
41478 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41479 - sprintf(tmp, "jade A ISTA %x", val);
41480 - debugl1(cs, tmp);
41481 + debugl1(cs, "jade A ISTA %x", val);
41482 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41483 - sprintf(tmp, "jade B STAR %x", val);
41484 - debugl1(cs, tmp);
41485 + debugl1(cs, "jade B STAR %x", val);
41486 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41487 - sprintf(tmp, "jade A STAR %x", val);
41488 - debugl1(cs, tmp);
41489 + debugl1(cs, "jade A STAR %x", val);
41490 /* Unmask ints */
41491 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41492 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41493 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41494 index f521fc8..b930da9 100644
41495 --- a/drivers/isdn/hisax/jade_irq.c
41496 +++ b/drivers/isdn/hisax/jade_irq.c
41497 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41498 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41499 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41500 QuickHex(t, ptr, count);
41501 - debugl1(cs, bcs->blog);
41502 + debugl1(cs, "%s", bcs->blog);
41503 }
41504 }
41505
41506 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41507 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41508 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41509 QuickHex(t, ptr, count);
41510 - debugl1(cs, bcs->blog);
41511 + debugl1(cs, "%s", bcs->blog);
41512 }
41513 }
41514
41515 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41516 index 4c1bca5..875402e 100644
41517 --- a/drivers/isdn/hisax/l3_1tr6.c
41518 +++ b/drivers/isdn/hisax/l3_1tr6.c
41519 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41520 {
41521 dev_kfree_skb(skb);
41522 if (pc->st->l3.debug & L3_DEB_WARN)
41523 - l3_debug(pc->st, msg);
41524 + l3_debug(pc->st, "%s", msg);
41525 l3_1tr6_release_req(pc, 0, NULL);
41526 }
41527
41528 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41529 {
41530 u_char *p;
41531 int bcfound = 0;
41532 - char tmp[80];
41533 struct sk_buff *skb = arg;
41534
41535 /* Channel Identification */
41536 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41537 /* Signal all services, linklevel takes care of Service-Indicator */
41538 if (bcfound) {
41539 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41540 - sprintf(tmp, "non-digital call: %s -> %s",
41541 + l3_debug(pc->st, "non-digital call: %s -> %s",
41542 pc->para.setup.phone,
41543 pc->para.setup.eazmsn);
41544 - l3_debug(pc->st, tmp);
41545 }
41546 newl3state(pc, 6);
41547 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41548 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41549 {
41550 u_char *p;
41551 int i, tmpcharge = 0;
41552 - char a_charge[8], tmp[32];
41553 + char a_charge[8];
41554 struct sk_buff *skb = arg;
41555
41556 p = skb->data;
41557 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41558 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41559 }
41560 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41561 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41562 - l3_debug(pc->st, tmp);
41563 + l3_debug(pc->st, "charging info %d",
41564 + pc->para.chargeinfo);
41565 }
41566 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41567 l3_debug(pc->st, "charging info not found");
41568 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41569 struct sk_buff *skb = arg;
41570 u_char *p;
41571 int i, tmpcharge = 0;
41572 - char a_charge[8], tmp[32];
41573 + char a_charge[8];
41574
41575 StopAllL3Timer(pc);
41576 p = skb->data;
41577 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41578 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41579 }
41580 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41581 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41582 - l3_debug(pc->st, tmp);
41583 + l3_debug(pc->st, "charging info %d",
41584 + pc->para.chargeinfo);
41585 }
41586 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41587 l3_debug(pc->st, "charging info not found");
41588 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41589 int i, mt, cr;
41590 struct l3_process *proc;
41591 struct sk_buff *skb = arg;
41592 - char tmp[80];
41593
41594 switch (pr) {
41595 case (DL_DATA | INDICATION):
41596 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41597 }
41598 if (skb->len < 4) {
41599 if (st->l3.debug & L3_DEB_PROTERR) {
41600 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41601 - l3_debug(st, tmp);
41602 + l3_debug(st, "up1tr6 len only %d", skb->len);
41603 }
41604 dev_kfree_skb(skb);
41605 return;
41606 }
41607 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41608 if (st->l3.debug & L3_DEB_PROTERR) {
41609 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41610 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41611 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41612 skb->data[0], skb->len);
41613 - l3_debug(st, tmp);
41614 }
41615 dev_kfree_skb(skb);
41616 return;
41617 }
41618 if (skb->data[1] != 1) {
41619 if (st->l3.debug & L3_DEB_PROTERR) {
41620 - sprintf(tmp, "up1tr6 CR len not 1");
41621 - l3_debug(st, tmp);
41622 + l3_debug(st, "up1tr6 CR len not 1");
41623 }
41624 dev_kfree_skb(skb);
41625 return;
41626 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41627 if (skb->data[0] == PROTO_DIS_N0) {
41628 dev_kfree_skb(skb);
41629 if (st->l3.debug & L3_DEB_STATE) {
41630 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41631 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41632 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41633 - l3_debug(st, tmp);
41634 }
41635 } else if (skb->data[0] == PROTO_DIS_N1) {
41636 if (!(proc = getl3proc(st, cr))) {
41637 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41638 if (cr < 128) {
41639 if (!(proc = new_l3_process(st, cr))) {
41640 if (st->l3.debug & L3_DEB_PROTERR) {
41641 - sprintf(tmp, "up1tr6 no roc mem");
41642 - l3_debug(st, tmp);
41643 + l3_debug(st, "up1tr6 no roc mem");
41644 }
41645 dev_kfree_skb(skb);
41646 return;
41647 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41648 } else {
41649 if (!(proc = new_l3_process(st, cr))) {
41650 if (st->l3.debug & L3_DEB_PROTERR) {
41651 - sprintf(tmp, "up1tr6 no roc mem");
41652 - l3_debug(st, tmp);
41653 + l3_debug(st, "up1tr6 no roc mem");
41654 }
41655 dev_kfree_skb(skb);
41656 return;
41657 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41658 if (i == ARRAY_SIZE(datastln1)) {
41659 dev_kfree_skb(skb);
41660 if (st->l3.debug & L3_DEB_STATE) {
41661 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41662 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41663 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41664 proc->state, mt);
41665 - l3_debug(st, tmp);
41666 }
41667 return;
41668 } else {
41669 if (st->l3.debug & L3_DEB_STATE) {
41670 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41671 + l3_debug(st, "up1tr6%sstate %d mt %x",
41672 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41673 proc->state, mt);
41674 - l3_debug(st, tmp);
41675 }
41676 datastln1[i].rout(proc, pr, skb);
41677 }
41678 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41679 int i, cr;
41680 struct l3_process *proc;
41681 struct Channel *chan;
41682 - char tmp[80];
41683
41684 if ((DL_ESTABLISH | REQUEST) == pr) {
41685 l3_msg(st, pr, NULL);
41686 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41687 break;
41688 if (i == ARRAY_SIZE(downstl)) {
41689 if (st->l3.debug & L3_DEB_STATE) {
41690 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41691 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41692 proc->state, pr);
41693 - l3_debug(st, tmp);
41694 }
41695 } else {
41696 if (st->l3.debug & L3_DEB_STATE) {
41697 - sprintf(tmp, "down1tr6 state %d prim %d",
41698 + l3_debug(st, "down1tr6 state %d prim %d",
41699 proc->state, pr);
41700 - l3_debug(st, tmp);
41701 }
41702 downstl[i].rout(proc, pr, arg);
41703 }
41704 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41705 index b646eed..233e432 100644
41706 --- a/drivers/isdn/hisax/netjet.c
41707 +++ b/drivers/isdn/hisax/netjet.c
41708 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41709 else
41710 j = i;
41711 QuickHex(t, p, j);
41712 - debugl1(cs, tmp);
41713 + debugl1(cs, "%s", tmp);
41714 p += j;
41715 i -= j;
41716 t = tmp;
41717 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41718 index 041bf52..af1b020 100644
41719 --- a/drivers/isdn/hisax/q931.c
41720 +++ b/drivers/isdn/hisax/q931.c
41721 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41722 dp--;
41723 *dp++ = '\n';
41724 *dp = 0;
41725 - HiSax_putstatus(cs, NULL, cs->dlog);
41726 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41727 } else
41728 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41729 }
41730 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41731 }
41732 if (finish) {
41733 *dp = 0;
41734 - HiSax_putstatus(cs, NULL, cs->dlog);
41735 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41736 return;
41737 }
41738 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41739 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41740 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41741 }
41742 *dp = 0;
41743 - HiSax_putstatus(cs, NULL, cs->dlog);
41744 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41745 }
41746 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41747 index d8cac69..a858955 100644
41748 --- a/drivers/isdn/hisax/w6692.c
41749 +++ b/drivers/isdn/hisax/w6692.c
41750 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41751
41752 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41753 QuickHex(t, ptr, count);
41754 - debugl1(cs, cs->dlog);
41755 + debugl1(cs, "%s", cs->dlog);
41756 }
41757 }
41758
41759 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41760
41761 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41762 QuickHex(t, ptr, count);
41763 - debugl1(cs, cs->dlog);
41764 + debugl1(cs, "%s", cs->dlog);
41765 }
41766 }
41767
41768 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41769 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41770 bcs->channel + '1', count);
41771 QuickHex(t, ptr, count);
41772 - debugl1(cs, bcs->blog);
41773 + debugl1(cs, "%s", bcs->blog);
41774 }
41775 }
41776
41777 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41778 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41779 bcs->channel + '1', count);
41780 QuickHex(t, ptr, count);
41781 - debugl1(cs, bcs->blog);
41782 + debugl1(cs, "%s", bcs->blog);
41783 }
41784 }
41785
41786 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41787 index 9bb12ba..d4262f7 100644
41788 --- a/drivers/isdn/i4l/isdn_common.c
41789 +++ b/drivers/isdn/i4l/isdn_common.c
41790 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41791 } else
41792 return -EINVAL;
41793 case IIOCDBGVAR:
41794 + if (!capable(CAP_SYS_RAWIO))
41795 + return -EPERM;
41796 if (arg) {
41797 if (copy_to_user(argp, &dev, sizeof(ulong)))
41798 return -EFAULT;
41799 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41800 index 3c5f249..5fac4d0 100644
41801 --- a/drivers/isdn/i4l/isdn_tty.c
41802 +++ b/drivers/isdn/i4l/isdn_tty.c
41803 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41804
41805 #ifdef ISDN_DEBUG_MODEM_OPEN
41806 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41807 - port->count);
41808 + atomic_read(&port->count));
41809 #endif
41810 - port->count++;
41811 + atomic_inc(&port->count);
41812 port->tty = tty;
41813 /*
41814 * Start up serial port
41815 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41816 #endif
41817 return;
41818 }
41819 - if ((tty->count == 1) && (port->count != 1)) {
41820 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41821 /*
41822 * Uh, oh. tty->count is 1, which means that the tty
41823 * structure will be freed. Info->count should always
41824 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41825 * serial port won't be shutdown.
41826 */
41827 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41828 - "info->count is %d\n", port->count);
41829 - port->count = 1;
41830 + "info->count is %d\n", atomic_read(&port->count));
41831 + atomic_set(&port->count, 1);
41832 }
41833 - if (--port->count < 0) {
41834 + if (atomic_dec_return(&port->count) < 0) {
41835 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41836 - info->line, port->count);
41837 - port->count = 0;
41838 + info->line, atomic_read(&port->count));
41839 + atomic_set(&port->count, 0);
41840 }
41841 - if (port->count) {
41842 + if (atomic_read(&port->count)) {
41843 #ifdef ISDN_DEBUG_MODEM_OPEN
41844 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41845 #endif
41846 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41847 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41848 return;
41849 isdn_tty_shutdown(info);
41850 - port->count = 0;
41851 + atomic_set(&port->count, 0);
41852 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41853 port->tty = NULL;
41854 wake_up_interruptible(&port->open_wait);
41855 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41856 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41857 modem_info *info = &dev->mdm.info[i];
41858
41859 - if (info->port.count == 0)
41860 + if (atomic_read(&info->port.count) == 0)
41861 continue;
41862 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41863 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41864 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41865 index e74df7c..03a03ba 100644
41866 --- a/drivers/isdn/icn/icn.c
41867 +++ b/drivers/isdn/icn/icn.c
41868 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41869 if (count > len)
41870 count = len;
41871 if (user) {
41872 - if (copy_from_user(msg, buf, count))
41873 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41874 return -EFAULT;
41875 } else
41876 memcpy(msg, buf, count);
41877 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41878 index 6a8405d..0bd1c7e 100644
41879 --- a/drivers/leds/leds-clevo-mail.c
41880 +++ b/drivers/leds/leds-clevo-mail.c
41881 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41882 * detected as working, but in reality it is not) as low as
41883 * possible.
41884 */
41885 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41886 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41887 {
41888 .callback = clevo_mail_led_dmi_callback,
41889 .ident = "Clevo D410J",
41890 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41891 index 64e204e..c6bf189 100644
41892 --- a/drivers/leds/leds-ss4200.c
41893 +++ b/drivers/leds/leds-ss4200.c
41894 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41895 * detected as working, but in reality it is not) as low as
41896 * possible.
41897 */
41898 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41899 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41900 {
41901 .callback = ss4200_led_dmi_callback,
41902 .ident = "Intel SS4200-E",
41903 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41904 index 0bf1e4e..b4bf44e 100644
41905 --- a/drivers/lguest/core.c
41906 +++ b/drivers/lguest/core.c
41907 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41908 * The end address needs +1 because __get_vm_area allocates an
41909 * extra guard page, so we need space for that.
41910 */
41911 +
41912 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41913 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41914 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41915 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41916 +#else
41917 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41918 VM_ALLOC, switcher_addr, switcher_addr
41919 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41920 +#endif
41921 +
41922 if (!switcher_vma) {
41923 err = -ENOMEM;
41924 printk("lguest: could not map switcher pages high\n");
41925 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41926 * Now the Switcher is mapped at the right address, we can't fail!
41927 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41928 */
41929 - memcpy(switcher_vma->addr, start_switcher_text,
41930 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41931 end_switcher_text - start_switcher_text);
41932
41933 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41934 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41935 index a35d8d1..59fb772 100644
41936 --- a/drivers/lguest/page_tables.c
41937 +++ b/drivers/lguest/page_tables.c
41938 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41939 /*:*/
41940
41941 #ifdef CONFIG_X86_PAE
41942 -static void release_pmd(pmd_t *spmd)
41943 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41944 {
41945 /* If the entry's not present, there's nothing to release. */
41946 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41947 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41948 index 5169239..47cb4db 100644
41949 --- a/drivers/lguest/x86/core.c
41950 +++ b/drivers/lguest/x86/core.c
41951 @@ -59,7 +59,7 @@ static struct {
41952 /* Offset from where switcher.S was compiled to where we've copied it */
41953 static unsigned long switcher_offset(void)
41954 {
41955 - return switcher_addr - (unsigned long)start_switcher_text;
41956 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41957 }
41958
41959 /* This cpu's struct lguest_pages (after the Switcher text page) */
41960 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41961 * These copies are pretty cheap, so we do them unconditionally: */
41962 /* Save the current Host top-level page directory.
41963 */
41964 +
41965 +#ifdef CONFIG_PAX_PER_CPU_PGD
41966 + pages->state.host_cr3 = read_cr3();
41967 +#else
41968 pages->state.host_cr3 = __pa(current->mm->pgd);
41969 +#endif
41970 +
41971 /*
41972 * Set up the Guest's page tables to see this CPU's pages (and no
41973 * other CPU's pages).
41974 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41975 * compiled-in switcher code and the high-mapped copy we just made.
41976 */
41977 for (i = 0; i < IDT_ENTRIES; i++)
41978 - default_idt_entries[i] += switcher_offset();
41979 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41980
41981 /*
41982 * Set up the Switcher's per-cpu areas.
41983 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41984 * it will be undisturbed when we switch. To change %cs and jump we
41985 * need this structure to feed to Intel's "lcall" instruction.
41986 */
41987 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41988 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41989 lguest_entry.segment = LGUEST_CS;
41990
41991 /*
41992 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41993 index 40634b0..4f5855e 100644
41994 --- a/drivers/lguest/x86/switcher_32.S
41995 +++ b/drivers/lguest/x86/switcher_32.S
41996 @@ -87,6 +87,7 @@
41997 #include <asm/page.h>
41998 #include <asm/segment.h>
41999 #include <asm/lguest.h>
42000 +#include <asm/processor-flags.h>
42001
42002 // We mark the start of the code to copy
42003 // It's placed in .text tho it's never run here
42004 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42005 // Changes type when we load it: damn Intel!
42006 // For after we switch over our page tables
42007 // That entry will be read-only: we'd crash.
42008 +
42009 +#ifdef CONFIG_PAX_KERNEXEC
42010 + mov %cr0, %edx
42011 + xor $X86_CR0_WP, %edx
42012 + mov %edx, %cr0
42013 +#endif
42014 +
42015 movl $(GDT_ENTRY_TSS*8), %edx
42016 ltr %dx
42017
42018 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42019 // Let's clear it again for our return.
42020 // The GDT descriptor of the Host
42021 // Points to the table after two "size" bytes
42022 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42023 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42024 // Clear "used" from type field (byte 5, bit 2)
42025 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42026 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42027 +
42028 +#ifdef CONFIG_PAX_KERNEXEC
42029 + mov %cr0, %eax
42030 + xor $X86_CR0_WP, %eax
42031 + mov %eax, %cr0
42032 +#endif
42033
42034 // Once our page table's switched, the Guest is live!
42035 // The Host fades as we run this final step.
42036 @@ -295,13 +309,12 @@ deliver_to_host:
42037 // I consulted gcc, and it gave
42038 // These instructions, which I gladly credit:
42039 leal (%edx,%ebx,8), %eax
42040 - movzwl (%eax),%edx
42041 - movl 4(%eax), %eax
42042 - xorw %ax, %ax
42043 - orl %eax, %edx
42044 + movl 4(%eax), %edx
42045 + movw (%eax), %dx
42046 // Now the address of the handler's in %edx
42047 // We call it now: its "iret" drops us home.
42048 - jmp *%edx
42049 + ljmp $__KERNEL_CS, $1f
42050 +1: jmp *%edx
42051
42052 // Every interrupt can come to us here
42053 // But we must truly tell each apart.
42054 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42055 index 0003992..854bbce 100644
42056 --- a/drivers/md/bcache/closure.h
42057 +++ b/drivers/md/bcache/closure.h
42058 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42059 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42060 struct workqueue_struct *wq)
42061 {
42062 - BUG_ON(object_is_on_stack(cl));
42063 + BUG_ON(object_starts_on_stack(cl));
42064 closure_set_ip(cl);
42065 cl->fn = fn;
42066 cl->wq = wq;
42067 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42068 index 547c4c5..5be1de4 100644
42069 --- a/drivers/md/bcache/super.c
42070 +++ b/drivers/md/bcache/super.c
42071 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42072 err:
42073 closure_sync(&op.cl);
42074 /* XXX: test this, it's broken */
42075 - bch_cache_set_error(c, err);
42076 + bch_cache_set_error(c, "%s", err);
42077 }
42078
42079 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42080 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42081 index a7fd821..9dcf6c3 100644
42082 --- a/drivers/md/bitmap.c
42083 +++ b/drivers/md/bitmap.c
42084 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42085 chunk_kb ? "KB" : "B");
42086 if (bitmap->storage.file) {
42087 seq_printf(seq, ", file: ");
42088 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42089 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42090 }
42091
42092 seq_printf(seq, "\n");
42093 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42094 index f1b7586..a49c4bd 100644
42095 --- a/drivers/md/dm-ioctl.c
42096 +++ b/drivers/md/dm-ioctl.c
42097 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42098 cmd == DM_LIST_VERSIONS_CMD)
42099 return 0;
42100
42101 - if ((cmd == DM_DEV_CREATE_CMD)) {
42102 + if (cmd == DM_DEV_CREATE_CMD) {
42103 if (!*param->name) {
42104 DMWARN("name not supplied when creating device");
42105 return -EINVAL;
42106 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42107 index 699b5be..eac0a15 100644
42108 --- a/drivers/md/dm-raid1.c
42109 +++ b/drivers/md/dm-raid1.c
42110 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42111
42112 struct mirror {
42113 struct mirror_set *ms;
42114 - atomic_t error_count;
42115 + atomic_unchecked_t error_count;
42116 unsigned long error_type;
42117 struct dm_dev *dev;
42118 sector_t offset;
42119 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42120 struct mirror *m;
42121
42122 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42123 - if (!atomic_read(&m->error_count))
42124 + if (!atomic_read_unchecked(&m->error_count))
42125 return m;
42126
42127 return NULL;
42128 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42129 * simple way to tell if a device has encountered
42130 * errors.
42131 */
42132 - atomic_inc(&m->error_count);
42133 + atomic_inc_unchecked(&m->error_count);
42134
42135 if (test_and_set_bit(error_type, &m->error_type))
42136 return;
42137 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42138 struct mirror *m = get_default_mirror(ms);
42139
42140 do {
42141 - if (likely(!atomic_read(&m->error_count)))
42142 + if (likely(!atomic_read_unchecked(&m->error_count)))
42143 return m;
42144
42145 if (m-- == ms->mirror)
42146 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42147 {
42148 struct mirror *default_mirror = get_default_mirror(m->ms);
42149
42150 - return !atomic_read(&default_mirror->error_count);
42151 + return !atomic_read_unchecked(&default_mirror->error_count);
42152 }
42153
42154 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42155 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42156 */
42157 if (likely(region_in_sync(ms, region, 1)))
42158 m = choose_mirror(ms, bio->bi_sector);
42159 - else if (m && atomic_read(&m->error_count))
42160 + else if (m && atomic_read_unchecked(&m->error_count))
42161 m = NULL;
42162
42163 if (likely(m))
42164 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42165 }
42166
42167 ms->mirror[mirror].ms = ms;
42168 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42169 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42170 ms->mirror[mirror].error_type = 0;
42171 ms->mirror[mirror].offset = offset;
42172
42173 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42174 */
42175 static char device_status_char(struct mirror *m)
42176 {
42177 - if (!atomic_read(&(m->error_count)))
42178 + if (!atomic_read_unchecked(&(m->error_count)))
42179 return 'A';
42180
42181 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42182 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42183 index d907ca6..cfb8384 100644
42184 --- a/drivers/md/dm-stripe.c
42185 +++ b/drivers/md/dm-stripe.c
42186 @@ -20,7 +20,7 @@ struct stripe {
42187 struct dm_dev *dev;
42188 sector_t physical_start;
42189
42190 - atomic_t error_count;
42191 + atomic_unchecked_t error_count;
42192 };
42193
42194 struct stripe_c {
42195 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42196 kfree(sc);
42197 return r;
42198 }
42199 - atomic_set(&(sc->stripe[i].error_count), 0);
42200 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42201 }
42202
42203 ti->private = sc;
42204 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42205 DMEMIT("%d ", sc->stripes);
42206 for (i = 0; i < sc->stripes; i++) {
42207 DMEMIT("%s ", sc->stripe[i].dev->name);
42208 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42209 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42210 'D' : 'A';
42211 }
42212 buffer[i] = '\0';
42213 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42214 */
42215 for (i = 0; i < sc->stripes; i++)
42216 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42217 - atomic_inc(&(sc->stripe[i].error_count));
42218 - if (atomic_read(&(sc->stripe[i].error_count)) <
42219 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42220 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42221 DM_IO_ERROR_THRESHOLD)
42222 schedule_work(&sc->trigger_event);
42223 }
42224 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42225 index f221812..aca962b 100644
42226 --- a/drivers/md/dm-table.c
42227 +++ b/drivers/md/dm-table.c
42228 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42229 if (!dev_size)
42230 return 0;
42231
42232 - if ((start >= dev_size) || (start + len > dev_size)) {
42233 + if ((start >= dev_size) || (len > dev_size - start)) {
42234 DMWARN("%s: %s too small for target: "
42235 "start=%llu, len=%llu, dev_size=%llu",
42236 dm_device_name(ti->table->md), bdevname(bdev, b),
42237 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42238 index 60bce43..9b997d0 100644
42239 --- a/drivers/md/dm-thin-metadata.c
42240 +++ b/drivers/md/dm-thin-metadata.c
42241 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42242 {
42243 pmd->info.tm = pmd->tm;
42244 pmd->info.levels = 2;
42245 - pmd->info.value_type.context = pmd->data_sm;
42246 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42247 pmd->info.value_type.size = sizeof(__le64);
42248 pmd->info.value_type.inc = data_block_inc;
42249 pmd->info.value_type.dec = data_block_dec;
42250 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42251
42252 pmd->bl_info.tm = pmd->tm;
42253 pmd->bl_info.levels = 1;
42254 - pmd->bl_info.value_type.context = pmd->data_sm;
42255 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42256 pmd->bl_info.value_type.size = sizeof(__le64);
42257 pmd->bl_info.value_type.inc = data_block_inc;
42258 pmd->bl_info.value_type.dec = data_block_dec;
42259 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42260 index 995e1fc..2468cec 100644
42261 --- a/drivers/md/dm.c
42262 +++ b/drivers/md/dm.c
42263 @@ -178,9 +178,9 @@ struct mapped_device {
42264 /*
42265 * Event handling.
42266 */
42267 - atomic_t event_nr;
42268 + atomic_unchecked_t event_nr;
42269 wait_queue_head_t eventq;
42270 - atomic_t uevent_seq;
42271 + atomic_unchecked_t uevent_seq;
42272 struct list_head uevent_list;
42273 spinlock_t uevent_lock; /* Protect access to uevent_list */
42274
42275 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42276 spin_lock_init(&md->deferred_lock);
42277 atomic_set(&md->holders, 1);
42278 atomic_set(&md->open_count, 0);
42279 - atomic_set(&md->event_nr, 0);
42280 - atomic_set(&md->uevent_seq, 0);
42281 + atomic_set_unchecked(&md->event_nr, 0);
42282 + atomic_set_unchecked(&md->uevent_seq, 0);
42283 INIT_LIST_HEAD(&md->uevent_list);
42284 spin_lock_init(&md->uevent_lock);
42285
42286 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42287
42288 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42289
42290 - atomic_inc(&md->event_nr);
42291 + atomic_inc_unchecked(&md->event_nr);
42292 wake_up(&md->eventq);
42293 }
42294
42295 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42296
42297 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42298 {
42299 - return atomic_add_return(1, &md->uevent_seq);
42300 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42301 }
42302
42303 uint32_t dm_get_event_nr(struct mapped_device *md)
42304 {
42305 - return atomic_read(&md->event_nr);
42306 + return atomic_read_unchecked(&md->event_nr);
42307 }
42308
42309 int dm_wait_event(struct mapped_device *md, int event_nr)
42310 {
42311 return wait_event_interruptible(md->eventq,
42312 - (event_nr != atomic_read(&md->event_nr)));
42313 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42314 }
42315
42316 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42317 diff --git a/drivers/md/md.c b/drivers/md/md.c
42318 index 9f13e13..411a5b8 100644
42319 --- a/drivers/md/md.c
42320 +++ b/drivers/md/md.c
42321 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42322 * start build, activate spare
42323 */
42324 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42325 -static atomic_t md_event_count;
42326 +static atomic_unchecked_t md_event_count;
42327 void md_new_event(struct mddev *mddev)
42328 {
42329 - atomic_inc(&md_event_count);
42330 + atomic_inc_unchecked(&md_event_count);
42331 wake_up(&md_event_waiters);
42332 }
42333 EXPORT_SYMBOL_GPL(md_new_event);
42334 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42335 */
42336 static void md_new_event_inintr(struct mddev *mddev)
42337 {
42338 - atomic_inc(&md_event_count);
42339 + atomic_inc_unchecked(&md_event_count);
42340 wake_up(&md_event_waiters);
42341 }
42342
42343 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42344 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42345 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42346 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42347 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42348 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42349
42350 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42351 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42352 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42353 else
42354 sb->resync_offset = cpu_to_le64(0);
42355
42356 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42357 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42358
42359 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42360 sb->size = cpu_to_le64(mddev->dev_sectors);
42361 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42362 static ssize_t
42363 errors_show(struct md_rdev *rdev, char *page)
42364 {
42365 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42366 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42367 }
42368
42369 static ssize_t
42370 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42371 char *e;
42372 unsigned long n = simple_strtoul(buf, &e, 10);
42373 if (*buf && (*e == 0 || *e == '\n')) {
42374 - atomic_set(&rdev->corrected_errors, n);
42375 + atomic_set_unchecked(&rdev->corrected_errors, n);
42376 return len;
42377 }
42378 return -EINVAL;
42379 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42380 rdev->sb_loaded = 0;
42381 rdev->bb_page = NULL;
42382 atomic_set(&rdev->nr_pending, 0);
42383 - atomic_set(&rdev->read_errors, 0);
42384 - atomic_set(&rdev->corrected_errors, 0);
42385 + atomic_set_unchecked(&rdev->read_errors, 0);
42386 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42387
42388 INIT_LIST_HEAD(&rdev->same_set);
42389 init_waitqueue_head(&rdev->blocked_wait);
42390 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42391
42392 spin_unlock(&pers_lock);
42393 seq_printf(seq, "\n");
42394 - seq->poll_event = atomic_read(&md_event_count);
42395 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42396 return 0;
42397 }
42398 if (v == (void*)2) {
42399 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42400 return error;
42401
42402 seq = file->private_data;
42403 - seq->poll_event = atomic_read(&md_event_count);
42404 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42405 return error;
42406 }
42407
42408 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42409 /* always allow read */
42410 mask = POLLIN | POLLRDNORM;
42411
42412 - if (seq->poll_event != atomic_read(&md_event_count))
42413 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42414 mask |= POLLERR | POLLPRI;
42415 return mask;
42416 }
42417 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42418 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42419 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42420 (int)part_stat_read(&disk->part0, sectors[1]) -
42421 - atomic_read(&disk->sync_io);
42422 + atomic_read_unchecked(&disk->sync_io);
42423 /* sync IO will cause sync_io to increase before the disk_stats
42424 * as sync_io is counted when a request starts, and
42425 * disk_stats is counted when it completes.
42426 diff --git a/drivers/md/md.h b/drivers/md/md.h
42427 index 20f02c0..fd8c821 100644
42428 --- a/drivers/md/md.h
42429 +++ b/drivers/md/md.h
42430 @@ -94,13 +94,13 @@ struct md_rdev {
42431 * only maintained for arrays that
42432 * support hot removal
42433 */
42434 - atomic_t read_errors; /* number of consecutive read errors that
42435 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42436 * we have tried to ignore.
42437 */
42438 struct timespec last_read_error; /* monotonic time since our
42439 * last read error
42440 */
42441 - atomic_t corrected_errors; /* number of corrected read errors,
42442 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42443 * for reporting to userspace and storing
42444 * in superblock.
42445 */
42446 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42447
42448 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42449 {
42450 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42451 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42452 }
42453
42454 struct md_personality
42455 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42456 index 3e6d115..ffecdeb 100644
42457 --- a/drivers/md/persistent-data/dm-space-map.h
42458 +++ b/drivers/md/persistent-data/dm-space-map.h
42459 @@ -71,6 +71,7 @@ struct dm_space_map {
42460 dm_sm_threshold_fn fn,
42461 void *context);
42462 };
42463 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42464
42465 /*----------------------------------------------------------------*/
42466
42467 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42468 index d60412c..8d4c982 100644
42469 --- a/drivers/md/raid1.c
42470 +++ b/drivers/md/raid1.c
42471 @@ -1823,7 +1823,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42472 if (r1_sync_page_io(rdev, sect, s,
42473 bio->bi_io_vec[idx].bv_page,
42474 READ) != 0)
42475 - atomic_add(s, &rdev->corrected_errors);
42476 + atomic_add_unchecked(s, &rdev->corrected_errors);
42477 }
42478 sectors -= s;
42479 sect += s;
42480 @@ -2050,7 +2050,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42481 test_bit(In_sync, &rdev->flags)) {
42482 if (r1_sync_page_io(rdev, sect, s,
42483 conf->tmppage, READ)) {
42484 - atomic_add(s, &rdev->corrected_errors);
42485 + atomic_add_unchecked(s, &rdev->corrected_errors);
42486 printk(KERN_INFO
42487 "md/raid1:%s: read error corrected "
42488 "(%d sectors at %llu on %s)\n",
42489 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42490 index df7b0a0..a257495 100644
42491 --- a/drivers/md/raid10.c
42492 +++ b/drivers/md/raid10.c
42493 @@ -1962,7 +1962,7 @@ static void end_sync_read(struct bio *bio, int error)
42494 /* The write handler will notice the lack of
42495 * R10BIO_Uptodate and record any errors etc
42496 */
42497 - atomic_add(r10_bio->sectors,
42498 + atomic_add_unchecked(r10_bio->sectors,
42499 &conf->mirrors[d].rdev->corrected_errors);
42500
42501 /* for reconstruct, we always reschedule after a read.
42502 @@ -2320,7 +2320,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42503 {
42504 struct timespec cur_time_mon;
42505 unsigned long hours_since_last;
42506 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42507 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42508
42509 ktime_get_ts(&cur_time_mon);
42510
42511 @@ -2342,9 +2342,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42512 * overflowing the shift of read_errors by hours_since_last.
42513 */
42514 if (hours_since_last >= 8 * sizeof(read_errors))
42515 - atomic_set(&rdev->read_errors, 0);
42516 + atomic_set_unchecked(&rdev->read_errors, 0);
42517 else
42518 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42519 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42520 }
42521
42522 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42523 @@ -2398,8 +2398,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42524 return;
42525
42526 check_decay_read_errors(mddev, rdev);
42527 - atomic_inc(&rdev->read_errors);
42528 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42529 + atomic_inc_unchecked(&rdev->read_errors);
42530 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42531 char b[BDEVNAME_SIZE];
42532 bdevname(rdev->bdev, b);
42533
42534 @@ -2407,7 +2407,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42535 "md/raid10:%s: %s: Raid device exceeded "
42536 "read_error threshold [cur %d:max %d]\n",
42537 mdname(mddev), b,
42538 - atomic_read(&rdev->read_errors), max_read_errors);
42539 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42540 printk(KERN_NOTICE
42541 "md/raid10:%s: %s: Failing raid device\n",
42542 mdname(mddev), b);
42543 @@ -2562,7 +2562,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42544 sect +
42545 choose_data_offset(r10_bio, rdev)),
42546 bdevname(rdev->bdev, b));
42547 - atomic_add(s, &rdev->corrected_errors);
42548 + atomic_add_unchecked(s, &rdev->corrected_errors);
42549 }
42550
42551 rdev_dec_pending(rdev, mddev);
42552 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42553 index 78ea443..7d57513 100644
42554 --- a/drivers/md/raid5.c
42555 +++ b/drivers/md/raid5.c
42556 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42557 mdname(conf->mddev), STRIPE_SECTORS,
42558 (unsigned long long)s,
42559 bdevname(rdev->bdev, b));
42560 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42561 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42562 clear_bit(R5_ReadError, &sh->dev[i].flags);
42563 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42564 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42565 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42566
42567 - if (atomic_read(&rdev->read_errors))
42568 - atomic_set(&rdev->read_errors, 0);
42569 + if (atomic_read_unchecked(&rdev->read_errors))
42570 + atomic_set_unchecked(&rdev->read_errors, 0);
42571 } else {
42572 const char *bdn = bdevname(rdev->bdev, b);
42573 int retry = 0;
42574 int set_bad = 0;
42575
42576 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42577 - atomic_inc(&rdev->read_errors);
42578 + atomic_inc_unchecked(&rdev->read_errors);
42579 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42580 printk_ratelimited(
42581 KERN_WARNING
42582 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42583 mdname(conf->mddev),
42584 (unsigned long long)s,
42585 bdn);
42586 - } else if (atomic_read(&rdev->read_errors)
42587 + } else if (atomic_read_unchecked(&rdev->read_errors)
42588 > conf->max_nr_stripes)
42589 printk(KERN_WARNING
42590 "md/raid:%s: Too many read errors, failing device %s.\n",
42591 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42592 index 401ef64..836e563 100644
42593 --- a/drivers/media/dvb-core/dvbdev.c
42594 +++ b/drivers/media/dvb-core/dvbdev.c
42595 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42596 const struct dvb_device *template, void *priv, int type)
42597 {
42598 struct dvb_device *dvbdev;
42599 - struct file_operations *dvbdevfops;
42600 + file_operations_no_const *dvbdevfops;
42601 struct device *clsdev;
42602 int minor;
42603 int id;
42604 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42605 index 9b6c3bb..baeb5c7 100644
42606 --- a/drivers/media/dvb-frontends/dib3000.h
42607 +++ b/drivers/media/dvb-frontends/dib3000.h
42608 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42609 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42610 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42611 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42612 -};
42613 +} __no_const;
42614
42615 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42616 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42617 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42618 index ecf21d9..b992428d 100644
42619 --- a/drivers/media/pci/cx88/cx88-video.c
42620 +++ b/drivers/media/pci/cx88/cx88-video.c
42621 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42622
42623 /* ------------------------------------------------------------------ */
42624
42625 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42626 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42627 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42628 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42629 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42630 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42631
42632 module_param_array(video_nr, int, NULL, 0444);
42633 module_param_array(vbi_nr, int, NULL, 0444);
42634 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42635 index c08ae3e..eb59af1 100644
42636 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42637 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42638 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42639 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42640
42641 /* ivtv instance counter */
42642 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42643 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42644
42645 /* Parameter declarations */
42646 static int cardtype[IVTV_MAX_CARDS];
42647 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42648 index dfd0a21..6bbb465 100644
42649 --- a/drivers/media/platform/omap/omap_vout.c
42650 +++ b/drivers/media/platform/omap/omap_vout.c
42651 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42652 OMAP_VIDEO2,
42653 };
42654
42655 -static struct videobuf_queue_ops video_vbq_ops;
42656 /* Variables configurable through module params*/
42657 static u32 video1_numbuffers = 3;
42658 static u32 video2_numbuffers = 3;
42659 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42660 {
42661 struct videobuf_queue *q;
42662 struct omap_vout_device *vout = NULL;
42663 + static struct videobuf_queue_ops video_vbq_ops = {
42664 + .buf_setup = omap_vout_buffer_setup,
42665 + .buf_prepare = omap_vout_buffer_prepare,
42666 + .buf_release = omap_vout_buffer_release,
42667 + .buf_queue = omap_vout_buffer_queue,
42668 + };
42669
42670 vout = video_drvdata(file);
42671 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42672 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42673 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42674
42675 q = &vout->vbq;
42676 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42677 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42678 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42679 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42680 spin_lock_init(&vout->vbq_lock);
42681
42682 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42683 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42684 index 04e6490..2df65bf 100644
42685 --- a/drivers/media/platform/s5p-tv/mixer.h
42686 +++ b/drivers/media/platform/s5p-tv/mixer.h
42687 @@ -156,7 +156,7 @@ struct mxr_layer {
42688 /** layer index (unique identifier) */
42689 int idx;
42690 /** callbacks for layer methods */
42691 - struct mxr_layer_ops ops;
42692 + struct mxr_layer_ops *ops;
42693 /** format array */
42694 const struct mxr_format **fmt_array;
42695 /** size of format array */
42696 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42697 index b93a21f..2535195 100644
42698 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42699 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42700 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42701 {
42702 struct mxr_layer *layer;
42703 int ret;
42704 - struct mxr_layer_ops ops = {
42705 + static struct mxr_layer_ops ops = {
42706 .release = mxr_graph_layer_release,
42707 .buffer_set = mxr_graph_buffer_set,
42708 .stream_set = mxr_graph_stream_set,
42709 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42710 index b713403..53cb5ad 100644
42711 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42712 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42713 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42714 layer->update_buf = next;
42715 }
42716
42717 - layer->ops.buffer_set(layer, layer->update_buf);
42718 + layer->ops->buffer_set(layer, layer->update_buf);
42719
42720 if (done && done != layer->shadow_buf)
42721 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42722 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42723 index 641b1f0..49cff30 100644
42724 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42725 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42726 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42727 layer->geo.src.height = layer->geo.src.full_height;
42728
42729 mxr_geometry_dump(mdev, &layer->geo);
42730 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42731 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42732 mxr_geometry_dump(mdev, &layer->geo);
42733 }
42734
42735 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42736 layer->geo.dst.full_width = mbus_fmt.width;
42737 layer->geo.dst.full_height = mbus_fmt.height;
42738 layer->geo.dst.field = mbus_fmt.field;
42739 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42740 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42741
42742 mxr_geometry_dump(mdev, &layer->geo);
42743 }
42744 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42745 /* set source size to highest accepted value */
42746 geo->src.full_width = max(geo->dst.full_width, pix->width);
42747 geo->src.full_height = max(geo->dst.full_height, pix->height);
42748 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42749 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42750 mxr_geometry_dump(mdev, &layer->geo);
42751 /* set cropping to total visible screen */
42752 geo->src.width = pix->width;
42753 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42754 geo->src.x_offset = 0;
42755 geo->src.y_offset = 0;
42756 /* assure consistency of geometry */
42757 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42758 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42759 mxr_geometry_dump(mdev, &layer->geo);
42760 /* set full size to lowest possible value */
42761 geo->src.full_width = 0;
42762 geo->src.full_height = 0;
42763 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42764 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42765 mxr_geometry_dump(mdev, &layer->geo);
42766
42767 /* returning results */
42768 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42769 target->width = s->r.width;
42770 target->height = s->r.height;
42771
42772 - layer->ops.fix_geometry(layer, stage, s->flags);
42773 + layer->ops->fix_geometry(layer, stage, s->flags);
42774
42775 /* retrieve update selection rectangle */
42776 res.left = target->x_offset;
42777 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42778 mxr_output_get(mdev);
42779
42780 mxr_layer_update_output(layer);
42781 - layer->ops.format_set(layer);
42782 + layer->ops->format_set(layer);
42783 /* enabling layer in hardware */
42784 spin_lock_irqsave(&layer->enq_slock, flags);
42785 layer->state = MXR_LAYER_STREAMING;
42786 spin_unlock_irqrestore(&layer->enq_slock, flags);
42787
42788 - layer->ops.stream_set(layer, MXR_ENABLE);
42789 + layer->ops->stream_set(layer, MXR_ENABLE);
42790 mxr_streamer_get(mdev);
42791
42792 return 0;
42793 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42794 spin_unlock_irqrestore(&layer->enq_slock, flags);
42795
42796 /* disabling layer in hardware */
42797 - layer->ops.stream_set(layer, MXR_DISABLE);
42798 + layer->ops->stream_set(layer, MXR_DISABLE);
42799 /* remove one streamer */
42800 mxr_streamer_put(mdev);
42801 /* allow changes in output configuration */
42802 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42803
42804 void mxr_layer_release(struct mxr_layer *layer)
42805 {
42806 - if (layer->ops.release)
42807 - layer->ops.release(layer);
42808 + if (layer->ops->release)
42809 + layer->ops->release(layer);
42810 }
42811
42812 void mxr_base_layer_release(struct mxr_layer *layer)
42813 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42814
42815 layer->mdev = mdev;
42816 layer->idx = idx;
42817 - layer->ops = *ops;
42818 + layer->ops = ops;
42819
42820 spin_lock_init(&layer->enq_slock);
42821 INIT_LIST_HEAD(&layer->enq_list);
42822 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42823 index 3d13a63..da31bf1 100644
42824 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42825 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42826 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42827 {
42828 struct mxr_layer *layer;
42829 int ret;
42830 - struct mxr_layer_ops ops = {
42831 + static struct mxr_layer_ops ops = {
42832 .release = mxr_vp_layer_release,
42833 .buffer_set = mxr_vp_buffer_set,
42834 .stream_set = mxr_vp_stream_set,
42835 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42836 index 545c04c..a14bded 100644
42837 --- a/drivers/media/radio/radio-cadet.c
42838 +++ b/drivers/media/radio/radio-cadet.c
42839 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42840 unsigned char readbuf[RDS_BUFFER];
42841 int i = 0;
42842
42843 + if (count > RDS_BUFFER)
42844 + return -EFAULT;
42845 mutex_lock(&dev->lock);
42846 if (dev->rdsstat == 0)
42847 cadet_start_rds(dev);
42848 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42849 while (i < count && dev->rdsin != dev->rdsout)
42850 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42851
42852 - if (i && copy_to_user(data, readbuf, i))
42853 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42854 i = -EFAULT;
42855 unlock:
42856 mutex_unlock(&dev->lock);
42857 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42858 index bd4d3a7..ffc0b9d 100644
42859 --- a/drivers/media/radio/radio-maxiradio.c
42860 +++ b/drivers/media/radio/radio-maxiradio.c
42861 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42862 /* TEA5757 pin mappings */
42863 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42864
42865 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42866 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42867
42868 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42869 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42870 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42871 index 8fa18ab..caee70f 100644
42872 --- a/drivers/media/radio/radio-shark.c
42873 +++ b/drivers/media/radio/radio-shark.c
42874 @@ -79,7 +79,7 @@ struct shark_device {
42875 u32 last_val;
42876 };
42877
42878 -static atomic_t shark_instance = ATOMIC_INIT(0);
42879 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42880
42881 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42882 {
42883 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42884 index 9fb6697..f167415 100644
42885 --- a/drivers/media/radio/radio-shark2.c
42886 +++ b/drivers/media/radio/radio-shark2.c
42887 @@ -74,7 +74,7 @@ struct shark_device {
42888 u8 *transfer_buffer;
42889 };
42890
42891 -static atomic_t shark_instance = ATOMIC_INIT(0);
42892 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42893
42894 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42895 {
42896 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42897 index 9c9084c..a9e8dfb 100644
42898 --- a/drivers/media/radio/radio-si476x.c
42899 +++ b/drivers/media/radio/radio-si476x.c
42900 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42901 struct si476x_radio *radio;
42902 struct v4l2_ctrl *ctrl;
42903
42904 - static atomic_t instance = ATOMIC_INIT(0);
42905 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42906
42907 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42908 if (!radio)
42909 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42910 index 1cf382a..c22998c 100644
42911 --- a/drivers/media/rc/rc-main.c
42912 +++ b/drivers/media/rc/rc-main.c
42913 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42914 int rc_register_device(struct rc_dev *dev)
42915 {
42916 static bool raw_init = false; /* raw decoders loaded? */
42917 - static atomic_t devno = ATOMIC_INIT(0);
42918 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42919 struct rc_map *rc_map;
42920 const char *path;
42921 int rc;
42922 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42923 */
42924 mutex_lock(&dev->lock);
42925
42926 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42927 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42928 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42929 dev_set_drvdata(&dev->dev, dev);
42930 rc = device_add(&dev->dev);
42931 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42932 index 3940bb0..fb3952a 100644
42933 --- a/drivers/media/usb/dvb-usb/cxusb.c
42934 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42935 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42936
42937 struct dib0700_adapter_state {
42938 int (*set_param_save) (struct dvb_frontend *);
42939 -};
42940 +} __no_const;
42941
42942 static int dib7070_set_param_override(struct dvb_frontend *fe)
42943 {
42944 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42945 index 6e237b6..dc25556 100644
42946 --- a/drivers/media/usb/dvb-usb/dw2102.c
42947 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42948 @@ -118,7 +118,7 @@ struct su3000_state {
42949
42950 struct s6x0_state {
42951 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42952 -};
42953 +} __no_const;
42954
42955 /* debug */
42956 static int dvb_usb_dw2102_debug;
42957 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42958 index 8f7a6a4..59502dd 100644
42959 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42960 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42961 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42962 __u32 reserved;
42963 };
42964
42965 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42966 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42967 enum v4l2_memory memory)
42968 {
42969 void __user *up_pln;
42970 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42971 return 0;
42972 }
42973
42974 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42975 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42976 enum v4l2_memory memory)
42977 {
42978 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42979 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42980 put_user(kp->start_block, &up->start_block) ||
42981 put_user(kp->blocks, &up->blocks) ||
42982 put_user(tmp, &up->edid) ||
42983 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42984 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42985 return -EFAULT;
42986 return 0;
42987 }
42988 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42989 index 02d1b63..5fd6b16 100644
42990 --- a/drivers/media/v4l2-core/v4l2-device.c
42991 +++ b/drivers/media/v4l2-core/v4l2-device.c
42992 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42993 EXPORT_SYMBOL_GPL(v4l2_device_put);
42994
42995 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42996 - atomic_t *instance)
42997 + atomic_unchecked_t *instance)
42998 {
42999 - int num = atomic_inc_return(instance) - 1;
43000 + int num = atomic_inc_return_unchecked(instance) - 1;
43001 int len = strlen(basename);
43002
43003 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43004 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43005 index 68e6b5e..d8b923e 100644
43006 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43007 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43008 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43009 struct file *file, void *fh, void *p);
43010 } u;
43011 void (*debug)(const void *arg, bool write_only);
43012 -};
43013 +} __do_const;
43014 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43015
43016 /* This control needs a priority check */
43017 #define INFO_FL_PRIO (1 << 0)
43018 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43019 struct video_device *vfd = video_devdata(file);
43020 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43021 bool write_only = false;
43022 - struct v4l2_ioctl_info default_info;
43023 + v4l2_ioctl_info_no_const default_info;
43024 const struct v4l2_ioctl_info *info;
43025 void *fh = file->private_data;
43026 struct v4l2_fh *vfh = NULL;
43027 @@ -2194,7 +2195,7 @@ done:
43028 }
43029
43030 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43031 - void * __user *user_ptr, void ***kernel_ptr)
43032 + void __user **user_ptr, void ***kernel_ptr)
43033 {
43034 int ret = 0;
43035
43036 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43037 ret = -EINVAL;
43038 break;
43039 }
43040 - *user_ptr = (void __user *)buf->m.planes;
43041 + *user_ptr = (void __force_user *)buf->m.planes;
43042 *kernel_ptr = (void *)&buf->m.planes;
43043 *array_size = sizeof(struct v4l2_plane) * buf->length;
43044 ret = 1;
43045 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43046 ret = -EINVAL;
43047 break;
43048 }
43049 - *user_ptr = (void __user *)ctrls->controls;
43050 + *user_ptr = (void __force_user *)ctrls->controls;
43051 *kernel_ptr = (void *)&ctrls->controls;
43052 *array_size = sizeof(struct v4l2_ext_control)
43053 * ctrls->count;
43054 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43055 index 767ff4d..c69d259 100644
43056 --- a/drivers/message/fusion/mptbase.c
43057 +++ b/drivers/message/fusion/mptbase.c
43058 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43059 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43060 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43061
43062 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43063 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43064 +#else
43065 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43066 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43067 +#endif
43068 +
43069 /*
43070 * Rounding UP to nearest 4-kB boundary here...
43071 */
43072 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43073 ioc->facts.GlobalCredits);
43074
43075 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43076 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43077 + NULL, NULL);
43078 +#else
43079 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43080 +#endif
43081 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43082 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43083 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43084 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43085 index dd239bd..689c4f7 100644
43086 --- a/drivers/message/fusion/mptsas.c
43087 +++ b/drivers/message/fusion/mptsas.c
43088 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43089 return 0;
43090 }
43091
43092 +static inline void
43093 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43094 +{
43095 + if (phy_info->port_details) {
43096 + phy_info->port_details->rphy = rphy;
43097 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43098 + ioc->name, rphy));
43099 + }
43100 +
43101 + if (rphy) {
43102 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43103 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43104 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43105 + ioc->name, rphy, rphy->dev.release));
43106 + }
43107 +}
43108 +
43109 /* no mutex */
43110 static void
43111 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43112 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43113 return NULL;
43114 }
43115
43116 -static inline void
43117 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43118 -{
43119 - if (phy_info->port_details) {
43120 - phy_info->port_details->rphy = rphy;
43121 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43122 - ioc->name, rphy));
43123 - }
43124 -
43125 - if (rphy) {
43126 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43127 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43128 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43129 - ioc->name, rphy, rphy->dev.release));
43130 - }
43131 -}
43132 -
43133 static inline struct sas_port *
43134 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43135 {
43136 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43137 index 727819c..ad74694 100644
43138 --- a/drivers/message/fusion/mptscsih.c
43139 +++ b/drivers/message/fusion/mptscsih.c
43140 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43141
43142 h = shost_priv(SChost);
43143
43144 - if (h) {
43145 - if (h->info_kbuf == NULL)
43146 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43147 - return h->info_kbuf;
43148 - h->info_kbuf[0] = '\0';
43149 + if (!h)
43150 + return NULL;
43151
43152 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43153 - h->info_kbuf[size-1] = '\0';
43154 - }
43155 + if (h->info_kbuf == NULL)
43156 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43157 + return h->info_kbuf;
43158 + h->info_kbuf[0] = '\0';
43159 +
43160 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43161 + h->info_kbuf[size-1] = '\0';
43162
43163 return h->info_kbuf;
43164 }
43165 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43166 index b7d87cd..9890039 100644
43167 --- a/drivers/message/i2o/i2o_proc.c
43168 +++ b/drivers/message/i2o/i2o_proc.c
43169 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43170 "Array Controller Device"
43171 };
43172
43173 -static char *chtostr(char *tmp, u8 *chars, int n)
43174 -{
43175 - tmp[0] = 0;
43176 - return strncat(tmp, (char *)chars, n);
43177 -}
43178 -
43179 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43180 char *group)
43181 {
43182 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43183 } *result;
43184
43185 i2o_exec_execute_ddm_table ddm_table;
43186 - char tmp[28 + 1];
43187
43188 result = kmalloc(sizeof(*result), GFP_KERNEL);
43189 if (!result)
43190 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43191
43192 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43193 seq_printf(seq, "%-#8x", ddm_table.module_id);
43194 - seq_printf(seq, "%-29s",
43195 - chtostr(tmp, ddm_table.module_name_version, 28));
43196 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43197 seq_printf(seq, "%9d ", ddm_table.data_size);
43198 seq_printf(seq, "%8d", ddm_table.code_size);
43199
43200 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43201
43202 i2o_driver_result_table *result;
43203 i2o_driver_store_table *dst;
43204 - char tmp[28 + 1];
43205
43206 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43207 if (result == NULL)
43208 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43209
43210 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43211 seq_printf(seq, "%-#8x", dst->module_id);
43212 - seq_printf(seq, "%-29s",
43213 - chtostr(tmp, dst->module_name_version, 28));
43214 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43215 + seq_printf(seq, "%-.28s", dst->module_name_version);
43216 + seq_printf(seq, "%-.8s", dst->date);
43217 seq_printf(seq, "%8d ", dst->module_size);
43218 seq_printf(seq, "%8d ", dst->mpb_size);
43219 seq_printf(seq, "0x%04x", dst->module_flags);
43220 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43221 // == (allow) 512d bytes (max)
43222 static u16 *work16 = (u16 *) work32;
43223 int token;
43224 - char tmp[16 + 1];
43225
43226 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43227
43228 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43229 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43230 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43231 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43232 - seq_printf(seq, "Vendor info : %s\n",
43233 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43234 - seq_printf(seq, "Product info : %s\n",
43235 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43236 - seq_printf(seq, "Description : %s\n",
43237 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43238 - seq_printf(seq, "Product rev. : %s\n",
43239 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43240 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43241 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43242 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43243 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43244
43245 seq_printf(seq, "Serial number : ");
43246 print_serial_number(seq, (u8 *) (work32 + 16),
43247 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43248 u8 pad[256]; // allow up to 256 byte (max) serial number
43249 } result;
43250
43251 - char tmp[24 + 1];
43252 -
43253 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43254
43255 if (token < 0) {
43256 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43257 }
43258
43259 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43260 - seq_printf(seq, "Module name : %s\n",
43261 - chtostr(tmp, result.module_name, 24));
43262 - seq_printf(seq, "Module revision : %s\n",
43263 - chtostr(tmp, result.module_rev, 8));
43264 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43265 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43266
43267 seq_printf(seq, "Serial number : ");
43268 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43269 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43270 u8 instance_number[4];
43271 } result;
43272
43273 - char tmp[64 + 1];
43274 -
43275 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43276
43277 if (token < 0) {
43278 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43279 return 0;
43280 }
43281
43282 - seq_printf(seq, "Device name : %s\n",
43283 - chtostr(tmp, result.device_name, 64));
43284 - seq_printf(seq, "Service name : %s\n",
43285 - chtostr(tmp, result.service_name, 64));
43286 - seq_printf(seq, "Physical name : %s\n",
43287 - chtostr(tmp, result.physical_location, 64));
43288 - seq_printf(seq, "Instance number : %s\n",
43289 - chtostr(tmp, result.instance_number, 4));
43290 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43291 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43292 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43293 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43294
43295 return 0;
43296 }
43297 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43298 index a8c08f3..155fe3d 100644
43299 --- a/drivers/message/i2o/iop.c
43300 +++ b/drivers/message/i2o/iop.c
43301 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43302
43303 spin_lock_irqsave(&c->context_list_lock, flags);
43304
43305 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43306 - atomic_inc(&c->context_list_counter);
43307 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43308 + atomic_inc_unchecked(&c->context_list_counter);
43309
43310 - entry->context = atomic_read(&c->context_list_counter);
43311 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43312
43313 list_add(&entry->list, &c->context_list);
43314
43315 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43316
43317 #if BITS_PER_LONG == 64
43318 spin_lock_init(&c->context_list_lock);
43319 - atomic_set(&c->context_list_counter, 0);
43320 + atomic_set_unchecked(&c->context_list_counter, 0);
43321 INIT_LIST_HEAD(&c->context_list);
43322 #endif
43323
43324 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43325 index fcbb2e9..2635e11 100644
43326 --- a/drivers/mfd/janz-cmodio.c
43327 +++ b/drivers/mfd/janz-cmodio.c
43328 @@ -13,6 +13,7 @@
43329
43330 #include <linux/kernel.h>
43331 #include <linux/module.h>
43332 +#include <linux/slab.h>
43333 #include <linux/init.h>
43334 #include <linux/pci.h>
43335 #include <linux/interrupt.h>
43336 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43337 index 9aa6d1e..1631bfc 100644
43338 --- a/drivers/mfd/twl4030-irq.c
43339 +++ b/drivers/mfd/twl4030-irq.c
43340 @@ -35,6 +35,7 @@
43341 #include <linux/of.h>
43342 #include <linux/irqdomain.h>
43343 #include <linux/i2c/twl.h>
43344 +#include <asm/pgtable.h>
43345
43346 #include "twl-core.h"
43347
43348 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43349 * Install an irq handler for each of the SIH modules;
43350 * clone dummy irq_chip since PIH can't *do* anything
43351 */
43352 - twl4030_irq_chip = dummy_irq_chip;
43353 - twl4030_irq_chip.name = "twl4030";
43354 + pax_open_kernel();
43355 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43356 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43357
43358 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43359 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43360 + pax_close_kernel();
43361
43362 for (i = irq_base; i < irq_end; i++) {
43363 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43364 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43365 index 277a8db..0e0b754 100644
43366 --- a/drivers/mfd/twl6030-irq.c
43367 +++ b/drivers/mfd/twl6030-irq.c
43368 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43369 * install an irq handler for each of the modules;
43370 * clone dummy irq_chip since PIH can't *do* anything
43371 */
43372 - twl6030_irq_chip = dummy_irq_chip;
43373 - twl6030_irq_chip.name = "twl6030";
43374 - twl6030_irq_chip.irq_set_type = NULL;
43375 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43376 + pax_open_kernel();
43377 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43378 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43379 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43380 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43381 + pax_close_kernel();
43382
43383 for (i = irq_base; i < irq_end; i++) {
43384 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43385 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43386 index f32550a..e3e52a2 100644
43387 --- a/drivers/misc/c2port/core.c
43388 +++ b/drivers/misc/c2port/core.c
43389 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43390 mutex_init(&c2dev->mutex);
43391
43392 /* Create binary file */
43393 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43394 + pax_open_kernel();
43395 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43396 + pax_close_kernel();
43397 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43398 if (unlikely(ret))
43399 goto error_device_create_bin_file;
43400 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43401 index 36f5d52..32311c3 100644
43402 --- a/drivers/misc/kgdbts.c
43403 +++ b/drivers/misc/kgdbts.c
43404 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43405 char before[BREAK_INSTR_SIZE];
43406 char after[BREAK_INSTR_SIZE];
43407
43408 - probe_kernel_read(before, (char *)kgdbts_break_test,
43409 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43410 BREAK_INSTR_SIZE);
43411 init_simple_test();
43412 ts.tst = plant_and_detach_test;
43413 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43414 /* Activate test with initial breakpoint */
43415 if (!is_early)
43416 kgdb_breakpoint();
43417 - probe_kernel_read(after, (char *)kgdbts_break_test,
43418 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43419 BREAK_INSTR_SIZE);
43420 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43421 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43422 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43423 index 036effe..b3a6336 100644
43424 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43425 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43426 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43427 * the lid is closed. This leads to interrupts as soon as a little move
43428 * is done.
43429 */
43430 - atomic_inc(&lis3->count);
43431 + atomic_inc_unchecked(&lis3->count);
43432
43433 wake_up_interruptible(&lis3->misc_wait);
43434 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43435 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43436 if (lis3->pm_dev)
43437 pm_runtime_get_sync(lis3->pm_dev);
43438
43439 - atomic_set(&lis3->count, 0);
43440 + atomic_set_unchecked(&lis3->count, 0);
43441 return 0;
43442 }
43443
43444 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43445 add_wait_queue(&lis3->misc_wait, &wait);
43446 while (true) {
43447 set_current_state(TASK_INTERRUPTIBLE);
43448 - data = atomic_xchg(&lis3->count, 0);
43449 + data = atomic_xchg_unchecked(&lis3->count, 0);
43450 if (data)
43451 break;
43452
43453 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43454 struct lis3lv02d, miscdev);
43455
43456 poll_wait(file, &lis3->misc_wait, wait);
43457 - if (atomic_read(&lis3->count))
43458 + if (atomic_read_unchecked(&lis3->count))
43459 return POLLIN | POLLRDNORM;
43460 return 0;
43461 }
43462 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43463 index c439c82..1f20f57 100644
43464 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43465 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43466 @@ -297,7 +297,7 @@ struct lis3lv02d {
43467 struct input_polled_dev *idev; /* input device */
43468 struct platform_device *pdev; /* platform device */
43469 struct regulator_bulk_data regulators[2];
43470 - atomic_t count; /* interrupt count after last read */
43471 + atomic_unchecked_t count; /* interrupt count after last read */
43472 union axis_conversion ac; /* hw -> logical axis */
43473 int mapped_btns[3];
43474
43475 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43476 index 2f30bad..c4c13d0 100644
43477 --- a/drivers/misc/sgi-gru/gruhandles.c
43478 +++ b/drivers/misc/sgi-gru/gruhandles.c
43479 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43480 unsigned long nsec;
43481
43482 nsec = CLKS2NSEC(clks);
43483 - atomic_long_inc(&mcs_op_statistics[op].count);
43484 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43485 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43486 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43487 if (mcs_op_statistics[op].max < nsec)
43488 mcs_op_statistics[op].max = nsec;
43489 }
43490 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43491 index 4f76359..cdfcb2e 100644
43492 --- a/drivers/misc/sgi-gru/gruprocfs.c
43493 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43494 @@ -32,9 +32,9 @@
43495
43496 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43497
43498 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43499 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43500 {
43501 - unsigned long val = atomic_long_read(v);
43502 + unsigned long val = atomic_long_read_unchecked(v);
43503
43504 seq_printf(s, "%16lu %s\n", val, id);
43505 }
43506 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43507
43508 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43509 for (op = 0; op < mcsop_last; op++) {
43510 - count = atomic_long_read(&mcs_op_statistics[op].count);
43511 - total = atomic_long_read(&mcs_op_statistics[op].total);
43512 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43513 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43514 max = mcs_op_statistics[op].max;
43515 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43516 count ? total / count : 0, max);
43517 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43518 index 5c3ce24..4915ccb 100644
43519 --- a/drivers/misc/sgi-gru/grutables.h
43520 +++ b/drivers/misc/sgi-gru/grutables.h
43521 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43522 * GRU statistics.
43523 */
43524 struct gru_stats_s {
43525 - atomic_long_t vdata_alloc;
43526 - atomic_long_t vdata_free;
43527 - atomic_long_t gts_alloc;
43528 - atomic_long_t gts_free;
43529 - atomic_long_t gms_alloc;
43530 - atomic_long_t gms_free;
43531 - atomic_long_t gts_double_allocate;
43532 - atomic_long_t assign_context;
43533 - atomic_long_t assign_context_failed;
43534 - atomic_long_t free_context;
43535 - atomic_long_t load_user_context;
43536 - atomic_long_t load_kernel_context;
43537 - atomic_long_t lock_kernel_context;
43538 - atomic_long_t unlock_kernel_context;
43539 - atomic_long_t steal_user_context;
43540 - atomic_long_t steal_kernel_context;
43541 - atomic_long_t steal_context_failed;
43542 - atomic_long_t nopfn;
43543 - atomic_long_t asid_new;
43544 - atomic_long_t asid_next;
43545 - atomic_long_t asid_wrap;
43546 - atomic_long_t asid_reuse;
43547 - atomic_long_t intr;
43548 - atomic_long_t intr_cbr;
43549 - atomic_long_t intr_tfh;
43550 - atomic_long_t intr_spurious;
43551 - atomic_long_t intr_mm_lock_failed;
43552 - atomic_long_t call_os;
43553 - atomic_long_t call_os_wait_queue;
43554 - atomic_long_t user_flush_tlb;
43555 - atomic_long_t user_unload_context;
43556 - atomic_long_t user_exception;
43557 - atomic_long_t set_context_option;
43558 - atomic_long_t check_context_retarget_intr;
43559 - atomic_long_t check_context_unload;
43560 - atomic_long_t tlb_dropin;
43561 - atomic_long_t tlb_preload_page;
43562 - atomic_long_t tlb_dropin_fail_no_asid;
43563 - atomic_long_t tlb_dropin_fail_upm;
43564 - atomic_long_t tlb_dropin_fail_invalid;
43565 - atomic_long_t tlb_dropin_fail_range_active;
43566 - atomic_long_t tlb_dropin_fail_idle;
43567 - atomic_long_t tlb_dropin_fail_fmm;
43568 - atomic_long_t tlb_dropin_fail_no_exception;
43569 - atomic_long_t tfh_stale_on_fault;
43570 - atomic_long_t mmu_invalidate_range;
43571 - atomic_long_t mmu_invalidate_page;
43572 - atomic_long_t flush_tlb;
43573 - atomic_long_t flush_tlb_gru;
43574 - atomic_long_t flush_tlb_gru_tgh;
43575 - atomic_long_t flush_tlb_gru_zero_asid;
43576 + atomic_long_unchecked_t vdata_alloc;
43577 + atomic_long_unchecked_t vdata_free;
43578 + atomic_long_unchecked_t gts_alloc;
43579 + atomic_long_unchecked_t gts_free;
43580 + atomic_long_unchecked_t gms_alloc;
43581 + atomic_long_unchecked_t gms_free;
43582 + atomic_long_unchecked_t gts_double_allocate;
43583 + atomic_long_unchecked_t assign_context;
43584 + atomic_long_unchecked_t assign_context_failed;
43585 + atomic_long_unchecked_t free_context;
43586 + atomic_long_unchecked_t load_user_context;
43587 + atomic_long_unchecked_t load_kernel_context;
43588 + atomic_long_unchecked_t lock_kernel_context;
43589 + atomic_long_unchecked_t unlock_kernel_context;
43590 + atomic_long_unchecked_t steal_user_context;
43591 + atomic_long_unchecked_t steal_kernel_context;
43592 + atomic_long_unchecked_t steal_context_failed;
43593 + atomic_long_unchecked_t nopfn;
43594 + atomic_long_unchecked_t asid_new;
43595 + atomic_long_unchecked_t asid_next;
43596 + atomic_long_unchecked_t asid_wrap;
43597 + atomic_long_unchecked_t asid_reuse;
43598 + atomic_long_unchecked_t intr;
43599 + atomic_long_unchecked_t intr_cbr;
43600 + atomic_long_unchecked_t intr_tfh;
43601 + atomic_long_unchecked_t intr_spurious;
43602 + atomic_long_unchecked_t intr_mm_lock_failed;
43603 + atomic_long_unchecked_t call_os;
43604 + atomic_long_unchecked_t call_os_wait_queue;
43605 + atomic_long_unchecked_t user_flush_tlb;
43606 + atomic_long_unchecked_t user_unload_context;
43607 + atomic_long_unchecked_t user_exception;
43608 + atomic_long_unchecked_t set_context_option;
43609 + atomic_long_unchecked_t check_context_retarget_intr;
43610 + atomic_long_unchecked_t check_context_unload;
43611 + atomic_long_unchecked_t tlb_dropin;
43612 + atomic_long_unchecked_t tlb_preload_page;
43613 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43614 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43615 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43616 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43617 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43618 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43619 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43620 + atomic_long_unchecked_t tfh_stale_on_fault;
43621 + atomic_long_unchecked_t mmu_invalidate_range;
43622 + atomic_long_unchecked_t mmu_invalidate_page;
43623 + atomic_long_unchecked_t flush_tlb;
43624 + atomic_long_unchecked_t flush_tlb_gru;
43625 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43626 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43627
43628 - atomic_long_t copy_gpa;
43629 - atomic_long_t read_gpa;
43630 + atomic_long_unchecked_t copy_gpa;
43631 + atomic_long_unchecked_t read_gpa;
43632
43633 - atomic_long_t mesq_receive;
43634 - atomic_long_t mesq_receive_none;
43635 - atomic_long_t mesq_send;
43636 - atomic_long_t mesq_send_failed;
43637 - atomic_long_t mesq_noop;
43638 - atomic_long_t mesq_send_unexpected_error;
43639 - atomic_long_t mesq_send_lb_overflow;
43640 - atomic_long_t mesq_send_qlimit_reached;
43641 - atomic_long_t mesq_send_amo_nacked;
43642 - atomic_long_t mesq_send_put_nacked;
43643 - atomic_long_t mesq_page_overflow;
43644 - atomic_long_t mesq_qf_locked;
43645 - atomic_long_t mesq_qf_noop_not_full;
43646 - atomic_long_t mesq_qf_switch_head_failed;
43647 - atomic_long_t mesq_qf_unexpected_error;
43648 - atomic_long_t mesq_noop_unexpected_error;
43649 - atomic_long_t mesq_noop_lb_overflow;
43650 - atomic_long_t mesq_noop_qlimit_reached;
43651 - atomic_long_t mesq_noop_amo_nacked;
43652 - atomic_long_t mesq_noop_put_nacked;
43653 - atomic_long_t mesq_noop_page_overflow;
43654 + atomic_long_unchecked_t mesq_receive;
43655 + atomic_long_unchecked_t mesq_receive_none;
43656 + atomic_long_unchecked_t mesq_send;
43657 + atomic_long_unchecked_t mesq_send_failed;
43658 + atomic_long_unchecked_t mesq_noop;
43659 + atomic_long_unchecked_t mesq_send_unexpected_error;
43660 + atomic_long_unchecked_t mesq_send_lb_overflow;
43661 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43662 + atomic_long_unchecked_t mesq_send_amo_nacked;
43663 + atomic_long_unchecked_t mesq_send_put_nacked;
43664 + atomic_long_unchecked_t mesq_page_overflow;
43665 + atomic_long_unchecked_t mesq_qf_locked;
43666 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43667 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43668 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43669 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43670 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43671 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43672 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43673 + atomic_long_unchecked_t mesq_noop_put_nacked;
43674 + atomic_long_unchecked_t mesq_noop_page_overflow;
43675
43676 };
43677
43678 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43679 tghop_invalidate, mcsop_last};
43680
43681 struct mcs_op_statistic {
43682 - atomic_long_t count;
43683 - atomic_long_t total;
43684 + atomic_long_unchecked_t count;
43685 + atomic_long_unchecked_t total;
43686 unsigned long max;
43687 };
43688
43689 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43690
43691 #define STAT(id) do { \
43692 if (gru_options & OPT_STATS) \
43693 - atomic_long_inc(&gru_stats.id); \
43694 + atomic_long_inc_unchecked(&gru_stats.id); \
43695 } while (0)
43696
43697 #ifdef CONFIG_SGI_GRU_DEBUG
43698 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43699 index c862cd4..0d176fe 100644
43700 --- a/drivers/misc/sgi-xp/xp.h
43701 +++ b/drivers/misc/sgi-xp/xp.h
43702 @@ -288,7 +288,7 @@ struct xpc_interface {
43703 xpc_notify_func, void *);
43704 void (*received) (short, int, void *);
43705 enum xp_retval (*partid_to_nasids) (short, void *);
43706 -};
43707 +} __no_const;
43708
43709 extern struct xpc_interface xpc_interface;
43710
43711 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43712 index b94d5f7..7f494c5 100644
43713 --- a/drivers/misc/sgi-xp/xpc.h
43714 +++ b/drivers/misc/sgi-xp/xpc.h
43715 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43716 void (*received_payload) (struct xpc_channel *, void *);
43717 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43718 };
43719 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43720
43721 /* struct xpc_partition act_state values (for XPC HB) */
43722
43723 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43724 /* found in xpc_main.c */
43725 extern struct device *xpc_part;
43726 extern struct device *xpc_chan;
43727 -extern struct xpc_arch_operations xpc_arch_ops;
43728 +extern xpc_arch_operations_no_const xpc_arch_ops;
43729 extern int xpc_disengage_timelimit;
43730 extern int xpc_disengage_timedout;
43731 extern int xpc_activate_IRQ_rcvd;
43732 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43733 index 82dc574..8539ab2 100644
43734 --- a/drivers/misc/sgi-xp/xpc_main.c
43735 +++ b/drivers/misc/sgi-xp/xpc_main.c
43736 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43737 .notifier_call = xpc_system_die,
43738 };
43739
43740 -struct xpc_arch_operations xpc_arch_ops;
43741 +xpc_arch_operations_no_const xpc_arch_ops;
43742
43743 /*
43744 * Timer function to enforce the timelimit on the partition disengage.
43745 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43746
43747 if (((die_args->trapnr == X86_TRAP_MF) ||
43748 (die_args->trapnr == X86_TRAP_XF)) &&
43749 - !user_mode_vm(die_args->regs))
43750 + !user_mode(die_args->regs))
43751 xpc_die_deactivate();
43752
43753 break;
43754 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43755 index 837fc73..acb5862 100644
43756 --- a/drivers/mmc/core/mmc_ops.c
43757 +++ b/drivers/mmc/core/mmc_ops.c
43758 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43759 void *data_buf;
43760 int is_on_stack;
43761
43762 - is_on_stack = object_is_on_stack(buf);
43763 + is_on_stack = object_starts_on_stack(buf);
43764 if (is_on_stack) {
43765 /*
43766 * dma onto stack is unsafe/nonportable, but callers to this
43767 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43768 index 81b2994..dce857e 100644
43769 --- a/drivers/mmc/host/dw_mmc.h
43770 +++ b/drivers/mmc/host/dw_mmc.h
43771 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43772 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43773 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43774 int (*parse_dt)(struct dw_mci *host);
43775 -};
43776 +} __do_const;
43777 #endif /* _DW_MMC_H_ */
43778 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43779 index c3785ed..1984c44 100644
43780 --- a/drivers/mmc/host/mmci.c
43781 +++ b/drivers/mmc/host/mmci.c
43782 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43783 }
43784
43785 if (variant->busy_detect) {
43786 - mmci_ops.card_busy = mmci_card_busy;
43787 + pax_open_kernel();
43788 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43789 + pax_close_kernel();
43790 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43791 }
43792
43793 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43794 index 926aaf6..8e153e2 100644
43795 --- a/drivers/mmc/host/sdhci-s3c.c
43796 +++ b/drivers/mmc/host/sdhci-s3c.c
43797 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43798 * we can use overriding functions instead of default.
43799 */
43800 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43801 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43802 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43803 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43804 + pax_open_kernel();
43805 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43806 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43807 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43808 + pax_close_kernel();
43809 }
43810
43811 /* It supports additional host capabilities if needed */
43812 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43813 index 0c8bb6b..6f35deb 100644
43814 --- a/drivers/mtd/nand/denali.c
43815 +++ b/drivers/mtd/nand/denali.c
43816 @@ -24,6 +24,7 @@
43817 #include <linux/slab.h>
43818 #include <linux/mtd/mtd.h>
43819 #include <linux/module.h>
43820 +#include <linux/slab.h>
43821
43822 #include "denali.h"
43823
43824 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43825 index 51b9d6a..52af9a7 100644
43826 --- a/drivers/mtd/nftlmount.c
43827 +++ b/drivers/mtd/nftlmount.c
43828 @@ -24,6 +24,7 @@
43829 #include <asm/errno.h>
43830 #include <linux/delay.h>
43831 #include <linux/slab.h>
43832 +#include <linux/sched.h>
43833 #include <linux/mtd/mtd.h>
43834 #include <linux/mtd/nand.h>
43835 #include <linux/mtd/nftl.h>
43836 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43837 index f9d5615..99dd95f 100644
43838 --- a/drivers/mtd/sm_ftl.c
43839 +++ b/drivers/mtd/sm_ftl.c
43840 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43841 #define SM_CIS_VENDOR_OFFSET 0x59
43842 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43843 {
43844 - struct attribute_group *attr_group;
43845 + attribute_group_no_const *attr_group;
43846 struct attribute **attributes;
43847 struct sm_sysfs_attribute *vendor_attribute;
43848
43849 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43850 index 5e31046..82f8ddc 100644
43851 --- a/drivers/net/bonding/bond_main.c
43852 +++ b/drivers/net/bonding/bond_main.c
43853 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43854 return tx_queues;
43855 }
43856
43857 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43858 +static struct rtnl_link_ops bond_link_ops = {
43859 .kind = "bond",
43860 .priv_size = sizeof(struct bonding),
43861 .setup = bond_setup,
43862 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43863
43864 bond_destroy_debugfs();
43865
43866 - rtnl_link_unregister(&bond_link_ops);
43867 unregister_pernet_subsys(&bond_net_ops);
43868 + rtnl_link_unregister(&bond_link_ops);
43869
43870 #ifdef CONFIG_NET_POLL_CONTROLLER
43871 /*
43872 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43873 index e1d2643..7f4133b 100644
43874 --- a/drivers/net/ethernet/8390/ax88796.c
43875 +++ b/drivers/net/ethernet/8390/ax88796.c
43876 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43877 if (ax->plat->reg_offsets)
43878 ei_local->reg_offset = ax->plat->reg_offsets;
43879 else {
43880 + resource_size_t _mem_size = mem_size;
43881 + do_div(_mem_size, 0x18);
43882 ei_local->reg_offset = ax->reg_offsets;
43883 for (ret = 0; ret < 0x18; ret++)
43884 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43885 + ax->reg_offsets[ret] = _mem_size * ret;
43886 }
43887
43888 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43889 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43890 index c07a6d0..ca88c45 100644
43891 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43892 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43893 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43894 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43895 {
43896 /* RX_MODE controlling object */
43897 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43898 + bnx2x_init_rx_mode_obj(bp);
43899
43900 /* multicast configuration controlling object */
43901 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43902 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43903 index 8f03c98..dd0ef10 100644
43904 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43905 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43906 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43907 return rc;
43908 }
43909
43910 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43911 - struct bnx2x_rx_mode_obj *o)
43912 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43913 {
43914 if (CHIP_IS_E1x(bp)) {
43915 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43916 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43917 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43918 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43919 } else {
43920 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43921 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43922 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43923 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43924 }
43925 }
43926
43927 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43928 index 798dfe9..05d0a44 100644
43929 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43930 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43931 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43932
43933 /********************* RX MODE ****************/
43934
43935 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43936 - struct bnx2x_rx_mode_obj *o);
43937 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43938
43939 /**
43940 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43941 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43942 index cd63d11..b67dd78 100644
43943 --- a/drivers/net/ethernet/broadcom/tg3.h
43944 +++ b/drivers/net/ethernet/broadcom/tg3.h
43945 @@ -147,6 +147,7 @@
43946 #define CHIPREV_ID_5750_A0 0x4000
43947 #define CHIPREV_ID_5750_A1 0x4001
43948 #define CHIPREV_ID_5750_A3 0x4003
43949 +#define CHIPREV_ID_5750_C1 0x4201
43950 #define CHIPREV_ID_5750_C2 0x4202
43951 #define CHIPREV_ID_5752_A0_HW 0x5000
43952 #define CHIPREV_ID_5752_A0 0x6000
43953 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43954 index 8cffcdf..aadf043 100644
43955 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43956 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43957 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43958 */
43959 struct l2t_skb_cb {
43960 arp_failure_handler_func arp_failure_handler;
43961 -};
43962 +} __no_const;
43963
43964 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43965
43966 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43967 index 9c89dc8..725ecc3 100644
43968 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
43969 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43970 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
43971 flits = skb_transport_offset(skb) / 8;
43972 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
43973 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
43974 - skb->tail - skb->transport_header,
43975 + skb_tail_pointer(skb) - skb_transport_header(skb),
43976 adap->pdev);
43977 if (need_skb_unmap()) {
43978 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
43979 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43980 index 4c83003..2a2a5b9 100644
43981 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43982 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43983 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43984 for (i=0; i<ETH_ALEN; i++) {
43985 tmp.addr[i] = dev->dev_addr[i];
43986 }
43987 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43988 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43989 break;
43990
43991 case DE4X5_SET_HWADDR: /* Set the hardware address */
43992 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43993 spin_lock_irqsave(&lp->lock, flags);
43994 memcpy(&statbuf, &lp->pktStats, ioc->len);
43995 spin_unlock_irqrestore(&lp->lock, flags);
43996 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43997 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43998 return -EFAULT;
43999 break;
44000 }
44001 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44002 index 3d91a5e..1014702 100644
44003 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44004 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44005 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44006
44007 if (wrapped)
44008 newacc += 65536;
44009 - ACCESS_ONCE(*acc) = newacc;
44010 + ACCESS_ONCE_RW(*acc) = newacc;
44011 }
44012
44013 void populate_erx_stats(struct be_adapter *adapter,
44014 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44015 index 934e1ae..b262e6b 100644
44016 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44017 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44018 @@ -31,6 +31,8 @@
44019 #include <linux/netdevice.h>
44020 #include <linux/phy.h>
44021 #include <linux/platform_device.h>
44022 +#include <linux/interrupt.h>
44023 +#include <linux/irqreturn.h>
44024 #include <net/ip.h>
44025
44026 #include "ftgmac100.h"
44027 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44028 index 4658f4c..407d155 100644
44029 --- a/drivers/net/ethernet/faraday/ftmac100.c
44030 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44031 @@ -31,6 +31,8 @@
44032 #include <linux/module.h>
44033 #include <linux/netdevice.h>
44034 #include <linux/platform_device.h>
44035 +#include <linux/interrupt.h>
44036 +#include <linux/irqreturn.h>
44037
44038 #include "ftmac100.h"
44039
44040 diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
44041 index 85fe7b5..e2da180 100644
44042 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
44043 +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
44044 @@ -2637,6 +2637,8 @@ static int igb_set_eee(struct net_device *netdev,
44045 (hw->phy.media_type != e1000_media_type_copper))
44046 return -EOPNOTSUPP;
44047
44048 + memset(&eee_curr, 0, sizeof(struct ethtool_eee));
44049 +
44050 ret_val = igb_get_eee(netdev, &eee_curr);
44051 if (ret_val)
44052 return ret_val;
44053 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44054 index 331987d..3be1135 100644
44055 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44056 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44057 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44058 }
44059
44060 /* update the base incval used to calculate frequency adjustment */
44061 - ACCESS_ONCE(adapter->base_incval) = incval;
44062 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44063 smp_mb();
44064
44065 /* need lock to prevent incorrect read while modifying cyclecounter */
44066 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44067 index fbe5363..266b4e3 100644
44068 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44069 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44070 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44071 struct __vxge_hw_fifo *fifo;
44072 struct vxge_hw_fifo_config *config;
44073 u32 txdl_size, txdl_per_memblock;
44074 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44075 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44076 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44077 + };
44078 +
44079 struct __vxge_hw_virtualpath *vpath;
44080
44081 if ((vp == NULL) || (attr == NULL)) {
44082 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44083 goto exit;
44084 }
44085
44086 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44087 -
44088 fifo->mempool =
44089 __vxge_hw_mempool_create(vpath->hldev,
44090 fifo->config->memblock_size,
44091 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44092 index 345d987..af69721 100644
44093 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44094 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44095 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44096 op_mode = QLC_83XX_DEFAULT_OPMODE;
44097
44098 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44099 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44100 + pax_open_kernel();
44101 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44102 + pax_close_kernel();
44103 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44104 } else {
44105 return -EIO;
44106 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44107 index 599d1fd..59868fe 100644
44108 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44109 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44110 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44111 case QLCNIC_NON_PRIV_FUNC:
44112 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44113 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44114 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44115 + pax_open_kernel();
44116 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44117 + pax_close_kernel();
44118 break;
44119 case QLCNIC_PRIV_FUNC:
44120 ahw->op_mode = QLCNIC_PRIV_FUNC;
44121 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44122 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44123 + pax_open_kernel();
44124 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44125 + pax_close_kernel();
44126 break;
44127 case QLCNIC_MGMT_FUNC:
44128 ahw->op_mode = QLCNIC_MGMT_FUNC;
44129 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44130 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44131 + pax_open_kernel();
44132 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44133 + pax_close_kernel();
44134 break;
44135 default:
44136 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44137 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44138 index 7ba68e0..618c73d 100644
44139 --- a/drivers/net/ethernet/realtek/r8169.c
44140 +++ b/drivers/net/ethernet/realtek/r8169.c
44141 @@ -759,22 +759,22 @@ struct rtl8169_private {
44142 struct mdio_ops {
44143 void (*write)(struct rtl8169_private *, int, int);
44144 int (*read)(struct rtl8169_private *, int);
44145 - } mdio_ops;
44146 + } __no_const mdio_ops;
44147
44148 struct pll_power_ops {
44149 void (*down)(struct rtl8169_private *);
44150 void (*up)(struct rtl8169_private *);
44151 - } pll_power_ops;
44152 + } __no_const pll_power_ops;
44153
44154 struct jumbo_ops {
44155 void (*enable)(struct rtl8169_private *);
44156 void (*disable)(struct rtl8169_private *);
44157 - } jumbo_ops;
44158 + } __no_const jumbo_ops;
44159
44160 struct csi_ops {
44161 void (*write)(struct rtl8169_private *, int, int);
44162 u32 (*read)(struct rtl8169_private *, int);
44163 - } csi_ops;
44164 + } __no_const csi_ops;
44165
44166 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44167 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44168 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44169 index b495394..0748c54 100644
44170 --- a/drivers/net/ethernet/sfc/ptp.c
44171 +++ b/drivers/net/ethernet/sfc/ptp.c
44172 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44173 (u32)((u64)ptp->start.dma_addr >> 32));
44174
44175 /* Clear flag that signals MC ready */
44176 - ACCESS_ONCE(*start) = 0;
44177 + ACCESS_ONCE_RW(*start) = 0;
44178 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44179 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44180
44181 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44182 index 50617c5..b13724c 100644
44183 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44184 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44185 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44186
44187 writel(value, ioaddr + MMC_CNTRL);
44188
44189 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44190 - MMC_CNTRL, value);
44191 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44192 +// MMC_CNTRL, value);
44193 }
44194
44195 /* To mask all all interrupts.*/
44196 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44197 index e6fe0d8..2b7d752 100644
44198 --- a/drivers/net/hyperv/hyperv_net.h
44199 +++ b/drivers/net/hyperv/hyperv_net.h
44200 @@ -101,7 +101,7 @@ struct rndis_device {
44201
44202 enum rndis_device_state state;
44203 bool link_state;
44204 - atomic_t new_req_id;
44205 + atomic_unchecked_t new_req_id;
44206
44207 spinlock_t request_lock;
44208 struct list_head req_list;
44209 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44210 index 0775f0a..d4fb316 100644
44211 --- a/drivers/net/hyperv/rndis_filter.c
44212 +++ b/drivers/net/hyperv/rndis_filter.c
44213 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44214 * template
44215 */
44216 set = &rndis_msg->msg.set_req;
44217 - set->req_id = atomic_inc_return(&dev->new_req_id);
44218 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44219
44220 /* Add to the request list */
44221 spin_lock_irqsave(&dev->request_lock, flags);
44222 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44223
44224 /* Setup the rndis set */
44225 halt = &request->request_msg.msg.halt_req;
44226 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44227 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44228
44229 /* Ignore return since this msg is optional. */
44230 rndis_filter_send_request(dev, request);
44231 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44232 index bf0d55e..82bcfbd1 100644
44233 --- a/drivers/net/ieee802154/fakehard.c
44234 +++ b/drivers/net/ieee802154/fakehard.c
44235 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44236 phy->transmit_power = 0xbf;
44237
44238 dev->netdev_ops = &fake_ops;
44239 - dev->ml_priv = &fake_mlme;
44240 + dev->ml_priv = (void *)&fake_mlme;
44241
44242 priv = netdev_priv(dev);
44243 priv->phy = phy;
44244 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44245 index 16b43bf..ead0c35 100644
44246 --- a/drivers/net/macvlan.c
44247 +++ b/drivers/net/macvlan.c
44248 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44249 int macvlan_link_register(struct rtnl_link_ops *ops)
44250 {
44251 /* common fields */
44252 - ops->priv_size = sizeof(struct macvlan_dev);
44253 - ops->validate = macvlan_validate;
44254 - ops->maxtype = IFLA_MACVLAN_MAX;
44255 - ops->policy = macvlan_policy;
44256 - ops->changelink = macvlan_changelink;
44257 - ops->get_size = macvlan_get_size;
44258 - ops->fill_info = macvlan_fill_info;
44259 + pax_open_kernel();
44260 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44261 + *(void **)&ops->validate = macvlan_validate;
44262 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44263 + *(const void **)&ops->policy = macvlan_policy;
44264 + *(void **)&ops->changelink = macvlan_changelink;
44265 + *(void **)&ops->get_size = macvlan_get_size;
44266 + *(void **)&ops->fill_info = macvlan_fill_info;
44267 + pax_close_kernel();
44268
44269 return rtnl_link_register(ops);
44270 };
44271 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44272 return NOTIFY_DONE;
44273 }
44274
44275 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44276 +static struct notifier_block macvlan_notifier_block = {
44277 .notifier_call = macvlan_device_event,
44278 };
44279
44280 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44281 index ea53abb..2e4d087 100644
44282 --- a/drivers/net/macvtap.c
44283 +++ b/drivers/net/macvtap.c
44284 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44285 return NOTIFY_DONE;
44286 }
44287
44288 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44289 +static struct notifier_block macvtap_notifier_block = {
44290 .notifier_call = macvtap_device_event,
44291 };
44292
44293 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44294 index daec9b0..6428fcb 100644
44295 --- a/drivers/net/phy/mdio-bitbang.c
44296 +++ b/drivers/net/phy/mdio-bitbang.c
44297 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44298 struct mdiobb_ctrl *ctrl = bus->priv;
44299
44300 module_put(ctrl->ops->owner);
44301 + mdiobus_unregister(bus);
44302 mdiobus_free(bus);
44303 }
44304 EXPORT_SYMBOL(free_mdio_bitbang);
44305 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44306 index 72ff14b..11d442d 100644
44307 --- a/drivers/net/ppp/ppp_generic.c
44308 +++ b/drivers/net/ppp/ppp_generic.c
44309 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44310 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44311 struct ppp_stats stats;
44312 struct ppp_comp_stats cstats;
44313 - char *vers;
44314
44315 switch (cmd) {
44316 case SIOCGPPPSTATS:
44317 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44318 break;
44319
44320 case SIOCGPPPVER:
44321 - vers = PPP_VERSION;
44322 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44323 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44324 break;
44325 err = 0;
44326 break;
44327 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44328 index 1252d9c..80e660b 100644
44329 --- a/drivers/net/slip/slhc.c
44330 +++ b/drivers/net/slip/slhc.c
44331 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44332 register struct tcphdr *thp;
44333 register struct iphdr *ip;
44334 register struct cstate *cs;
44335 - int len, hdrlen;
44336 + long len, hdrlen;
44337 unsigned char *cp = icp;
44338
44339 /* We've got a compressed packet; read the change byte */
44340 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44341 index bff7e0b..7315137 100644
44342 --- a/drivers/net/team/team.c
44343 +++ b/drivers/net/team/team.c
44344 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44345 return NOTIFY_DONE;
44346 }
44347
44348 -static struct notifier_block team_notifier_block __read_mostly = {
44349 +static struct notifier_block team_notifier_block = {
44350 .notifier_call = team_device_event,
44351 };
44352
44353 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44354 index 68b9aa3..b3c20f3 100644
44355 --- a/drivers/net/tun.c
44356 +++ b/drivers/net/tun.c
44357 @@ -1874,7 +1874,7 @@ unlock:
44358 }
44359
44360 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44361 - unsigned long arg, int ifreq_len)
44362 + unsigned long arg, size_t ifreq_len)
44363 {
44364 struct tun_file *tfile = file->private_data;
44365 struct tun_struct *tun;
44366 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44367 int vnet_hdr_sz;
44368 int ret;
44369
44370 + if (ifreq_len > sizeof ifr)
44371 + return -EFAULT;
44372 +
44373 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44374 if (copy_from_user(&ifr, argp, ifreq_len))
44375 return -EFAULT;
44376 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44377 index 86292e6..8d34433 100644
44378 --- a/drivers/net/usb/hso.c
44379 +++ b/drivers/net/usb/hso.c
44380 @@ -71,7 +71,7 @@
44381 #include <asm/byteorder.h>
44382 #include <linux/serial_core.h>
44383 #include <linux/serial.h>
44384 -
44385 +#include <asm/local.h>
44386
44387 #define MOD_AUTHOR "Option Wireless"
44388 #define MOD_DESCRIPTION "USB High Speed Option driver"
44389 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44390 struct urb *urb;
44391
44392 urb = serial->rx_urb[0];
44393 - if (serial->port.count > 0) {
44394 + if (atomic_read(&serial->port.count) > 0) {
44395 count = put_rxbuf_data(urb, serial);
44396 if (count == -1)
44397 return;
44398 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44399 DUMP1(urb->transfer_buffer, urb->actual_length);
44400
44401 /* Anyone listening? */
44402 - if (serial->port.count == 0)
44403 + if (atomic_read(&serial->port.count) == 0)
44404 return;
44405
44406 if (status == 0) {
44407 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44408 tty_port_tty_set(&serial->port, tty);
44409
44410 /* check for port already opened, if not set the termios */
44411 - serial->port.count++;
44412 - if (serial->port.count == 1) {
44413 + if (atomic_inc_return(&serial->port.count) == 1) {
44414 serial->rx_state = RX_IDLE;
44415 /* Force default termio settings */
44416 _hso_serial_set_termios(tty, NULL);
44417 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44418 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44419 if (result) {
44420 hso_stop_serial_device(serial->parent);
44421 - serial->port.count--;
44422 + atomic_dec(&serial->port.count);
44423 kref_put(&serial->parent->ref, hso_serial_ref_free);
44424 }
44425 } else {
44426 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44427
44428 /* reset the rts and dtr */
44429 /* do the actual close */
44430 - serial->port.count--;
44431 + atomic_dec(&serial->port.count);
44432
44433 - if (serial->port.count <= 0) {
44434 - serial->port.count = 0;
44435 + if (atomic_read(&serial->port.count) <= 0) {
44436 + atomic_set(&serial->port.count, 0);
44437 tty_port_tty_set(&serial->port, NULL);
44438 if (!usb_gone)
44439 hso_stop_serial_device(serial->parent);
44440 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44441
44442 /* the actual setup */
44443 spin_lock_irqsave(&serial->serial_lock, flags);
44444 - if (serial->port.count)
44445 + if (atomic_read(&serial->port.count))
44446 _hso_serial_set_termios(tty, old);
44447 else
44448 tty->termios = *old;
44449 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44450 D1("Pending read interrupt on port %d\n", i);
44451 spin_lock(&serial->serial_lock);
44452 if (serial->rx_state == RX_IDLE &&
44453 - serial->port.count > 0) {
44454 + atomic_read(&serial->port.count) > 0) {
44455 /* Setup and send a ctrl req read on
44456 * port i */
44457 if (!serial->rx_urb_filled[0]) {
44458 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44459 /* Start all serial ports */
44460 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44461 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44462 - if (dev2ser(serial_table[i])->port.count) {
44463 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44464 result =
44465 hso_start_serial_device(serial_table[i], GFP_NOIO);
44466 hso_kick_transmit(dev2ser(serial_table[i]));
44467 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44468 index a79e9d3..78cd4fa 100644
44469 --- a/drivers/net/usb/sierra_net.c
44470 +++ b/drivers/net/usb/sierra_net.c
44471 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44472 /* atomic counter partially included in MAC address to make sure 2 devices
44473 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44474 */
44475 -static atomic_t iface_counter = ATOMIC_INIT(0);
44476 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44477
44478 /*
44479 * SYNC Timer Delay definition used to set the expiry time
44480 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44481 dev->net->netdev_ops = &sierra_net_device_ops;
44482
44483 /* change MAC addr to include, ifacenum, and to be unique */
44484 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44485 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44486 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44487
44488 /* we will have to manufacture ethernet headers, prepare template */
44489 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44490 index 8a05d77..ba8b9c5 100644
44491 --- a/drivers/net/vxlan.c
44492 +++ b/drivers/net/vxlan.c
44493 @@ -1870,7 +1870,7 @@ nla_put_failure:
44494 return -EMSGSIZE;
44495 }
44496
44497 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44498 +static struct rtnl_link_ops vxlan_link_ops = {
44499 .kind = "vxlan",
44500 .maxtype = IFLA_VXLAN_MAX,
44501 .policy = vxlan_policy,
44502 diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
44503 index 3f0c4f2..bcfff0d 100644
44504 --- a/drivers/net/wan/farsync.c
44505 +++ b/drivers/net/wan/farsync.c
44506 @@ -1972,6 +1972,7 @@ fst_get_iface(struct fst_card_info *card, struct fst_port_info *port,
44507 }
44508
44509 i = port->index;
44510 + memset(&sync, 0, sizeof(sync));
44511 sync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed);
44512 /* Lucky card and linux use same encoding here */
44513 sync.clock_type = FST_RDB(card, portConfig[i].internalClock) ==
44514 diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
44515 index 6a24a5a..4c0a697 100644
44516 --- a/drivers/net/wan/wanxl.c
44517 +++ b/drivers/net/wan/wanxl.c
44518 @@ -355,6 +355,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44519 ifr->ifr_settings.size = size; /* data size wanted */
44520 return -ENOBUFS;
44521 }
44522 + memset(&line, 0, sizeof(line));
44523 line.clock_type = get_status(port)->clocking;
44524 line.clock_rate = 0;
44525 line.loopback = 0;
44526 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44527 index 0b60295..b8bfa5b 100644
44528 --- a/drivers/net/wimax/i2400m/rx.c
44529 +++ b/drivers/net/wimax/i2400m/rx.c
44530 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44531 if (i2400m->rx_roq == NULL)
44532 goto error_roq_alloc;
44533
44534 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44535 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44536 GFP_KERNEL);
44537 if (rd == NULL) {
44538 result = -ENOMEM;
44539 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44540 index 34c8a33..3261fdc 100644
44541 --- a/drivers/net/wireless/at76c50x-usb.c
44542 +++ b/drivers/net/wireless/at76c50x-usb.c
44543 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44544 }
44545
44546 /* Convert timeout from the DFU status to jiffies */
44547 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44548 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44549 {
44550 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44551 | (s->poll_timeout[1] << 8)
44552 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44553 index 2b3426b..1f564be 100644
44554 --- a/drivers/net/wireless/ath/ath10k/core.c
44555 +++ b/drivers/net/wireless/ath/ath10k/core.c
44556 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44557
44558 int ath10k_core_register(struct ath10k *ar)
44559 {
44560 - struct ath10k_htc_ops htc_ops;
44561 + static struct ath10k_htc_ops htc_ops = {
44562 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44563 + };
44564 struct bmi_target_info target_info;
44565 int status;
44566
44567 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44568 if (status)
44569 goto err;
44570
44571 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44572 -
44573 ar->htc = ath10k_htc_create(ar, &htc_ops);
44574 if (IS_ERR(ar->htc)) {
44575 status = PTR_ERR(ar->htc);
44576 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44577 index 74363c9..237b926 100644
44578 --- a/drivers/net/wireless/ath/ath10k/htc.c
44579 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44580 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44581 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44582 struct ath10k_htc_ops *htc_ops)
44583 {
44584 - struct ath10k_hif_cb htc_callbacks;
44585 + static struct ath10k_hif_cb htc_callbacks = {
44586 + .rx_completion = ath10k_htc_rx_completion_handler,
44587 + .tx_completion = ath10k_htc_tx_completion_handler,
44588 + };
44589 struct ath10k_htc_ep *ep = NULL;
44590 struct ath10k_htc *htc = NULL;
44591
44592 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44593 ath10k_htc_reset_endpoint_states(htc);
44594
44595 /* setup HIF layer callbacks */
44596 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44597 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44598 htc->ar = ar;
44599
44600 /* Get HIF default pipe for HTC message exchange */
44601 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44602 index 8d78253..bebbb68 100644
44603 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44604 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44605 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44606 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44607 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44608
44609 - ACCESS_ONCE(ads->ds_link) = i->link;
44610 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44611 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44612 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44613
44614 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44615 ctl6 = SM(i->keytype, AR_EncrType);
44616 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44617
44618 if ((i->is_first || i->is_last) &&
44619 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44620 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44621 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44622 | set11nTries(i->rates, 1)
44623 | set11nTries(i->rates, 2)
44624 | set11nTries(i->rates, 3)
44625 | (i->dur_update ? AR_DurUpdateEna : 0)
44626 | SM(0, AR_BurstDur);
44627
44628 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44629 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44630 | set11nRate(i->rates, 1)
44631 | set11nRate(i->rates, 2)
44632 | set11nRate(i->rates, 3);
44633 } else {
44634 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44635 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44636 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44637 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44638 }
44639
44640 if (!i->is_first) {
44641 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44642 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44643 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44644 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44645 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44646 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44647 return;
44648 }
44649
44650 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44651 break;
44652 }
44653
44654 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44655 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44656 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44657 | SM(i->txpower, AR_XmitPower)
44658 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44659 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44660 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44661 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44662
44663 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44664 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44665 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44666 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44667
44668 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44669 return;
44670
44671 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44672 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44673 | set11nPktDurRTSCTS(i->rates, 1);
44674
44675 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44676 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44677 | set11nPktDurRTSCTS(i->rates, 3);
44678
44679 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44680 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44681 | set11nRateFlags(i->rates, 1)
44682 | set11nRateFlags(i->rates, 2)
44683 | set11nRateFlags(i->rates, 3)
44684 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44685 index 5163abd..3ada4c2 100644
44686 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44687 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44688 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44689 (i->qcu << AR_TxQcuNum_S) | desc_len;
44690
44691 checksum += val;
44692 - ACCESS_ONCE(ads->info) = val;
44693 + ACCESS_ONCE_RW(ads->info) = val;
44694
44695 checksum += i->link;
44696 - ACCESS_ONCE(ads->link) = i->link;
44697 + ACCESS_ONCE_RW(ads->link) = i->link;
44698
44699 checksum += i->buf_addr[0];
44700 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44701 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44702 checksum += i->buf_addr[1];
44703 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44704 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44705 checksum += i->buf_addr[2];
44706 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44707 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44708 checksum += i->buf_addr[3];
44709 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44710 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44711
44712 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44713 - ACCESS_ONCE(ads->ctl3) = val;
44714 + ACCESS_ONCE_RW(ads->ctl3) = val;
44715 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44716 - ACCESS_ONCE(ads->ctl5) = val;
44717 + ACCESS_ONCE_RW(ads->ctl5) = val;
44718 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44719 - ACCESS_ONCE(ads->ctl7) = val;
44720 + ACCESS_ONCE_RW(ads->ctl7) = val;
44721 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44722 - ACCESS_ONCE(ads->ctl9) = val;
44723 + ACCESS_ONCE_RW(ads->ctl9) = val;
44724
44725 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44726 - ACCESS_ONCE(ads->ctl10) = checksum;
44727 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44728
44729 if (i->is_first || i->is_last) {
44730 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44731 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44732 | set11nTries(i->rates, 1)
44733 | set11nTries(i->rates, 2)
44734 | set11nTries(i->rates, 3)
44735 | (i->dur_update ? AR_DurUpdateEna : 0)
44736 | SM(0, AR_BurstDur);
44737
44738 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44739 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44740 | set11nRate(i->rates, 1)
44741 | set11nRate(i->rates, 2)
44742 | set11nRate(i->rates, 3);
44743 } else {
44744 - ACCESS_ONCE(ads->ctl13) = 0;
44745 - ACCESS_ONCE(ads->ctl14) = 0;
44746 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44747 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44748 }
44749
44750 ads->ctl20 = 0;
44751 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44752
44753 ctl17 = SM(i->keytype, AR_EncrType);
44754 if (!i->is_first) {
44755 - ACCESS_ONCE(ads->ctl11) = 0;
44756 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44757 - ACCESS_ONCE(ads->ctl15) = 0;
44758 - ACCESS_ONCE(ads->ctl16) = 0;
44759 - ACCESS_ONCE(ads->ctl17) = ctl17;
44760 - ACCESS_ONCE(ads->ctl18) = 0;
44761 - ACCESS_ONCE(ads->ctl19) = 0;
44762 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44763 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44764 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44765 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44766 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44767 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44768 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44769 return;
44770 }
44771
44772 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44773 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44774 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44775 | SM(i->txpower, AR_XmitPower)
44776 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44777 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44778 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44779 ctl12 |= SM(val, AR_PAPRDChainMask);
44780
44781 - ACCESS_ONCE(ads->ctl12) = ctl12;
44782 - ACCESS_ONCE(ads->ctl17) = ctl17;
44783 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44784 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44785
44786 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44787 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44788 | set11nPktDurRTSCTS(i->rates, 1);
44789
44790 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44791 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44792 | set11nPktDurRTSCTS(i->rates, 3);
44793
44794 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44795 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44796 | set11nRateFlags(i->rates, 1)
44797 | set11nRateFlags(i->rates, 2)
44798 | set11nRateFlags(i->rates, 3)
44799 | SM(i->rtscts_rate, AR_RTSCTSRate);
44800
44801 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44802 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44803 }
44804
44805 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44806 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44807 index cd74b3a..6a28d24 100644
44808 --- a/drivers/net/wireless/ath/ath9k/hw.h
44809 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44810 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44811
44812 /* ANI */
44813 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44814 -};
44815 +} __no_const;
44816
44817 /**
44818 * struct ath_spec_scan - parameters for Atheros spectral scan
44819 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44820 struct ath_spec_scan *param);
44821 void (*spectral_scan_trigger)(struct ath_hw *ah);
44822 void (*spectral_scan_wait)(struct ath_hw *ah);
44823 -};
44824 +} __no_const;
44825
44826 struct ath_nf_limits {
44827 s16 max;
44828 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44829 index 9581d07..84f6a76 100644
44830 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44831 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44832 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44833 */
44834 if (il3945_mod_params.disable_hw_scan) {
44835 D_INFO("Disabling hw_scan\n");
44836 - il3945_mac_ops.hw_scan = NULL;
44837 + pax_open_kernel();
44838 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44839 + pax_close_kernel();
44840 }
44841
44842 D_INFO("*** LOAD DRIVER ***\n");
44843 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44844 index d532948..e0d8bb1 100644
44845 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44846 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44847 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44848 {
44849 struct iwl_priv *priv = file->private_data;
44850 char buf[64];
44851 - int buf_size;
44852 + size_t buf_size;
44853 u32 offset, len;
44854
44855 memset(buf, 0, sizeof(buf));
44856 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44857 struct iwl_priv *priv = file->private_data;
44858
44859 char buf[8];
44860 - int buf_size;
44861 + size_t buf_size;
44862 u32 reset_flag;
44863
44864 memset(buf, 0, sizeof(buf));
44865 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44866 {
44867 struct iwl_priv *priv = file->private_data;
44868 char buf[8];
44869 - int buf_size;
44870 + size_t buf_size;
44871 int ht40;
44872
44873 memset(buf, 0, sizeof(buf));
44874 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44875 {
44876 struct iwl_priv *priv = file->private_data;
44877 char buf[8];
44878 - int buf_size;
44879 + size_t buf_size;
44880 int value;
44881
44882 memset(buf, 0, sizeof(buf));
44883 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44884 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44885 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44886
44887 -static const char *fmt_value = " %-30s %10u\n";
44888 -static const char *fmt_hex = " %-30s 0x%02X\n";
44889 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44890 -static const char *fmt_header =
44891 +static const char fmt_value[] = " %-30s %10u\n";
44892 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44893 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44894 +static const char fmt_header[] =
44895 "%-32s current cumulative delta max\n";
44896
44897 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44898 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44899 {
44900 struct iwl_priv *priv = file->private_data;
44901 char buf[8];
44902 - int buf_size;
44903 + size_t buf_size;
44904 int clear;
44905
44906 memset(buf, 0, sizeof(buf));
44907 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44908 {
44909 struct iwl_priv *priv = file->private_data;
44910 char buf[8];
44911 - int buf_size;
44912 + size_t buf_size;
44913 int trace;
44914
44915 memset(buf, 0, sizeof(buf));
44916 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44917 {
44918 struct iwl_priv *priv = file->private_data;
44919 char buf[8];
44920 - int buf_size;
44921 + size_t buf_size;
44922 int missed;
44923
44924 memset(buf, 0, sizeof(buf));
44925 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44926
44927 struct iwl_priv *priv = file->private_data;
44928 char buf[8];
44929 - int buf_size;
44930 + size_t buf_size;
44931 int plcp;
44932
44933 memset(buf, 0, sizeof(buf));
44934 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44935
44936 struct iwl_priv *priv = file->private_data;
44937 char buf[8];
44938 - int buf_size;
44939 + size_t buf_size;
44940 int flush;
44941
44942 memset(buf, 0, sizeof(buf));
44943 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44944
44945 struct iwl_priv *priv = file->private_data;
44946 char buf[8];
44947 - int buf_size;
44948 + size_t buf_size;
44949 int rts;
44950
44951 if (!priv->cfg->ht_params)
44952 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44953 {
44954 struct iwl_priv *priv = file->private_data;
44955 char buf[8];
44956 - int buf_size;
44957 + size_t buf_size;
44958
44959 memset(buf, 0, sizeof(buf));
44960 buf_size = min(count, sizeof(buf) - 1);
44961 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44962 struct iwl_priv *priv = file->private_data;
44963 u32 event_log_flag;
44964 char buf[8];
44965 - int buf_size;
44966 + size_t buf_size;
44967
44968 /* check that the interface is up */
44969 if (!iwl_is_ready(priv))
44970 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44971 struct iwl_priv *priv = file->private_data;
44972 char buf[8];
44973 u32 calib_disabled;
44974 - int buf_size;
44975 + size_t buf_size;
44976
44977 memset(buf, 0, sizeof(buf));
44978 buf_size = min(count, sizeof(buf) - 1);
44979 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44980 index 1531a4f..21d2641 100644
44981 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44982 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44983 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44984 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44985 {
44986 struct iwl_nvm_data *data = priv->nvm_data;
44987 - char *debug_msg;
44988 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44989
44990 if (data->sku_cap_11n_enable &&
44991 !priv->cfg->ht_params) {
44992 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44993 return -EINVAL;
44994 }
44995
44996 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44997 IWL_DEBUG_INFO(priv, debug_msg,
44998 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44999 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45000 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45001 index 390e2f0..75cfbaf 100644
45002 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45003 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45004 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45005 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45006
45007 char buf[8];
45008 - int buf_size;
45009 + size_t buf_size;
45010 u32 reset_flag;
45011
45012 memset(buf, 0, sizeof(buf));
45013 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45014 {
45015 struct iwl_trans *trans = file->private_data;
45016 char buf[8];
45017 - int buf_size;
45018 + size_t buf_size;
45019 int csr;
45020
45021 memset(buf, 0, sizeof(buf));
45022 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45023 index cb34c78..9fec0dc 100644
45024 --- a/drivers/net/wireless/mac80211_hwsim.c
45025 +++ b/drivers/net/wireless/mac80211_hwsim.c
45026 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45027
45028 if (channels > 1) {
45029 hwsim_if_comb.num_different_channels = channels;
45030 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45031 - mac80211_hwsim_ops.cancel_hw_scan =
45032 - mac80211_hwsim_cancel_hw_scan;
45033 - mac80211_hwsim_ops.sw_scan_start = NULL;
45034 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45035 - mac80211_hwsim_ops.remain_on_channel =
45036 - mac80211_hwsim_roc;
45037 - mac80211_hwsim_ops.cancel_remain_on_channel =
45038 - mac80211_hwsim_croc;
45039 - mac80211_hwsim_ops.add_chanctx =
45040 - mac80211_hwsim_add_chanctx;
45041 - mac80211_hwsim_ops.remove_chanctx =
45042 - mac80211_hwsim_remove_chanctx;
45043 - mac80211_hwsim_ops.change_chanctx =
45044 - mac80211_hwsim_change_chanctx;
45045 - mac80211_hwsim_ops.assign_vif_chanctx =
45046 - mac80211_hwsim_assign_vif_chanctx;
45047 - mac80211_hwsim_ops.unassign_vif_chanctx =
45048 - mac80211_hwsim_unassign_vif_chanctx;
45049 + pax_open_kernel();
45050 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45051 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45052 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45053 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45054 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45055 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45056 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45057 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45058 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45059 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45060 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45061 + pax_close_kernel();
45062 }
45063
45064 spin_lock_init(&hwsim_radio_lock);
45065 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45066 index 8169a85..7fa3b47 100644
45067 --- a/drivers/net/wireless/rndis_wlan.c
45068 +++ b/drivers/net/wireless/rndis_wlan.c
45069 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45070
45071 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45072
45073 - if (rts_threshold < 0 || rts_threshold > 2347)
45074 + if (rts_threshold > 2347)
45075 rts_threshold = 2347;
45076
45077 tmp = cpu_to_le32(rts_threshold);
45078 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45079 index ee3fc57..ed5ddc9 100644
45080 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45081 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45082 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45083 * for hardware which doesn't support hardware
45084 * sequence counting.
45085 */
45086 - atomic_t seqno;
45087 + atomic_unchecked_t seqno;
45088 };
45089
45090 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45091 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45092 index aa95c6c..a59dd67 100644
45093 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45094 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45095 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45096 * sequence counter given by mac80211.
45097 */
45098 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45099 - seqno = atomic_add_return(0x10, &intf->seqno);
45100 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45101 else
45102 - seqno = atomic_read(&intf->seqno);
45103 + seqno = atomic_read_unchecked(&intf->seqno);
45104
45105 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45106 hdr->seq_ctrl |= cpu_to_le16(seqno);
45107 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45108 index e2b3d9c..67a5184 100644
45109 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45110 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45111 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45112
45113 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45114
45115 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45116 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45117 + pax_open_kernel();
45118 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45119 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45120 + pax_close_kernel();
45121
45122 wl1251_info("using dedicated interrupt line");
45123 } else {
45124 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45125 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45126 + pax_open_kernel();
45127 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45128 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45129 + pax_close_kernel();
45130
45131 wl1251_info("using SDIO interrupt");
45132 }
45133 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45134 index 1c627da..69f7d17 100644
45135 --- a/drivers/net/wireless/ti/wl12xx/main.c
45136 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45137 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45138 sizeof(wl->conf.mem));
45139
45140 /* read data preparation is only needed by wl127x */
45141 - wl->ops->prepare_read = wl127x_prepare_read;
45142 + pax_open_kernel();
45143 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45144 + pax_close_kernel();
45145
45146 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45147 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45148 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45149 sizeof(wl->conf.mem));
45150
45151 /* read data preparation is only needed by wl127x */
45152 - wl->ops->prepare_read = wl127x_prepare_read;
45153 + pax_open_kernel();
45154 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45155 + pax_close_kernel();
45156
45157 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45158 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45159 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45160 index 7aa0eb8..5a9ef38 100644
45161 --- a/drivers/net/wireless/ti/wl18xx/main.c
45162 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45163 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45164 }
45165
45166 if (!checksum_param) {
45167 - wl18xx_ops.set_rx_csum = NULL;
45168 - wl18xx_ops.init_vif = NULL;
45169 + pax_open_kernel();
45170 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45171 + *(void **)&wl18xx_ops.init_vif = NULL;
45172 + pax_close_kernel();
45173 }
45174
45175 /* Enable 11a Band only if we have 5G antennas */
45176 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45177 index 7ef0b4a..ff65c28 100644
45178 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45179 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45180 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45181 {
45182 struct zd_usb *usb = urb->context;
45183 struct zd_usb_interrupt *intr = &usb->intr;
45184 - int len;
45185 + unsigned int len;
45186 u16 int_num;
45187
45188 ZD_ASSERT(in_interrupt());
45189 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45190 index d93b2b6..ae50401 100644
45191 --- a/drivers/oprofile/buffer_sync.c
45192 +++ b/drivers/oprofile/buffer_sync.c
45193 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45194 if (cookie == NO_COOKIE)
45195 offset = pc;
45196 if (cookie == INVALID_COOKIE) {
45197 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45198 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45199 offset = pc;
45200 }
45201 if (cookie != last_cookie) {
45202 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45203 /* add userspace sample */
45204
45205 if (!mm) {
45206 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45207 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45208 return 0;
45209 }
45210
45211 cookie = lookup_dcookie(mm, s->eip, &offset);
45212
45213 if (cookie == INVALID_COOKIE) {
45214 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45215 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45216 return 0;
45217 }
45218
45219 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45220 /* ignore backtraces if failed to add a sample */
45221 if (state == sb_bt_start) {
45222 state = sb_bt_ignore;
45223 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45224 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45225 }
45226 }
45227 release_mm(mm);
45228 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45229 index c0cc4e7..44d4e54 100644
45230 --- a/drivers/oprofile/event_buffer.c
45231 +++ b/drivers/oprofile/event_buffer.c
45232 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45233 }
45234
45235 if (buffer_pos == buffer_size) {
45236 - atomic_inc(&oprofile_stats.event_lost_overflow);
45237 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45238 return;
45239 }
45240
45241 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45242 index ed2c3ec..deda85a 100644
45243 --- a/drivers/oprofile/oprof.c
45244 +++ b/drivers/oprofile/oprof.c
45245 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45246 if (oprofile_ops.switch_events())
45247 return;
45248
45249 - atomic_inc(&oprofile_stats.multiplex_counter);
45250 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45251 start_switch_worker();
45252 }
45253
45254 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45255 index 84a208d..d61b0a1 100644
45256 --- a/drivers/oprofile/oprofile_files.c
45257 +++ b/drivers/oprofile/oprofile_files.c
45258 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45259
45260 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45261
45262 -static ssize_t timeout_read(struct file *file, char __user *buf,
45263 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45264 size_t count, loff_t *offset)
45265 {
45266 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45267 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45268 index 917d28e..d62d981 100644
45269 --- a/drivers/oprofile/oprofile_stats.c
45270 +++ b/drivers/oprofile/oprofile_stats.c
45271 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45272 cpu_buf->sample_invalid_eip = 0;
45273 }
45274
45275 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45276 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45277 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45278 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45279 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45280 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45281 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45282 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45283 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45284 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45285 }
45286
45287
45288 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45289 index 38b6fc0..b5cbfce 100644
45290 --- a/drivers/oprofile/oprofile_stats.h
45291 +++ b/drivers/oprofile/oprofile_stats.h
45292 @@ -13,11 +13,11 @@
45293 #include <linux/atomic.h>
45294
45295 struct oprofile_stat_struct {
45296 - atomic_t sample_lost_no_mm;
45297 - atomic_t sample_lost_no_mapping;
45298 - atomic_t bt_lost_no_mapping;
45299 - atomic_t event_lost_overflow;
45300 - atomic_t multiplex_counter;
45301 + atomic_unchecked_t sample_lost_no_mm;
45302 + atomic_unchecked_t sample_lost_no_mapping;
45303 + atomic_unchecked_t bt_lost_no_mapping;
45304 + atomic_unchecked_t event_lost_overflow;
45305 + atomic_unchecked_t multiplex_counter;
45306 };
45307
45308 extern struct oprofile_stat_struct oprofile_stats;
45309 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45310 index 7c12d9c..558bf3bb 100644
45311 --- a/drivers/oprofile/oprofilefs.c
45312 +++ b/drivers/oprofile/oprofilefs.c
45313 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45314
45315
45316 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45317 - char const *name, atomic_t *val)
45318 + char const *name, atomic_unchecked_t *val)
45319 {
45320 return __oprofilefs_create_file(sb, root, name,
45321 &atomic_ro_fops, 0444, val);
45322 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45323 index 61be1d9..dec05d7 100644
45324 --- a/drivers/oprofile/timer_int.c
45325 +++ b/drivers/oprofile/timer_int.c
45326 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45327 return NOTIFY_OK;
45328 }
45329
45330 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45331 +static struct notifier_block oprofile_cpu_notifier = {
45332 .notifier_call = oprofile_cpu_notify,
45333 };
45334
45335 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45336 index 92ed045..62d39bd7 100644
45337 --- a/drivers/parport/procfs.c
45338 +++ b/drivers/parport/procfs.c
45339 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45340
45341 *ppos += len;
45342
45343 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45344 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45345 }
45346
45347 #ifdef CONFIG_PARPORT_1284
45348 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45349
45350 *ppos += len;
45351
45352 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45353 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45354 }
45355 #endif /* IEEE1284.3 support. */
45356
45357 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45358 index c35e8ad..fc33beb 100644
45359 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45360 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45361 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45362 goto init_cleanup;
45363 }
45364
45365 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45366 + pax_open_kernel();
45367 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45368 + pax_close_kernel();
45369 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45370
45371 return retval;
45372 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45373 index a6a71c4..c91097b 100644
45374 --- a/drivers/pci/hotplug/cpcihp_generic.c
45375 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45376 @@ -73,7 +73,6 @@ static u16 port;
45377 static unsigned int enum_bit;
45378 static u8 enum_mask;
45379
45380 -static struct cpci_hp_controller_ops generic_hpc_ops;
45381 static struct cpci_hp_controller generic_hpc;
45382
45383 static int __init validate_parameters(void)
45384 @@ -139,6 +138,10 @@ static int query_enum(void)
45385 return ((value & enum_mask) == enum_mask);
45386 }
45387
45388 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45389 + .query_enum = query_enum,
45390 +};
45391 +
45392 static int __init cpcihp_generic_init(void)
45393 {
45394 int status;
45395 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45396 pci_dev_put(dev);
45397
45398 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45399 - generic_hpc_ops.query_enum = query_enum;
45400 generic_hpc.ops = &generic_hpc_ops;
45401
45402 status = cpci_hp_register_controller(&generic_hpc);
45403 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45404 index 449b4bb..257e2e8 100644
45405 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45406 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45407 @@ -59,7 +59,6 @@
45408 /* local variables */
45409 static bool debug;
45410 static bool poll;
45411 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45412 static struct cpci_hp_controller zt5550_hpc;
45413
45414 /* Primary cPCI bus bridge device */
45415 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45416 return 0;
45417 }
45418
45419 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45420 + .query_enum = zt5550_hc_query_enum,
45421 +};
45422 +
45423 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45424 {
45425 int status;
45426 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45427 dbg("returned from zt5550_hc_config");
45428
45429 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45430 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45431 zt5550_hpc.ops = &zt5550_hpc_ops;
45432 if(!poll) {
45433 zt5550_hpc.irq = hc_dev->irq;
45434 zt5550_hpc.irq_flags = IRQF_SHARED;
45435 zt5550_hpc.dev_id = hc_dev;
45436
45437 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45438 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45439 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45440 + pax_open_kernel();
45441 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45442 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45443 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45444 + pax_open_kernel();
45445 } else {
45446 info("using ENUM# polling mode");
45447 }
45448 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45449 index 76ba8a1..20ca857 100644
45450 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45451 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45452 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45453
45454 void compaq_nvram_init (void __iomem *rom_start)
45455 {
45456 +
45457 +#ifndef CONFIG_PAX_KERNEXEC
45458 if (rom_start) {
45459 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45460 }
45461 +#endif
45462 +
45463 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45464
45465 /* initialize our int15 lock */
45466 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45467 index ec20f74..c1d961e 100644
45468 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45469 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45470 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45471 return -EINVAL;
45472 }
45473
45474 - slot->ops->owner = owner;
45475 - slot->ops->mod_name = mod_name;
45476 + pax_open_kernel();
45477 + *(struct module **)&slot->ops->owner = owner;
45478 + *(const char **)&slot->ops->mod_name = mod_name;
45479 + pax_close_kernel();
45480
45481 mutex_lock(&pci_hp_mutex);
45482 /*
45483 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45484 index 7d72c5e..edce02c 100644
45485 --- a/drivers/pci/hotplug/pciehp_core.c
45486 +++ b/drivers/pci/hotplug/pciehp_core.c
45487 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45488 struct slot *slot = ctrl->slot;
45489 struct hotplug_slot *hotplug = NULL;
45490 struct hotplug_slot_info *info = NULL;
45491 - struct hotplug_slot_ops *ops = NULL;
45492 + hotplug_slot_ops_no_const *ops = NULL;
45493 char name[SLOT_NAME_SIZE];
45494 int retval = -ENOMEM;
45495
45496 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45497 index c0dbe1f..94cf3d8 100644
45498 --- a/drivers/pci/pci-sysfs.c
45499 +++ b/drivers/pci/pci-sysfs.c
45500 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45501 {
45502 /* allocate attribute structure, piggyback attribute name */
45503 int name_len = write_combine ? 13 : 10;
45504 - struct bin_attribute *res_attr;
45505 + bin_attribute_no_const *res_attr;
45506 int retval;
45507
45508 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45509 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45510 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45511 {
45512 int retval;
45513 - struct bin_attribute *attr;
45514 + bin_attribute_no_const *attr;
45515
45516 /* If the device has VPD, try to expose it in sysfs. */
45517 if (dev->vpd) {
45518 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45519 {
45520 int retval;
45521 int rom_size = 0;
45522 - struct bin_attribute *attr;
45523 + bin_attribute_no_const *attr;
45524
45525 if (!sysfs_initialized)
45526 return -EACCES;
45527 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45528 index d1182c4..2a138ec 100644
45529 --- a/drivers/pci/pci.h
45530 +++ b/drivers/pci/pci.h
45531 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45532 struct pci_vpd {
45533 unsigned int len;
45534 const struct pci_vpd_ops *ops;
45535 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45536 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45537 };
45538
45539 int pci_vpd_pci22_init(struct pci_dev *dev);
45540 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45541 index 403a443..034e050 100644
45542 --- a/drivers/pci/pcie/aspm.c
45543 +++ b/drivers/pci/pcie/aspm.c
45544 @@ -27,9 +27,9 @@
45545 #define MODULE_PARAM_PREFIX "pcie_aspm."
45546
45547 /* Note: those are not register definitions */
45548 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45549 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45550 -#define ASPM_STATE_L1 (4) /* L1 state */
45551 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45552 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45553 +#define ASPM_STATE_L1 (4U) /* L1 state */
45554 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45555 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45556
45557 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45558 index 46ada5c..20da716 100644
45559 --- a/drivers/pci/probe.c
45560 +++ b/drivers/pci/probe.c
45561 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45562 struct pci_bus_region region, inverted_region;
45563 bool bar_too_big = false, bar_disabled = false;
45564
45565 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45566 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45567
45568 /* No printks while decoding is disabled! */
45569 if (!dev->mmio_always_on) {
45570 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45571 index cdc7836..528635c 100644
45572 --- a/drivers/pci/proc.c
45573 +++ b/drivers/pci/proc.c
45574 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45575 static int __init pci_proc_init(void)
45576 {
45577 struct pci_dev *dev = NULL;
45578 +
45579 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45580 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45581 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45582 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45583 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45584 +#endif
45585 +#else
45586 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45587 +#endif
45588 proc_create("devices", 0, proc_bus_pci_dir,
45589 &proc_bus_pci_dev_operations);
45590 proc_initialized = 1;
45591 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45592 index 3e5b4497..dcdfb70 100644
45593 --- a/drivers/platform/x86/chromeos_laptop.c
45594 +++ b/drivers/platform/x86/chromeos_laptop.c
45595 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45596 return 0;
45597 }
45598
45599 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45600 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45601 {
45602 .ident = "Samsung Series 5 550 - Touchpad",
45603 .matches = {
45604 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45605 index 62f8030..c7f2a45 100644
45606 --- a/drivers/platform/x86/msi-laptop.c
45607 +++ b/drivers/platform/x86/msi-laptop.c
45608 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45609
45610 if (!quirks->ec_read_only) {
45611 /* allow userland write sysfs file */
45612 - dev_attr_bluetooth.store = store_bluetooth;
45613 - dev_attr_wlan.store = store_wlan;
45614 - dev_attr_threeg.store = store_threeg;
45615 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45616 - dev_attr_wlan.attr.mode |= S_IWUSR;
45617 - dev_attr_threeg.attr.mode |= S_IWUSR;
45618 + pax_open_kernel();
45619 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45620 + *(void **)&dev_attr_wlan.store = store_wlan;
45621 + *(void **)&dev_attr_threeg.store = store_threeg;
45622 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45623 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45624 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45625 + pax_close_kernel();
45626 }
45627
45628 /* disable hardware control by fn key */
45629 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45630 index 3a1b6bf..b453930 100644
45631 --- a/drivers/platform/x86/sony-laptop.c
45632 +++ b/drivers/platform/x86/sony-laptop.c
45633 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45634 }
45635
45636 /* High speed charging function */
45637 -static struct device_attribute *hsc_handle;
45638 +static device_attribute_no_const *hsc_handle;
45639
45640 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45641 struct device_attribute *attr,
45642 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45643 index 54d31c0..3f896d3 100644
45644 --- a/drivers/platform/x86/thinkpad_acpi.c
45645 +++ b/drivers/platform/x86/thinkpad_acpi.c
45646 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45647 return 0;
45648 }
45649
45650 -void static hotkey_mask_warn_incomplete_mask(void)
45651 +static void hotkey_mask_warn_incomplete_mask(void)
45652 {
45653 /* log only what the user can fix... */
45654 const u32 wantedmask = hotkey_driver_mask &
45655 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45656 }
45657 }
45658
45659 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45660 - struct tp_nvram_state *newn,
45661 - const u32 event_mask)
45662 -{
45663 -
45664 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45665 do { \
45666 if ((event_mask & (1 << __scancode)) && \
45667 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45668 tpacpi_hotkey_send_key(__scancode); \
45669 } while (0)
45670
45671 - void issue_volchange(const unsigned int oldvol,
45672 - const unsigned int newvol)
45673 - {
45674 - unsigned int i = oldvol;
45675 +static void issue_volchange(const unsigned int oldvol,
45676 + const unsigned int newvol,
45677 + const u32 event_mask)
45678 +{
45679 + unsigned int i = oldvol;
45680
45681 - while (i > newvol) {
45682 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45683 - i--;
45684 - }
45685 - while (i < newvol) {
45686 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45687 - i++;
45688 - }
45689 + while (i > newvol) {
45690 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45691 + i--;
45692 }
45693 + while (i < newvol) {
45694 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45695 + i++;
45696 + }
45697 +}
45698
45699 - void issue_brightnesschange(const unsigned int oldbrt,
45700 - const unsigned int newbrt)
45701 - {
45702 - unsigned int i = oldbrt;
45703 +static void issue_brightnesschange(const unsigned int oldbrt,
45704 + const unsigned int newbrt,
45705 + const u32 event_mask)
45706 +{
45707 + unsigned int i = oldbrt;
45708
45709 - while (i > newbrt) {
45710 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45711 - i--;
45712 - }
45713 - while (i < newbrt) {
45714 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45715 - i++;
45716 - }
45717 + while (i > newbrt) {
45718 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45719 + i--;
45720 + }
45721 + while (i < newbrt) {
45722 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45723 + i++;
45724 }
45725 +}
45726
45727 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45728 + struct tp_nvram_state *newn,
45729 + const u32 event_mask)
45730 +{
45731 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45732 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45733 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45734 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45735 oldn->volume_level != newn->volume_level) {
45736 /* recently muted, or repeated mute keypress, or
45737 * multiple presses ending in mute */
45738 - issue_volchange(oldn->volume_level, newn->volume_level);
45739 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45740 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45741 }
45742 } else {
45743 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45744 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45745 }
45746 if (oldn->volume_level != newn->volume_level) {
45747 - issue_volchange(oldn->volume_level, newn->volume_level);
45748 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45749 } else if (oldn->volume_toggle != newn->volume_toggle) {
45750 /* repeated vol up/down keypress at end of scale ? */
45751 if (newn->volume_level == 0)
45752 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45753 /* handle brightness */
45754 if (oldn->brightness_level != newn->brightness_level) {
45755 issue_brightnesschange(oldn->brightness_level,
45756 - newn->brightness_level);
45757 + newn->brightness_level,
45758 + event_mask);
45759 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45760 /* repeated key presses that didn't change state */
45761 if (newn->brightness_level == 0)
45762 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45763 && !tp_features.bright_unkfw)
45764 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45765 }
45766 +}
45767
45768 #undef TPACPI_COMPARE_KEY
45769 #undef TPACPI_MAY_SEND_KEY
45770 -}
45771
45772 /*
45773 * Polling driver
45774 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45775 index 769d265..a3a05ca 100644
45776 --- a/drivers/pnp/pnpbios/bioscalls.c
45777 +++ b/drivers/pnp/pnpbios/bioscalls.c
45778 @@ -58,7 +58,7 @@ do { \
45779 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45780 } while(0)
45781
45782 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45783 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45784 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45785
45786 /*
45787 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45788
45789 cpu = get_cpu();
45790 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45791 +
45792 + pax_open_kernel();
45793 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45794 + pax_close_kernel();
45795
45796 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45797 spin_lock_irqsave(&pnp_bios_lock, flags);
45798 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45799 :"memory");
45800 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45801
45802 + pax_open_kernel();
45803 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45804 + pax_close_kernel();
45805 +
45806 put_cpu();
45807
45808 /* If we get here and this is set then the PnP BIOS faulted on us. */
45809 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45810 return status;
45811 }
45812
45813 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45814 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45815 {
45816 int i;
45817
45818 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45819 pnp_bios_callpoint.offset = header->fields.pm16offset;
45820 pnp_bios_callpoint.segment = PNP_CS16;
45821
45822 + pax_open_kernel();
45823 +
45824 for_each_possible_cpu(i) {
45825 struct desc_struct *gdt = get_cpu_gdt_table(i);
45826 if (!gdt)
45827 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45828 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45829 (unsigned long)__va(header->fields.pm16dseg));
45830 }
45831 +
45832 + pax_close_kernel();
45833 }
45834 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45835 index d95e101..67f0c3f 100644
45836 --- a/drivers/pnp/resource.c
45837 +++ b/drivers/pnp/resource.c
45838 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45839 return 1;
45840
45841 /* check if the resource is valid */
45842 - if (*irq < 0 || *irq > 15)
45843 + if (*irq > 15)
45844 return 0;
45845
45846 /* check if the resource is reserved */
45847 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45848 return 1;
45849
45850 /* check if the resource is valid */
45851 - if (*dma < 0 || *dma == 4 || *dma > 7)
45852 + if (*dma == 4 || *dma > 7)
45853 return 0;
45854
45855 /* check if the resource is reserved */
45856 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45857 index 0c52e2a..3421ab7 100644
45858 --- a/drivers/power/pda_power.c
45859 +++ b/drivers/power/pda_power.c
45860 @@ -37,7 +37,11 @@ static int polling;
45861
45862 #if IS_ENABLED(CONFIG_USB_PHY)
45863 static struct usb_phy *transceiver;
45864 -static struct notifier_block otg_nb;
45865 +static int otg_handle_notification(struct notifier_block *nb,
45866 + unsigned long event, void *unused);
45867 +static struct notifier_block otg_nb = {
45868 + .notifier_call = otg_handle_notification
45869 +};
45870 #endif
45871
45872 static struct regulator *ac_draw;
45873 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45874
45875 #if IS_ENABLED(CONFIG_USB_PHY)
45876 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45877 - otg_nb.notifier_call = otg_handle_notification;
45878 ret = usb_register_notifier(transceiver, &otg_nb);
45879 if (ret) {
45880 dev_err(dev, "failure to register otg notifier\n");
45881 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45882 index cc439fd..8fa30df 100644
45883 --- a/drivers/power/power_supply.h
45884 +++ b/drivers/power/power_supply.h
45885 @@ -16,12 +16,12 @@ struct power_supply;
45886
45887 #ifdef CONFIG_SYSFS
45888
45889 -extern void power_supply_init_attrs(struct device_type *dev_type);
45890 +extern void power_supply_init_attrs(void);
45891 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45892
45893 #else
45894
45895 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45896 +static inline void power_supply_init_attrs(void) {}
45897 #define power_supply_uevent NULL
45898
45899 #endif /* CONFIG_SYSFS */
45900 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45901 index 3b2d5df..3207114 100644
45902 --- a/drivers/power/power_supply_core.c
45903 +++ b/drivers/power/power_supply_core.c
45904 @@ -24,7 +24,10 @@
45905 struct class *power_supply_class;
45906 EXPORT_SYMBOL_GPL(power_supply_class);
45907
45908 -static struct device_type power_supply_dev_type;
45909 +extern const struct attribute_group *power_supply_attr_groups[];
45910 +static struct device_type power_supply_dev_type = {
45911 + .groups = power_supply_attr_groups,
45912 +};
45913
45914 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45915 struct power_supply *supply)
45916 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45917 return PTR_ERR(power_supply_class);
45918
45919 power_supply_class->dev_uevent = power_supply_uevent;
45920 - power_supply_init_attrs(&power_supply_dev_type);
45921 + power_supply_init_attrs();
45922
45923 return 0;
45924 }
45925 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45926 index 29178f7..c65f324 100644
45927 --- a/drivers/power/power_supply_sysfs.c
45928 +++ b/drivers/power/power_supply_sysfs.c
45929 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45930 .is_visible = power_supply_attr_is_visible,
45931 };
45932
45933 -static const struct attribute_group *power_supply_attr_groups[] = {
45934 +const struct attribute_group *power_supply_attr_groups[] = {
45935 &power_supply_attr_group,
45936 NULL,
45937 };
45938
45939 -void power_supply_init_attrs(struct device_type *dev_type)
45940 +void power_supply_init_attrs(void)
45941 {
45942 int i;
45943
45944 - dev_type->groups = power_supply_attr_groups;
45945 -
45946 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45947 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45948 }
45949 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45950 index 288c75a..065bc84 100644
45951 --- a/drivers/regulator/core.c
45952 +++ b/drivers/regulator/core.c
45953 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45954 {
45955 const struct regulation_constraints *constraints = NULL;
45956 const struct regulator_init_data *init_data;
45957 - static atomic_t regulator_no = ATOMIC_INIT(0);
45958 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45959 struct regulator_dev *rdev;
45960 struct device *dev;
45961 int ret, i;
45962 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45963 rdev->dev.of_node = config->of_node;
45964 rdev->dev.parent = dev;
45965 dev_set_name(&rdev->dev, "regulator.%d",
45966 - atomic_inc_return(&regulator_no) - 1);
45967 + atomic_inc_return_unchecked(&regulator_no) - 1);
45968 ret = device_register(&rdev->dev);
45969 if (ret != 0) {
45970 put_device(&rdev->dev);
45971 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45972 index d428ef9..fdc0357 100644
45973 --- a/drivers/regulator/max8660.c
45974 +++ b/drivers/regulator/max8660.c
45975 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45976 max8660->shadow_regs[MAX8660_OVER1] = 5;
45977 } else {
45978 /* Otherwise devices can be toggled via software */
45979 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45980 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45981 + pax_open_kernel();
45982 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45983 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45984 + pax_close_kernel();
45985 }
45986
45987 /*
45988 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45989 index 0c5195a..637a453d 100644
45990 --- a/drivers/regulator/max8973-regulator.c
45991 +++ b/drivers/regulator/max8973-regulator.c
45992 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45993 if (!pdata || !pdata->enable_ext_control) {
45994 max->desc.enable_reg = MAX8973_VOUT;
45995 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45996 - max->ops.enable = regulator_enable_regmap;
45997 - max->ops.disable = regulator_disable_regmap;
45998 - max->ops.is_enabled = regulator_is_enabled_regmap;
45999 + pax_open_kernel();
46000 + *(void **)&max->ops.enable = regulator_enable_regmap;
46001 + *(void **)&max->ops.disable = regulator_disable_regmap;
46002 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46003 + pax_close_kernel();
46004 }
46005
46006 if (pdata) {
46007 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46008 index 1037e07..e64dea1 100644
46009 --- a/drivers/regulator/mc13892-regulator.c
46010 +++ b/drivers/regulator/mc13892-regulator.c
46011 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46012 }
46013 mc13xxx_unlock(mc13892);
46014
46015 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46016 + pax_open_kernel();
46017 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46018 = mc13892_vcam_set_mode;
46019 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46020 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46021 = mc13892_vcam_get_mode;
46022 + pax_close_kernel();
46023
46024 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46025 ARRAY_SIZE(mc13892_regulators));
46026 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46027 index be06d71..264aee9 100644
46028 --- a/drivers/rtc/rtc-cmos.c
46029 +++ b/drivers/rtc/rtc-cmos.c
46030 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46031 hpet_rtc_timer_init();
46032
46033 /* export at least the first block of NVRAM */
46034 - nvram.size = address_space - NVRAM_OFFSET;
46035 + pax_open_kernel();
46036 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46037 + pax_close_kernel();
46038 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46039 if (retval < 0) {
46040 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46041 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46042 index d049393..bb20be0 100644
46043 --- a/drivers/rtc/rtc-dev.c
46044 +++ b/drivers/rtc/rtc-dev.c
46045 @@ -16,6 +16,7 @@
46046 #include <linux/module.h>
46047 #include <linux/rtc.h>
46048 #include <linux/sched.h>
46049 +#include <linux/grsecurity.h>
46050 #include "rtc-core.h"
46051
46052 static dev_t rtc_devt;
46053 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46054 if (copy_from_user(&tm, uarg, sizeof(tm)))
46055 return -EFAULT;
46056
46057 + gr_log_timechange();
46058 +
46059 return rtc_set_time(rtc, &tm);
46060
46061 case RTC_PIE_ON:
46062 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46063 index ca18fd1..055e42d 100644
46064 --- a/drivers/rtc/rtc-ds1307.c
46065 +++ b/drivers/rtc/rtc-ds1307.c
46066 @@ -107,7 +107,7 @@ struct ds1307 {
46067 u8 offset; /* register's offset */
46068 u8 regs[11];
46069 u16 nvram_offset;
46070 - struct bin_attribute *nvram;
46071 + bin_attribute_no_const *nvram;
46072 enum ds_type type;
46073 unsigned long flags;
46074 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46075 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46076 index fcb0329..d77b7f2 100644
46077 --- a/drivers/rtc/rtc-m48t59.c
46078 +++ b/drivers/rtc/rtc-m48t59.c
46079 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46080 if (IS_ERR(m48t59->rtc))
46081 return PTR_ERR(m48t59->rtc);
46082
46083 - m48t59_nvram_attr.size = pdata->offset;
46084 + pax_open_kernel();
46085 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46086 + pax_close_kernel();
46087
46088 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46089 if (ret)
46090 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46091 index e693af6..2e525b6 100644
46092 --- a/drivers/scsi/bfa/bfa_fcpim.h
46093 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46094 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46095
46096 struct bfa_itn_s {
46097 bfa_isr_func_t isr;
46098 -};
46099 +} __no_const;
46100
46101 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46102 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46103 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46104 index 90814fe..4384138 100644
46105 --- a/drivers/scsi/bfa/bfa_ioc.h
46106 +++ b/drivers/scsi/bfa/bfa_ioc.h
46107 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46108 bfa_ioc_disable_cbfn_t disable_cbfn;
46109 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46110 bfa_ioc_reset_cbfn_t reset_cbfn;
46111 -};
46112 +} __no_const;
46113
46114 /*
46115 * IOC event notification mechanism.
46116 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46117 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46118 enum bfi_ioc_state fwstate);
46119 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46120 -};
46121 +} __no_const;
46122
46123 /*
46124 * Queue element to wait for room in request queue. FIFO order is
46125 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46126 index c9382d6..6619864 100644
46127 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46128 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46129 @@ -33,8 +33,8 @@
46130 */
46131 #include "libfcoe.h"
46132
46133 -static atomic_t ctlr_num;
46134 -static atomic_t fcf_num;
46135 +static atomic_unchecked_t ctlr_num;
46136 +static atomic_unchecked_t fcf_num;
46137
46138 /*
46139 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46140 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46141 if (!ctlr)
46142 goto out;
46143
46144 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46145 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46146 ctlr->f = f;
46147 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46148 INIT_LIST_HEAD(&ctlr->fcfs);
46149 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46150 fcf->dev.parent = &ctlr->dev;
46151 fcf->dev.bus = &fcoe_bus_type;
46152 fcf->dev.type = &fcoe_fcf_device_type;
46153 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46154 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46155 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46156
46157 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46158 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46159 {
46160 int error;
46161
46162 - atomic_set(&ctlr_num, 0);
46163 - atomic_set(&fcf_num, 0);
46164 + atomic_set_unchecked(&ctlr_num, 0);
46165 + atomic_set_unchecked(&fcf_num, 0);
46166
46167 error = bus_register(&fcoe_bus_type);
46168 if (error)
46169 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46170 index df0c3c7..b00e1d0 100644
46171 --- a/drivers/scsi/hosts.c
46172 +++ b/drivers/scsi/hosts.c
46173 @@ -42,7 +42,7 @@
46174 #include "scsi_logging.h"
46175
46176
46177 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46178 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46179
46180
46181 static void scsi_host_cls_release(struct device *dev)
46182 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46183 * subtract one because we increment first then return, but we need to
46184 * know what the next host number was before increment
46185 */
46186 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46187 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46188 shost->dma_channel = 0xff;
46189
46190 /* These three are default values which can be overridden */
46191 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46192 index 7f4f790..b75b92a 100644
46193 --- a/drivers/scsi/hpsa.c
46194 +++ b/drivers/scsi/hpsa.c
46195 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46196 unsigned long flags;
46197
46198 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46199 - return h->access.command_completed(h, q);
46200 + return h->access->command_completed(h, q);
46201
46202 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46203 a = rq->head[rq->current_entry];
46204 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46205 while (!list_empty(&h->reqQ)) {
46206 c = list_entry(h->reqQ.next, struct CommandList, list);
46207 /* can't do anything if fifo is full */
46208 - if ((h->access.fifo_full(h))) {
46209 + if ((h->access->fifo_full(h))) {
46210 dev_warn(&h->pdev->dev, "fifo full\n");
46211 break;
46212 }
46213 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46214
46215 /* Tell the controller execute command */
46216 spin_unlock_irqrestore(&h->lock, flags);
46217 - h->access.submit_command(h, c);
46218 + h->access->submit_command(h, c);
46219 spin_lock_irqsave(&h->lock, flags);
46220 }
46221 spin_unlock_irqrestore(&h->lock, flags);
46222 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46223
46224 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46225 {
46226 - return h->access.command_completed(h, q);
46227 + return h->access->command_completed(h, q);
46228 }
46229
46230 static inline bool interrupt_pending(struct ctlr_info *h)
46231 {
46232 - return h->access.intr_pending(h);
46233 + return h->access->intr_pending(h);
46234 }
46235
46236 static inline long interrupt_not_for_us(struct ctlr_info *h)
46237 {
46238 - return (h->access.intr_pending(h) == 0) ||
46239 + return (h->access->intr_pending(h) == 0) ||
46240 (h->interrupts_enabled == 0);
46241 }
46242
46243 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46244 if (prod_index < 0)
46245 return -ENODEV;
46246 h->product_name = products[prod_index].product_name;
46247 - h->access = *(products[prod_index].access);
46248 + h->access = products[prod_index].access;
46249
46250 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46251 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46252 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46253
46254 assert_spin_locked(&lockup_detector_lock);
46255 remove_ctlr_from_lockup_detector_list(h);
46256 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46257 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46258 spin_lock_irqsave(&h->lock, flags);
46259 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46260 spin_unlock_irqrestore(&h->lock, flags);
46261 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46262 }
46263
46264 /* make sure the board interrupts are off */
46265 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46266 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46267
46268 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46269 goto clean2;
46270 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46271 * fake ones to scoop up any residual completions.
46272 */
46273 spin_lock_irqsave(&h->lock, flags);
46274 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46275 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46276 spin_unlock_irqrestore(&h->lock, flags);
46277 free_irqs(h);
46278 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46279 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46280 dev_info(&h->pdev->dev, "Board READY.\n");
46281 dev_info(&h->pdev->dev,
46282 "Waiting for stale completions to drain.\n");
46283 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46284 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46285 msleep(10000);
46286 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46287 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46288
46289 rc = controller_reset_failed(h->cfgtable);
46290 if (rc)
46291 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46292 }
46293
46294 /* Turn the interrupts on so we can service requests */
46295 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46296 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46297
46298 hpsa_hba_inquiry(h);
46299 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46300 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46301 * To write all data in the battery backed cache to disks
46302 */
46303 hpsa_flush_cache(h);
46304 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46305 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46306 hpsa_free_irqs_and_disable_msix(h);
46307 }
46308
46309 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46310 return;
46311 }
46312 /* Change the access methods to the performant access methods */
46313 - h->access = SA5_performant_access;
46314 + h->access = &SA5_performant_access;
46315 h->transMethod = CFGTBL_Trans_Performant;
46316 }
46317
46318 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46319 index 9816479..c5d4e97 100644
46320 --- a/drivers/scsi/hpsa.h
46321 +++ b/drivers/scsi/hpsa.h
46322 @@ -79,7 +79,7 @@ struct ctlr_info {
46323 unsigned int msix_vector;
46324 unsigned int msi_vector;
46325 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46326 - struct access_method access;
46327 + struct access_method *access;
46328
46329 /* queue and queue Info */
46330 struct list_head reqQ;
46331 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46332 index 5879929..32b241d 100644
46333 --- a/drivers/scsi/libfc/fc_exch.c
46334 +++ b/drivers/scsi/libfc/fc_exch.c
46335 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46336 u16 pool_max_index;
46337
46338 struct {
46339 - atomic_t no_free_exch;
46340 - atomic_t no_free_exch_xid;
46341 - atomic_t xid_not_found;
46342 - atomic_t xid_busy;
46343 - atomic_t seq_not_found;
46344 - atomic_t non_bls_resp;
46345 + atomic_unchecked_t no_free_exch;
46346 + atomic_unchecked_t no_free_exch_xid;
46347 + atomic_unchecked_t xid_not_found;
46348 + atomic_unchecked_t xid_busy;
46349 + atomic_unchecked_t seq_not_found;
46350 + atomic_unchecked_t non_bls_resp;
46351 } stats;
46352 };
46353
46354 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46355 /* allocate memory for exchange */
46356 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46357 if (!ep) {
46358 - atomic_inc(&mp->stats.no_free_exch);
46359 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46360 goto out;
46361 }
46362 memset(ep, 0, sizeof(*ep));
46363 @@ -797,7 +797,7 @@ out:
46364 return ep;
46365 err:
46366 spin_unlock_bh(&pool->lock);
46367 - atomic_inc(&mp->stats.no_free_exch_xid);
46368 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46369 mempool_free(ep, mp->ep_pool);
46370 return NULL;
46371 }
46372 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46373 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46374 ep = fc_exch_find(mp, xid);
46375 if (!ep) {
46376 - atomic_inc(&mp->stats.xid_not_found);
46377 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46378 reject = FC_RJT_OX_ID;
46379 goto out;
46380 }
46381 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46382 ep = fc_exch_find(mp, xid);
46383 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46384 if (ep) {
46385 - atomic_inc(&mp->stats.xid_busy);
46386 + atomic_inc_unchecked(&mp->stats.xid_busy);
46387 reject = FC_RJT_RX_ID;
46388 goto rel;
46389 }
46390 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46391 }
46392 xid = ep->xid; /* get our XID */
46393 } else if (!ep) {
46394 - atomic_inc(&mp->stats.xid_not_found);
46395 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46396 reject = FC_RJT_RX_ID; /* XID not found */
46397 goto out;
46398 }
46399 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46400 } else {
46401 sp = &ep->seq;
46402 if (sp->id != fh->fh_seq_id) {
46403 - atomic_inc(&mp->stats.seq_not_found);
46404 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46405 if (f_ctl & FC_FC_END_SEQ) {
46406 /*
46407 * Update sequence_id based on incoming last
46408 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46409
46410 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46411 if (!ep) {
46412 - atomic_inc(&mp->stats.xid_not_found);
46413 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46414 goto out;
46415 }
46416 if (ep->esb_stat & ESB_ST_COMPLETE) {
46417 - atomic_inc(&mp->stats.xid_not_found);
46418 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46419 goto rel;
46420 }
46421 if (ep->rxid == FC_XID_UNKNOWN)
46422 ep->rxid = ntohs(fh->fh_rx_id);
46423 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46424 - atomic_inc(&mp->stats.xid_not_found);
46425 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46426 goto rel;
46427 }
46428 if (ep->did != ntoh24(fh->fh_s_id) &&
46429 ep->did != FC_FID_FLOGI) {
46430 - atomic_inc(&mp->stats.xid_not_found);
46431 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46432 goto rel;
46433 }
46434 sof = fr_sof(fp);
46435 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46436 sp->ssb_stat |= SSB_ST_RESP;
46437 sp->id = fh->fh_seq_id;
46438 } else if (sp->id != fh->fh_seq_id) {
46439 - atomic_inc(&mp->stats.seq_not_found);
46440 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46441 goto rel;
46442 }
46443
46444 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46445 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46446
46447 if (!sp)
46448 - atomic_inc(&mp->stats.xid_not_found);
46449 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46450 else
46451 - atomic_inc(&mp->stats.non_bls_resp);
46452 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46453
46454 fc_frame_free(fp);
46455 }
46456 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46457
46458 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46459 mp = ema->mp;
46460 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46461 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46462 st->fc_no_free_exch_xid +=
46463 - atomic_read(&mp->stats.no_free_exch_xid);
46464 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46465 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46466 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46467 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46468 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46469 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46470 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46471 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46472 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46473 }
46474 }
46475 EXPORT_SYMBOL(fc_exch_update_stats);
46476 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46477 index 161c98e..6d563b3 100644
46478 --- a/drivers/scsi/libsas/sas_ata.c
46479 +++ b/drivers/scsi/libsas/sas_ata.c
46480 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46481 .postreset = ata_std_postreset,
46482 .error_handler = ata_std_error_handler,
46483 .post_internal_cmd = sas_ata_post_internal,
46484 - .qc_defer = ata_std_qc_defer,
46485 + .qc_defer = ata_std_qc_defer,
46486 .qc_prep = ata_noop_qc_prep,
46487 .qc_issue = sas_ata_qc_issue,
46488 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46489 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46490 index 93f222d..73e977b 100644
46491 --- a/drivers/scsi/lpfc/lpfc.h
46492 +++ b/drivers/scsi/lpfc/lpfc.h
46493 @@ -431,7 +431,7 @@ struct lpfc_vport {
46494 struct dentry *debug_nodelist;
46495 struct dentry *vport_debugfs_root;
46496 struct lpfc_debugfs_trc *disc_trc;
46497 - atomic_t disc_trc_cnt;
46498 + atomic_unchecked_t disc_trc_cnt;
46499 #endif
46500 uint8_t stat_data_enabled;
46501 uint8_t stat_data_blocked;
46502 @@ -865,8 +865,8 @@ struct lpfc_hba {
46503 struct timer_list fabric_block_timer;
46504 unsigned long bit_flags;
46505 #define FABRIC_COMANDS_BLOCKED 0
46506 - atomic_t num_rsrc_err;
46507 - atomic_t num_cmd_success;
46508 + atomic_unchecked_t num_rsrc_err;
46509 + atomic_unchecked_t num_cmd_success;
46510 unsigned long last_rsrc_error_time;
46511 unsigned long last_ramp_down_time;
46512 unsigned long last_ramp_up_time;
46513 @@ -902,7 +902,7 @@ struct lpfc_hba {
46514
46515 struct dentry *debug_slow_ring_trc;
46516 struct lpfc_debugfs_trc *slow_ring_trc;
46517 - atomic_t slow_ring_trc_cnt;
46518 + atomic_unchecked_t slow_ring_trc_cnt;
46519 /* iDiag debugfs sub-directory */
46520 struct dentry *idiag_root;
46521 struct dentry *idiag_pci_cfg;
46522 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46523 index 60084e6..0e2e700 100644
46524 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46525 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46526 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46527
46528 #include <linux/debugfs.h>
46529
46530 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46531 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46532 static unsigned long lpfc_debugfs_start_time = 0L;
46533
46534 /* iDiag */
46535 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46536 lpfc_debugfs_enable = 0;
46537
46538 len = 0;
46539 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46540 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46541 (lpfc_debugfs_max_disc_trc - 1);
46542 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46543 dtp = vport->disc_trc + i;
46544 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46545 lpfc_debugfs_enable = 0;
46546
46547 len = 0;
46548 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46549 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46550 (lpfc_debugfs_max_slow_ring_trc - 1);
46551 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46552 dtp = phba->slow_ring_trc + i;
46553 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46554 !vport || !vport->disc_trc)
46555 return;
46556
46557 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46558 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46559 (lpfc_debugfs_max_disc_trc - 1);
46560 dtp = vport->disc_trc + index;
46561 dtp->fmt = fmt;
46562 dtp->data1 = data1;
46563 dtp->data2 = data2;
46564 dtp->data3 = data3;
46565 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46566 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46567 dtp->jif = jiffies;
46568 #endif
46569 return;
46570 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46571 !phba || !phba->slow_ring_trc)
46572 return;
46573
46574 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46575 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46576 (lpfc_debugfs_max_slow_ring_trc - 1);
46577 dtp = phba->slow_ring_trc + index;
46578 dtp->fmt = fmt;
46579 dtp->data1 = data1;
46580 dtp->data2 = data2;
46581 dtp->data3 = data3;
46582 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46583 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46584 dtp->jif = jiffies;
46585 #endif
46586 return;
46587 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46588 "slow_ring buffer\n");
46589 goto debug_failed;
46590 }
46591 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46592 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46593 memset(phba->slow_ring_trc, 0,
46594 (sizeof(struct lpfc_debugfs_trc) *
46595 lpfc_debugfs_max_slow_ring_trc));
46596 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46597 "buffer\n");
46598 goto debug_failed;
46599 }
46600 - atomic_set(&vport->disc_trc_cnt, 0);
46601 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46602
46603 snprintf(name, sizeof(name), "discovery_trace");
46604 vport->debug_disc_trc =
46605 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46606 index e0b20fa..30c2c0d 100644
46607 --- a/drivers/scsi/lpfc/lpfc_init.c
46608 +++ b/drivers/scsi/lpfc/lpfc_init.c
46609 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46610 "misc_register returned with status %d", error);
46611
46612 if (lpfc_enable_npiv) {
46613 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46614 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46615 + pax_open_kernel();
46616 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46617 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46618 + pax_close_kernel();
46619 }
46620 lpfc_transport_template =
46621 fc_attach_transport(&lpfc_transport_functions);
46622 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46623 index 243de1d..f40e3e5 100644
46624 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46625 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46626 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46627 uint32_t evt_posted;
46628
46629 spin_lock_irqsave(&phba->hbalock, flags);
46630 - atomic_inc(&phba->num_rsrc_err);
46631 + atomic_inc_unchecked(&phba->num_rsrc_err);
46632 phba->last_rsrc_error_time = jiffies;
46633
46634 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46635 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46636 unsigned long flags;
46637 struct lpfc_hba *phba = vport->phba;
46638 uint32_t evt_posted;
46639 - atomic_inc(&phba->num_cmd_success);
46640 + atomic_inc_unchecked(&phba->num_cmd_success);
46641
46642 if (vport->cfg_lun_queue_depth <= queue_depth)
46643 return;
46644 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46645 unsigned long num_rsrc_err, num_cmd_success;
46646 int i;
46647
46648 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46649 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46650 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46651 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46652
46653 /*
46654 * The error and success command counters are global per
46655 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46656 }
46657 }
46658 lpfc_destroy_vport_work_array(phba, vports);
46659 - atomic_set(&phba->num_rsrc_err, 0);
46660 - atomic_set(&phba->num_cmd_success, 0);
46661 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46662 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46663 }
46664
46665 /**
46666 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46667 }
46668 }
46669 lpfc_destroy_vport_work_array(phba, vports);
46670 - atomic_set(&phba->num_rsrc_err, 0);
46671 - atomic_set(&phba->num_cmd_success, 0);
46672 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46673 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46674 }
46675
46676 /**
46677 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46678 index 1eb7b028..b2a6080 100644
46679 --- a/drivers/scsi/pmcraid.c
46680 +++ b/drivers/scsi/pmcraid.c
46681 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46682 res->scsi_dev = scsi_dev;
46683 scsi_dev->hostdata = res;
46684 res->change_detected = 0;
46685 - atomic_set(&res->read_failures, 0);
46686 - atomic_set(&res->write_failures, 0);
46687 + atomic_set_unchecked(&res->read_failures, 0);
46688 + atomic_set_unchecked(&res->write_failures, 0);
46689 rc = 0;
46690 }
46691 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46692 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46693
46694 /* If this was a SCSI read/write command keep count of errors */
46695 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46696 - atomic_inc(&res->read_failures);
46697 + atomic_inc_unchecked(&res->read_failures);
46698 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46699 - atomic_inc(&res->write_failures);
46700 + atomic_inc_unchecked(&res->write_failures);
46701
46702 if (!RES_IS_GSCSI(res->cfg_entry) &&
46703 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46704 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46705 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46706 * hrrq_id assigned here in queuecommand
46707 */
46708 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46709 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46710 pinstance->num_hrrq;
46711 cmd->cmd_done = pmcraid_io_done;
46712
46713 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46714 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46715 * hrrq_id assigned here in queuecommand
46716 */
46717 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46718 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46719 pinstance->num_hrrq;
46720
46721 if (request_size) {
46722 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46723
46724 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46725 /* add resources only after host is added into system */
46726 - if (!atomic_read(&pinstance->expose_resources))
46727 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46728 return;
46729
46730 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46731 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46732 init_waitqueue_head(&pinstance->reset_wait_q);
46733
46734 atomic_set(&pinstance->outstanding_cmds, 0);
46735 - atomic_set(&pinstance->last_message_id, 0);
46736 - atomic_set(&pinstance->expose_resources, 0);
46737 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46738 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46739
46740 INIT_LIST_HEAD(&pinstance->free_res_q);
46741 INIT_LIST_HEAD(&pinstance->used_res_q);
46742 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46743 /* Schedule worker thread to handle CCN and take care of adding and
46744 * removing devices to OS
46745 */
46746 - atomic_set(&pinstance->expose_resources, 1);
46747 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46748 schedule_work(&pinstance->worker_q);
46749 return rc;
46750
46751 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46752 index e1d150f..6c6df44 100644
46753 --- a/drivers/scsi/pmcraid.h
46754 +++ b/drivers/scsi/pmcraid.h
46755 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46756 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46757
46758 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46759 - atomic_t last_message_id;
46760 + atomic_unchecked_t last_message_id;
46761
46762 /* configuration table */
46763 struct pmcraid_config_table *cfg_table;
46764 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46765 atomic_t outstanding_cmds;
46766
46767 /* should add/delete resources to mid-layer now ?*/
46768 - atomic_t expose_resources;
46769 + atomic_unchecked_t expose_resources;
46770
46771
46772
46773 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46774 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46775 };
46776 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46777 - atomic_t read_failures; /* count of failed READ commands */
46778 - atomic_t write_failures; /* count of failed WRITE commands */
46779 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46780 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46781
46782 /* To indicate add/delete/modify during CCN */
46783 u8 change_detected;
46784 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46785 index d7a99ae..801df70 100644
46786 --- a/drivers/scsi/qla2xxx/qla_attr.c
46787 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46788 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46789 return 0;
46790 }
46791
46792 -struct fc_function_template qla2xxx_transport_functions = {
46793 +fc_function_template_no_const qla2xxx_transport_functions = {
46794
46795 .show_host_node_name = 1,
46796 .show_host_port_name = 1,
46797 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46798 .bsg_timeout = qla24xx_bsg_timeout,
46799 };
46800
46801 -struct fc_function_template qla2xxx_transport_vport_functions = {
46802 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46803
46804 .show_host_node_name = 1,
46805 .show_host_port_name = 1,
46806 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46807 index 2d98232..a84298e 100644
46808 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46809 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46810 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46811 struct device_attribute;
46812 extern struct device_attribute *qla2x00_host_attrs[];
46813 struct fc_function_template;
46814 -extern struct fc_function_template qla2xxx_transport_functions;
46815 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46816 +extern fc_function_template_no_const qla2xxx_transport_functions;
46817 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46818 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46819 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46820 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46821 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46822 index 3e21e9f..426ba79 100644
46823 --- a/drivers/scsi/qla2xxx/qla_os.c
46824 +++ b/drivers/scsi/qla2xxx/qla_os.c
46825 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46826 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46827 /* Ok, a 64bit DMA mask is applicable. */
46828 ha->flags.enable_64bit_addressing = 1;
46829 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46830 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46831 + pax_open_kernel();
46832 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46833 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46834 + pax_close_kernel();
46835 return;
46836 }
46837 }
46838 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46839 index ddf16a8..80f4dd0 100644
46840 --- a/drivers/scsi/qla4xxx/ql4_def.h
46841 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46842 @@ -291,7 +291,7 @@ struct ddb_entry {
46843 * (4000 only) */
46844 atomic_t relogin_timer; /* Max Time to wait for
46845 * relogin to complete */
46846 - atomic_t relogin_retry_count; /* Num of times relogin has been
46847 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46848 * retried */
46849 uint32_t default_time2wait; /* Default Min time between
46850 * relogins (+aens) */
46851 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46852 index b246b3c..897004d 100644
46853 --- a/drivers/scsi/qla4xxx/ql4_os.c
46854 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46855 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46856 */
46857 if (!iscsi_is_session_online(cls_sess)) {
46858 /* Reset retry relogin timer */
46859 - atomic_inc(&ddb_entry->relogin_retry_count);
46860 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46861 DEBUG2(ql4_printk(KERN_INFO, ha,
46862 "%s: index[%d] relogin timed out-retrying"
46863 " relogin (%d), retry (%d)\n", __func__,
46864 ddb_entry->fw_ddb_index,
46865 - atomic_read(&ddb_entry->relogin_retry_count),
46866 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46867 ddb_entry->default_time2wait + 4));
46868 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46869 atomic_set(&ddb_entry->retry_relogin_timer,
46870 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46871
46872 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46873 atomic_set(&ddb_entry->relogin_timer, 0);
46874 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46875 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46876 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46877 ddb_entry->default_relogin_timeout =
46878 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46879 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46880 index eaa808e..95f8841 100644
46881 --- a/drivers/scsi/scsi.c
46882 +++ b/drivers/scsi/scsi.c
46883 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46884 unsigned long timeout;
46885 int rtn = 0;
46886
46887 - atomic_inc(&cmd->device->iorequest_cnt);
46888 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46889
46890 /* check if the device is still usable */
46891 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46892 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46893 index 124392f..75eb43e 100644
46894 --- a/drivers/scsi/scsi_lib.c
46895 +++ b/drivers/scsi/scsi_lib.c
46896 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46897 shost = sdev->host;
46898 scsi_init_cmd_errh(cmd);
46899 cmd->result = DID_NO_CONNECT << 16;
46900 - atomic_inc(&cmd->device->iorequest_cnt);
46901 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46902
46903 /*
46904 * SCSI request completion path will do scsi_device_unbusy(),
46905 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46906
46907 INIT_LIST_HEAD(&cmd->eh_entry);
46908
46909 - atomic_inc(&cmd->device->iodone_cnt);
46910 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46911 if (cmd->result)
46912 - atomic_inc(&cmd->device->ioerr_cnt);
46913 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46914
46915 disposition = scsi_decide_disposition(cmd);
46916 if (disposition != SUCCESS &&
46917 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46918 index 7e50061..71db7a6 100644
46919 --- a/drivers/scsi/scsi_sysfs.c
46920 +++ b/drivers/scsi/scsi_sysfs.c
46921 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46922 char *buf) \
46923 { \
46924 struct scsi_device *sdev = to_scsi_device(dev); \
46925 - unsigned long long count = atomic_read(&sdev->field); \
46926 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46927 return snprintf(buf, 20, "0x%llx\n", count); \
46928 } \
46929 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46930 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46931 index 84a1fdf..693b0d6 100644
46932 --- a/drivers/scsi/scsi_tgt_lib.c
46933 +++ b/drivers/scsi/scsi_tgt_lib.c
46934 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46935 int err;
46936
46937 dprintk("%lx %u\n", uaddr, len);
46938 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46939 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46940 if (err) {
46941 /*
46942 * TODO: need to fixup sg_tablesize, max_segment_size,
46943 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46944 index 4628fd5..a94a1c2 100644
46945 --- a/drivers/scsi/scsi_transport_fc.c
46946 +++ b/drivers/scsi/scsi_transport_fc.c
46947 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46948 * Netlink Infrastructure
46949 */
46950
46951 -static atomic_t fc_event_seq;
46952 +static atomic_unchecked_t fc_event_seq;
46953
46954 /**
46955 * fc_get_event_number - Obtain the next sequential FC event number
46956 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46957 u32
46958 fc_get_event_number(void)
46959 {
46960 - return atomic_add_return(1, &fc_event_seq);
46961 + return atomic_add_return_unchecked(1, &fc_event_seq);
46962 }
46963 EXPORT_SYMBOL(fc_get_event_number);
46964
46965 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46966 {
46967 int error;
46968
46969 - atomic_set(&fc_event_seq, 0);
46970 + atomic_set_unchecked(&fc_event_seq, 0);
46971
46972 error = transport_class_register(&fc_host_class);
46973 if (error)
46974 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46975 char *cp;
46976
46977 *val = simple_strtoul(buf, &cp, 0);
46978 - if ((*cp && (*cp != '\n')) || (*val < 0))
46979 + if (*cp && (*cp != '\n'))
46980 return -EINVAL;
46981 /*
46982 * Check for overflow; dev_loss_tmo is u32
46983 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46984 index abf7c40..c3240ed 100644
46985 --- a/drivers/scsi/scsi_transport_iscsi.c
46986 +++ b/drivers/scsi/scsi_transport_iscsi.c
46987 @@ -80,7 +80,7 @@ struct iscsi_internal {
46988 struct transport_container session_cont;
46989 };
46990
46991 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
46992 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
46993 static struct workqueue_struct *iscsi_eh_timer_workq;
46994
46995 static DEFINE_IDA(iscsi_sess_ida);
46996 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
46997 int err;
46998
46999 ihost = shost->shost_data;
47000 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47001 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47002
47003 if (target_id == ISCSI_MAX_TARGET) {
47004 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47005 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47006 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47007 ISCSI_TRANSPORT_VERSION);
47008
47009 - atomic_set(&iscsi_session_nr, 0);
47010 + atomic_set_unchecked(&iscsi_session_nr, 0);
47011
47012 err = class_register(&iscsi_transport_class);
47013 if (err)
47014 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47015 index f379c7f..e8fc69c 100644
47016 --- a/drivers/scsi/scsi_transport_srp.c
47017 +++ b/drivers/scsi/scsi_transport_srp.c
47018 @@ -33,7 +33,7 @@
47019 #include "scsi_transport_srp_internal.h"
47020
47021 struct srp_host_attrs {
47022 - atomic_t next_port_id;
47023 + atomic_unchecked_t next_port_id;
47024 };
47025 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47026
47027 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47028 struct Scsi_Host *shost = dev_to_shost(dev);
47029 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47030
47031 - atomic_set(&srp_host->next_port_id, 0);
47032 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47033 return 0;
47034 }
47035
47036 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47037 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47038 rport->roles = ids->roles;
47039
47040 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47041 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47042 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47043
47044 transport_setup_device(&rport->dev);
47045 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47046 index 2783dd7..d20395b 100644
47047 --- a/drivers/scsi/sd.c
47048 +++ b/drivers/scsi/sd.c
47049 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47050 sdkp->disk = gd;
47051 sdkp->index = index;
47052 atomic_set(&sdkp->openers, 0);
47053 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47054 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47055
47056 if (!sdp->request_queue->rq_timeout) {
47057 if (sdp->type != TYPE_MOD)
47058 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47059 index df5e961..df6b97f 100644
47060 --- a/drivers/scsi/sg.c
47061 +++ b/drivers/scsi/sg.c
47062 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47063 sdp->disk->disk_name,
47064 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47065 NULL,
47066 - (char *)arg);
47067 + (char __user *)arg);
47068 case BLKTRACESTART:
47069 return blk_trace_startstop(sdp->device->request_queue, 1);
47070 case BLKTRACESTOP:
47071 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47072 index 978dda2..cb19aa0 100644
47073 --- a/drivers/spi/spi.c
47074 +++ b/drivers/spi/spi.c
47075 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47076 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47077
47078 /* portable code must never pass more than 32 bytes */
47079 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47080 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47081
47082 static u8 *buf;
47083
47084 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47085 index ee3a57f..18368c1 100644
47086 --- a/drivers/staging/android/timed_output.c
47087 +++ b/drivers/staging/android/timed_output.c
47088 @@ -25,7 +25,7 @@
47089 #include "timed_output.h"
47090
47091 static struct class *timed_output_class;
47092 -static atomic_t device_count;
47093 +static atomic_unchecked_t device_count;
47094
47095 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47096 char *buf)
47097 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47098 timed_output_class = class_create(THIS_MODULE, "timed_output");
47099 if (IS_ERR(timed_output_class))
47100 return PTR_ERR(timed_output_class);
47101 - atomic_set(&device_count, 0);
47102 + atomic_set_unchecked(&device_count, 0);
47103 }
47104
47105 return 0;
47106 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47107 if (ret < 0)
47108 return ret;
47109
47110 - tdev->index = atomic_inc_return(&device_count);
47111 + tdev->index = atomic_inc_return_unchecked(&device_count);
47112 tdev->dev = device_create(timed_output_class, NULL,
47113 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47114 if (IS_ERR(tdev->dev))
47115 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47116 index 3675020..e80d92c 100644
47117 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47118 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47119 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47120
47121 static int solo_sysfs_init(struct solo_dev *solo_dev)
47122 {
47123 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47124 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47125 struct device *dev = &solo_dev->dev;
47126 const char *driver;
47127 int i;
47128 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47129 index 3335941..2b26186 100644
47130 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47131 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47132 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47133
47134 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47135 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47136 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47137 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47138 if (p2m_id < 0)
47139 p2m_id = -p2m_id;
47140 }
47141 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47142 index 6f91d2e..3f011d2 100644
47143 --- a/drivers/staging/media/solo6x10/solo6x10.h
47144 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47145 @@ -238,7 +238,7 @@ struct solo_dev {
47146
47147 /* P2M DMA Engine */
47148 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47149 - atomic_t p2m_count;
47150 + atomic_unchecked_t p2m_count;
47151 int p2m_jiffies;
47152 unsigned int p2m_timeouts;
47153
47154 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47155 index 34afc16..ffe44dd 100644
47156 --- a/drivers/staging/octeon/ethernet-rx.c
47157 +++ b/drivers/staging/octeon/ethernet-rx.c
47158 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47159 /* Increment RX stats for virtual ports */
47160 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47161 #ifdef CONFIG_64BIT
47162 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47163 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47164 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47165 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47166 #else
47167 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47168 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47169 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47170 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47171 #endif
47172 }
47173 netif_receive_skb(skb);
47174 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47175 dev->name);
47176 */
47177 #ifdef CONFIG_64BIT
47178 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47179 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47180 #else
47181 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47182 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47183 #endif
47184 dev_kfree_skb_irq(skb);
47185 }
47186 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47187 index c3a90e7..023619a 100644
47188 --- a/drivers/staging/octeon/ethernet.c
47189 +++ b/drivers/staging/octeon/ethernet.c
47190 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47191 * since the RX tasklet also increments it.
47192 */
47193 #ifdef CONFIG_64BIT
47194 - atomic64_add(rx_status.dropped_packets,
47195 - (atomic64_t *)&priv->stats.rx_dropped);
47196 + atomic64_add_unchecked(rx_status.dropped_packets,
47197 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47198 #else
47199 - atomic_add(rx_status.dropped_packets,
47200 - (atomic_t *)&priv->stats.rx_dropped);
47201 + atomic_add_unchecked(rx_status.dropped_packets,
47202 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47203 #endif
47204 }
47205
47206 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47207 index dc23395..cf7e9b1 100644
47208 --- a/drivers/staging/rtl8712/rtl871x_io.h
47209 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47210 @@ -108,7 +108,7 @@ struct _io_ops {
47211 u8 *pmem);
47212 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47213 u8 *pmem);
47214 -};
47215 +} __no_const;
47216
47217 struct io_req {
47218 struct list_head list;
47219 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47220 index 1f5088b..0e59820 100644
47221 --- a/drivers/staging/sbe-2t3e3/netdev.c
47222 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47223 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47224 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47225
47226 if (rlen)
47227 - if (copy_to_user(data, &resp, rlen))
47228 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47229 return -EFAULT;
47230
47231 return 0;
47232 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47233 index a863a98..d272795 100644
47234 --- a/drivers/staging/usbip/vhci.h
47235 +++ b/drivers/staging/usbip/vhci.h
47236 @@ -83,7 +83,7 @@ struct vhci_hcd {
47237 unsigned resuming:1;
47238 unsigned long re_timeout;
47239
47240 - atomic_t seqnum;
47241 + atomic_unchecked_t seqnum;
47242
47243 /*
47244 * NOTE:
47245 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47246 index d7974cb..d78076b 100644
47247 --- a/drivers/staging/usbip/vhci_hcd.c
47248 +++ b/drivers/staging/usbip/vhci_hcd.c
47249 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47250
47251 spin_lock(&vdev->priv_lock);
47252
47253 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47254 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47255 if (priv->seqnum == 0xffff)
47256 dev_info(&urb->dev->dev, "seqnum max\n");
47257
47258 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47259 return -ENOMEM;
47260 }
47261
47262 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47263 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47264 if (unlink->seqnum == 0xffff)
47265 pr_info("seqnum max\n");
47266
47267 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47268 vdev->rhport = rhport;
47269 }
47270
47271 - atomic_set(&vhci->seqnum, 0);
47272 + atomic_set_unchecked(&vhci->seqnum, 0);
47273 spin_lock_init(&vhci->lock);
47274
47275 hcd->power_budget = 0; /* no limit */
47276 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47277 index d07fcb5..358e1e1 100644
47278 --- a/drivers/staging/usbip/vhci_rx.c
47279 +++ b/drivers/staging/usbip/vhci_rx.c
47280 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47281 if (!urb) {
47282 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47283 pr_info("max seqnum %d\n",
47284 - atomic_read(&the_controller->seqnum));
47285 + atomic_read_unchecked(&the_controller->seqnum));
47286 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47287 return;
47288 }
47289 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47290 index 57a08c5..5b4bb7c 100644
47291 --- a/drivers/staging/vt6655/hostap.c
47292 +++ b/drivers/staging/vt6655/hostap.c
47293 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47294 *
47295 */
47296
47297 +static net_device_ops_no_const apdev_netdev_ops;
47298 +
47299 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47300 {
47301 PSDevice apdev_priv;
47302 struct net_device *dev = pDevice->dev;
47303 int ret;
47304 - const struct net_device_ops apdev_netdev_ops = {
47305 - .ndo_start_xmit = pDevice->tx_80211,
47306 - };
47307
47308 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47309
47310 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47311 *apdev_priv = *pDevice;
47312 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47313
47314 + /* only half broken now */
47315 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47316 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47317
47318 pDevice->apdev->type = ARPHRD_IEEE80211;
47319 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47320 index c699a30..b90a5fd 100644
47321 --- a/drivers/staging/vt6656/hostap.c
47322 +++ b/drivers/staging/vt6656/hostap.c
47323 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47324 *
47325 */
47326
47327 +static net_device_ops_no_const apdev_netdev_ops;
47328 +
47329 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47330 {
47331 struct vnt_private *apdev_priv;
47332 struct net_device *dev = pDevice->dev;
47333 int ret;
47334 - const struct net_device_ops apdev_netdev_ops = {
47335 - .ndo_start_xmit = pDevice->tx_80211,
47336 - };
47337
47338 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47339
47340 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47341 *apdev_priv = *pDevice;
47342 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47343
47344 + /* only half broken now */
47345 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47346 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47347
47348 pDevice->apdev->type = ARPHRD_IEEE80211;
47349 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47350 index d128ce2..fc1f9a1 100644
47351 --- a/drivers/staging/zcache/tmem.h
47352 +++ b/drivers/staging/zcache/tmem.h
47353 @@ -225,7 +225,7 @@ struct tmem_pamops {
47354 bool (*is_remote)(void *);
47355 int (*replace_in_obj)(void *, struct tmem_obj *);
47356 #endif
47357 -};
47358 +} __no_const;
47359 extern void tmem_register_pamops(struct tmem_pamops *m);
47360
47361 /* memory allocation methods provided by the host implementation */
47362 @@ -234,7 +234,7 @@ struct tmem_hostops {
47363 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47364 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47365 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47366 -};
47367 +} __no_const;
47368 extern void tmem_register_hostops(struct tmem_hostops *m);
47369
47370 /* core tmem accessor functions */
47371 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47372 index e51b09a..5ebac31 100644
47373 --- a/drivers/target/sbp/sbp_target.c
47374 +++ b/drivers/target/sbp/sbp_target.c
47375 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47376
47377 #define SESSION_MAINTENANCE_INTERVAL HZ
47378
47379 -static atomic_t login_id = ATOMIC_INIT(0);
47380 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47381
47382 static void session_maintenance_work(struct work_struct *);
47383 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47384 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47385 login->lun = se_lun;
47386 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47387 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47388 - login->login_id = atomic_inc_return(&login_id);
47389 + login->login_id = atomic_inc_return_unchecked(&login_id);
47390
47391 login->tgt_agt = sbp_target_agent_register(login);
47392 if (IS_ERR(login->tgt_agt)) {
47393 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47394 index 8f4142f..b127f7d 100644
47395 --- a/drivers/target/target_core_device.c
47396 +++ b/drivers/target/target_core_device.c
47397 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47398 spin_lock_init(&dev->se_port_lock);
47399 spin_lock_init(&dev->se_tmr_lock);
47400 spin_lock_init(&dev->qf_cmd_lock);
47401 - atomic_set(&dev->dev_ordered_id, 0);
47402 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47403 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47404 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47405 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47406 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47407 index d8e49d7..6fcfdec 100644
47408 --- a/drivers/target/target_core_transport.c
47409 +++ b/drivers/target/target_core_transport.c
47410 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47411 * Used to determine when ORDERED commands should go from
47412 * Dormant to Active status.
47413 */
47414 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47415 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47416 smp_mb__after_atomic_inc();
47417 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47418 cmd->se_ordered_id, cmd->sam_task_attr,
47419 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47420 index 33f83fe..d80f8e1 100644
47421 --- a/drivers/tty/cyclades.c
47422 +++ b/drivers/tty/cyclades.c
47423 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47424 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47425 info->port.count);
47426 #endif
47427 - info->port.count++;
47428 + atomic_inc(&info->port.count);
47429 #ifdef CY_DEBUG_COUNT
47430 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47431 - current->pid, info->port.count);
47432 + current->pid, atomic_read(&info->port.count));
47433 #endif
47434
47435 /*
47436 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47437 for (j = 0; j < cy_card[i].nports; j++) {
47438 info = &cy_card[i].ports[j];
47439
47440 - if (info->port.count) {
47441 + if (atomic_read(&info->port.count)) {
47442 /* XXX is the ldisc num worth this? */
47443 struct tty_struct *tty;
47444 struct tty_ldisc *ld;
47445 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47446 index eb255e8..f637a57 100644
47447 --- a/drivers/tty/hvc/hvc_console.c
47448 +++ b/drivers/tty/hvc/hvc_console.c
47449 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47450
47451 spin_lock_irqsave(&hp->port.lock, flags);
47452 /* Check and then increment for fast path open. */
47453 - if (hp->port.count++ > 0) {
47454 + if (atomic_inc_return(&hp->port.count) > 1) {
47455 spin_unlock_irqrestore(&hp->port.lock, flags);
47456 hvc_kick();
47457 return 0;
47458 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47459
47460 spin_lock_irqsave(&hp->port.lock, flags);
47461
47462 - if (--hp->port.count == 0) {
47463 + if (atomic_dec_return(&hp->port.count) == 0) {
47464 spin_unlock_irqrestore(&hp->port.lock, flags);
47465 /* We are done with the tty pointer now. */
47466 tty_port_tty_set(&hp->port, NULL);
47467 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47468 */
47469 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47470 } else {
47471 - if (hp->port.count < 0)
47472 + if (atomic_read(&hp->port.count) < 0)
47473 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47474 - hp->vtermno, hp->port.count);
47475 + hp->vtermno, atomic_read(&hp->port.count));
47476 spin_unlock_irqrestore(&hp->port.lock, flags);
47477 }
47478 }
47479 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47480 * open->hangup case this can be called after the final close so prevent
47481 * that from happening for now.
47482 */
47483 - if (hp->port.count <= 0) {
47484 + if (atomic_read(&hp->port.count) <= 0) {
47485 spin_unlock_irqrestore(&hp->port.lock, flags);
47486 return;
47487 }
47488
47489 - hp->port.count = 0;
47490 + atomic_set(&hp->port.count, 0);
47491 spin_unlock_irqrestore(&hp->port.lock, flags);
47492 tty_port_tty_set(&hp->port, NULL);
47493
47494 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47495 return -EPIPE;
47496
47497 /* FIXME what's this (unprotected) check for? */
47498 - if (hp->port.count <= 0)
47499 + if (atomic_read(&hp->port.count) <= 0)
47500 return -EIO;
47501
47502 spin_lock_irqsave(&hp->lock, flags);
47503 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47504 index 81e939e..95ead10 100644
47505 --- a/drivers/tty/hvc/hvcs.c
47506 +++ b/drivers/tty/hvc/hvcs.c
47507 @@ -83,6 +83,7 @@
47508 #include <asm/hvcserver.h>
47509 #include <asm/uaccess.h>
47510 #include <asm/vio.h>
47511 +#include <asm/local.h>
47512
47513 /*
47514 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47515 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47516
47517 spin_lock_irqsave(&hvcsd->lock, flags);
47518
47519 - if (hvcsd->port.count > 0) {
47520 + if (atomic_read(&hvcsd->port.count) > 0) {
47521 spin_unlock_irqrestore(&hvcsd->lock, flags);
47522 printk(KERN_INFO "HVCS: vterm state unchanged. "
47523 "The hvcs device node is still in use.\n");
47524 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47525 }
47526 }
47527
47528 - hvcsd->port.count = 0;
47529 + atomic_set(&hvcsd->port.count, 0);
47530 hvcsd->port.tty = tty;
47531 tty->driver_data = hvcsd;
47532
47533 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47534 unsigned long flags;
47535
47536 spin_lock_irqsave(&hvcsd->lock, flags);
47537 - hvcsd->port.count++;
47538 + atomic_inc(&hvcsd->port.count);
47539 hvcsd->todo_mask |= HVCS_SCHED_READ;
47540 spin_unlock_irqrestore(&hvcsd->lock, flags);
47541
47542 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47543 hvcsd = tty->driver_data;
47544
47545 spin_lock_irqsave(&hvcsd->lock, flags);
47546 - if (--hvcsd->port.count == 0) {
47547 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47548
47549 vio_disable_interrupts(hvcsd->vdev);
47550
47551 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47552
47553 free_irq(irq, hvcsd);
47554 return;
47555 - } else if (hvcsd->port.count < 0) {
47556 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47557 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47558 " is missmanaged.\n",
47559 - hvcsd->vdev->unit_address, hvcsd->port.count);
47560 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47561 }
47562
47563 spin_unlock_irqrestore(&hvcsd->lock, flags);
47564 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47565
47566 spin_lock_irqsave(&hvcsd->lock, flags);
47567 /* Preserve this so that we know how many kref refs to put */
47568 - temp_open_count = hvcsd->port.count;
47569 + temp_open_count = atomic_read(&hvcsd->port.count);
47570
47571 /*
47572 * Don't kref put inside the spinlock because the destruction
47573 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47574 tty->driver_data = NULL;
47575 hvcsd->port.tty = NULL;
47576
47577 - hvcsd->port.count = 0;
47578 + atomic_set(&hvcsd->port.count, 0);
47579
47580 /* This will drop any buffered data on the floor which is OK in a hangup
47581 * scenario. */
47582 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47583 * the middle of a write operation? This is a crummy place to do this
47584 * but we want to keep it all in the spinlock.
47585 */
47586 - if (hvcsd->port.count <= 0) {
47587 + if (atomic_read(&hvcsd->port.count) <= 0) {
47588 spin_unlock_irqrestore(&hvcsd->lock, flags);
47589 return -ENODEV;
47590 }
47591 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47592 {
47593 struct hvcs_struct *hvcsd = tty->driver_data;
47594
47595 - if (!hvcsd || hvcsd->port.count <= 0)
47596 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47597 return 0;
47598
47599 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47600 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47601 index 4190199..48f2920 100644
47602 --- a/drivers/tty/hvc/hvsi.c
47603 +++ b/drivers/tty/hvc/hvsi.c
47604 @@ -85,7 +85,7 @@ struct hvsi_struct {
47605 int n_outbuf;
47606 uint32_t vtermno;
47607 uint32_t virq;
47608 - atomic_t seqno; /* HVSI packet sequence number */
47609 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47610 uint16_t mctrl;
47611 uint8_t state; /* HVSI protocol state */
47612 uint8_t flags;
47613 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47614
47615 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47616 packet.hdr.len = sizeof(struct hvsi_query_response);
47617 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47618 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47619 packet.verb = VSV_SEND_VERSION_NUMBER;
47620 packet.u.version = HVSI_VERSION;
47621 packet.query_seqno = query_seqno+1;
47622 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47623
47624 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47625 packet.hdr.len = sizeof(struct hvsi_query);
47626 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47627 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47628 packet.verb = verb;
47629
47630 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47631 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47632 int wrote;
47633
47634 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47635 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47636 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47637 packet.hdr.len = sizeof(struct hvsi_control);
47638 packet.verb = VSV_SET_MODEM_CTL;
47639 packet.mask = HVSI_TSDTR;
47640 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47641 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47642
47643 packet.hdr.type = VS_DATA_PACKET_HEADER;
47644 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47645 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47646 packet.hdr.len = count + sizeof(struct hvsi_header);
47647 memcpy(&packet.data, buf, count);
47648
47649 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47650 struct hvsi_control packet __ALIGNED__;
47651
47652 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47653 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47654 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47655 packet.hdr.len = 6;
47656 packet.verb = VSV_CLOSE_PROTOCOL;
47657
47658 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47659 index ac27671..0f627ee 100644
47660 --- a/drivers/tty/hvc/hvsi_lib.c
47661 +++ b/drivers/tty/hvc/hvsi_lib.c
47662 @@ -9,7 +9,7 @@
47663
47664 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47665 {
47666 - packet->seqno = atomic_inc_return(&pv->seqno);
47667 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47668
47669 /* Assumes that always succeeds, works in practice */
47670 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47671 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47672
47673 /* Reset state */
47674 pv->established = 0;
47675 - atomic_set(&pv->seqno, 0);
47676 + atomic_set_unchecked(&pv->seqno, 0);
47677
47678 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47679
47680 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47681 pv->mctrl_update = 0;
47682 q.hdr.type = VS_QUERY_PACKET_HEADER;
47683 q.hdr.len = sizeof(struct hvsi_query);
47684 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47685 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47686 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47687 rc = hvsi_send_packet(pv, &q.hdr);
47688 if (rc <= 0) {
47689 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47690 index 8fd72ff..34a0bed 100644
47691 --- a/drivers/tty/ipwireless/tty.c
47692 +++ b/drivers/tty/ipwireless/tty.c
47693 @@ -29,6 +29,7 @@
47694 #include <linux/tty_driver.h>
47695 #include <linux/tty_flip.h>
47696 #include <linux/uaccess.h>
47697 +#include <asm/local.h>
47698
47699 #include "tty.h"
47700 #include "network.h"
47701 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47702 mutex_unlock(&tty->ipw_tty_mutex);
47703 return -ENODEV;
47704 }
47705 - if (tty->port.count == 0)
47706 + if (atomic_read(&tty->port.count) == 0)
47707 tty->tx_bytes_queued = 0;
47708
47709 - tty->port.count++;
47710 + atomic_inc(&tty->port.count);
47711
47712 tty->port.tty = linux_tty;
47713 linux_tty->driver_data = tty;
47714 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47715
47716 static void do_ipw_close(struct ipw_tty *tty)
47717 {
47718 - tty->port.count--;
47719 -
47720 - if (tty->port.count == 0) {
47721 + if (atomic_dec_return(&tty->port.count) == 0) {
47722 struct tty_struct *linux_tty = tty->port.tty;
47723
47724 if (linux_tty != NULL) {
47725 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47726 return;
47727
47728 mutex_lock(&tty->ipw_tty_mutex);
47729 - if (tty->port.count == 0) {
47730 + if (atomic_read(&tty->port.count) == 0) {
47731 mutex_unlock(&tty->ipw_tty_mutex);
47732 return;
47733 }
47734 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47735
47736 mutex_lock(&tty->ipw_tty_mutex);
47737
47738 - if (!tty->port.count) {
47739 + if (!atomic_read(&tty->port.count)) {
47740 mutex_unlock(&tty->ipw_tty_mutex);
47741 return;
47742 }
47743 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47744 return -ENODEV;
47745
47746 mutex_lock(&tty->ipw_tty_mutex);
47747 - if (!tty->port.count) {
47748 + if (!atomic_read(&tty->port.count)) {
47749 mutex_unlock(&tty->ipw_tty_mutex);
47750 return -EINVAL;
47751 }
47752 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47753 if (!tty)
47754 return -ENODEV;
47755
47756 - if (!tty->port.count)
47757 + if (!atomic_read(&tty->port.count))
47758 return -EINVAL;
47759
47760 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47761 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47762 if (!tty)
47763 return 0;
47764
47765 - if (!tty->port.count)
47766 + if (!atomic_read(&tty->port.count))
47767 return 0;
47768
47769 return tty->tx_bytes_queued;
47770 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47771 if (!tty)
47772 return -ENODEV;
47773
47774 - if (!tty->port.count)
47775 + if (!atomic_read(&tty->port.count))
47776 return -EINVAL;
47777
47778 return get_control_lines(tty);
47779 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47780 if (!tty)
47781 return -ENODEV;
47782
47783 - if (!tty->port.count)
47784 + if (!atomic_read(&tty->port.count))
47785 return -EINVAL;
47786
47787 return set_control_lines(tty, set, clear);
47788 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47789 if (!tty)
47790 return -ENODEV;
47791
47792 - if (!tty->port.count)
47793 + if (!atomic_read(&tty->port.count))
47794 return -EINVAL;
47795
47796 /* FIXME: Exactly how is the tty object locked here .. */
47797 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47798 * are gone */
47799 mutex_lock(&ttyj->ipw_tty_mutex);
47800 }
47801 - while (ttyj->port.count)
47802 + while (atomic_read(&ttyj->port.count))
47803 do_ipw_close(ttyj);
47804 ipwireless_disassociate_network_ttys(network,
47805 ttyj->channel_idx);
47806 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47807 index 1deaca4..c8582d4 100644
47808 --- a/drivers/tty/moxa.c
47809 +++ b/drivers/tty/moxa.c
47810 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47811 }
47812
47813 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47814 - ch->port.count++;
47815 + atomic_inc(&ch->port.count);
47816 tty->driver_data = ch;
47817 tty_port_tty_set(&ch->port, tty);
47818 mutex_lock(&ch->port.mutex);
47819 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47820 index 6422390..49003ac8 100644
47821 --- a/drivers/tty/n_gsm.c
47822 +++ b/drivers/tty/n_gsm.c
47823 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47824 spin_lock_init(&dlci->lock);
47825 mutex_init(&dlci->mutex);
47826 dlci->fifo = &dlci->_fifo;
47827 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47828 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47829 kfree(dlci);
47830 return NULL;
47831 }
47832 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47833 struct gsm_dlci *dlci = tty->driver_data;
47834 struct tty_port *port = &dlci->port;
47835
47836 - port->count++;
47837 + atomic_inc(&port->count);
47838 dlci_get(dlci);
47839 dlci_get(dlci->gsm->dlci[0]);
47840 mux_get(dlci->gsm);
47841 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47842 index 4bf0fc0..433bd58 100644
47843 --- a/drivers/tty/n_tty.c
47844 +++ b/drivers/tty/n_tty.c
47845 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47846 {
47847 *ops = tty_ldisc_N_TTY;
47848 ops->owner = NULL;
47849 - ops->refcount = ops->flags = 0;
47850 + atomic_set(&ops->refcount, 0);
47851 + ops->flags = 0;
47852 }
47853 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47854 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47855 index abfd990..5ab5da9 100644
47856 --- a/drivers/tty/pty.c
47857 +++ b/drivers/tty/pty.c
47858 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47859 panic("Couldn't register Unix98 pts driver");
47860
47861 /* Now create the /dev/ptmx special device */
47862 + pax_open_kernel();
47863 tty_default_fops(&ptmx_fops);
47864 - ptmx_fops.open = ptmx_open;
47865 + *(void **)&ptmx_fops.open = ptmx_open;
47866 + pax_close_kernel();
47867
47868 cdev_init(&ptmx_cdev, &ptmx_fops);
47869 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47870 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47871 index 354564e..fe50d9a 100644
47872 --- a/drivers/tty/rocket.c
47873 +++ b/drivers/tty/rocket.c
47874 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47875 tty->driver_data = info;
47876 tty_port_tty_set(port, tty);
47877
47878 - if (port->count++ == 0) {
47879 + if (atomic_inc_return(&port->count) == 1) {
47880 atomic_inc(&rp_num_ports_open);
47881
47882 #ifdef ROCKET_DEBUG_OPEN
47883 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47884 #endif
47885 }
47886 #ifdef ROCKET_DEBUG_OPEN
47887 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47888 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47889 #endif
47890
47891 /*
47892 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47893 spin_unlock_irqrestore(&info->port.lock, flags);
47894 return;
47895 }
47896 - if (info->port.count)
47897 + if (atomic_read(&info->port.count))
47898 atomic_dec(&rp_num_ports_open);
47899 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47900 spin_unlock_irqrestore(&info->port.lock, flags);
47901 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47902 index e2520ab..034e20b 100644
47903 --- a/drivers/tty/serial/ioc4_serial.c
47904 +++ b/drivers/tty/serial/ioc4_serial.c
47905 @@ -437,7 +437,7 @@ struct ioc4_soft {
47906 } is_intr_info[MAX_IOC4_INTR_ENTS];
47907
47908 /* Number of entries active in the above array */
47909 - atomic_t is_num_intrs;
47910 + atomic_unchecked_t is_num_intrs;
47911 } is_intr_type[IOC4_NUM_INTR_TYPES];
47912
47913 /* is_ir_lock must be held while
47914 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47915 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47916 || (type == IOC4_OTHER_INTR_TYPE)));
47917
47918 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47919 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47920 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47921
47922 /* Save off the lower level interrupt handler */
47923 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47924
47925 soft = arg;
47926 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47927 - num_intrs = (int)atomic_read(
47928 + num_intrs = (int)atomic_read_unchecked(
47929 &soft->is_intr_type[intr_type].is_num_intrs);
47930
47931 this_mir = this_ir = pending_intrs(soft, intr_type);
47932 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47933 index 1002054..dd644a8 100644
47934 --- a/drivers/tty/serial/kgdboc.c
47935 +++ b/drivers/tty/serial/kgdboc.c
47936 @@ -24,8 +24,9 @@
47937 #define MAX_CONFIG_LEN 40
47938
47939 static struct kgdb_io kgdboc_io_ops;
47940 +static struct kgdb_io kgdboc_io_ops_console;
47941
47942 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47943 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47944 static int configured = -1;
47945
47946 static char config[MAX_CONFIG_LEN];
47947 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47948 kgdboc_unregister_kbd();
47949 if (configured == 1)
47950 kgdb_unregister_io_module(&kgdboc_io_ops);
47951 + else if (configured == 2)
47952 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47953 }
47954
47955 static int configure_kgdboc(void)
47956 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47957 int err;
47958 char *cptr = config;
47959 struct console *cons;
47960 + int is_console = 0;
47961
47962 err = kgdboc_option_setup(config);
47963 if (err || !strlen(config) || isspace(config[0]))
47964 goto noconfig;
47965
47966 err = -ENODEV;
47967 - kgdboc_io_ops.is_console = 0;
47968 kgdb_tty_driver = NULL;
47969
47970 kgdboc_use_kms = 0;
47971 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47972 int idx;
47973 if (cons->device && cons->device(cons, &idx) == p &&
47974 idx == tty_line) {
47975 - kgdboc_io_ops.is_console = 1;
47976 + is_console = 1;
47977 break;
47978 }
47979 cons = cons->next;
47980 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47981 kgdb_tty_line = tty_line;
47982
47983 do_register:
47984 - err = kgdb_register_io_module(&kgdboc_io_ops);
47985 + if (is_console) {
47986 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
47987 + configured = 2;
47988 + } else {
47989 + err = kgdb_register_io_module(&kgdboc_io_ops);
47990 + configured = 1;
47991 + }
47992 if (err)
47993 goto noconfig;
47994
47995 @@ -205,8 +214,6 @@ do_register:
47996 if (err)
47997 goto nmi_con_failed;
47998
47999 - configured = 1;
48000 -
48001 return 0;
48002
48003 nmi_con_failed:
48004 @@ -223,7 +230,7 @@ noconfig:
48005 static int __init init_kgdboc(void)
48006 {
48007 /* Already configured? */
48008 - if (configured == 1)
48009 + if (configured >= 1)
48010 return 0;
48011
48012 return configure_kgdboc();
48013 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48014 if (config[len - 1] == '\n')
48015 config[len - 1] = '\0';
48016
48017 - if (configured == 1)
48018 + if (configured >= 1)
48019 cleanup_kgdboc();
48020
48021 /* Go and configure with the new params. */
48022 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48023 .post_exception = kgdboc_post_exp_handler,
48024 };
48025
48026 +static struct kgdb_io kgdboc_io_ops_console = {
48027 + .name = "kgdboc",
48028 + .read_char = kgdboc_get_char,
48029 + .write_char = kgdboc_put_char,
48030 + .pre_exception = kgdboc_pre_exp_handler,
48031 + .post_exception = kgdboc_post_exp_handler,
48032 + .is_console = 1
48033 +};
48034 +
48035 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48036 /* This is only available if kgdboc is a built in for early debugging */
48037 static int __init kgdboc_early_init(char *opt)
48038 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48039 index 2c6cfb3..048274e 100644
48040 --- a/drivers/tty/serial/msm_serial.c
48041 +++ b/drivers/tty/serial/msm_serial.c
48042 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48043 .cons = MSM_CONSOLE,
48044 };
48045
48046 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48047 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48048
48049 static int __init msm_serial_probe(struct platform_device *pdev)
48050 {
48051 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48052 int irq;
48053
48054 if (pdev->id == -1)
48055 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48056 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48057
48058 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48059 return -ENXIO;
48060 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48061 index 376079b..d8de7aa 100644
48062 --- a/drivers/tty/serial/samsung.c
48063 +++ b/drivers/tty/serial/samsung.c
48064 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48065 }
48066 }
48067
48068 +static int s3c64xx_serial_startup(struct uart_port *port);
48069 static int s3c24xx_serial_startup(struct uart_port *port)
48070 {
48071 struct s3c24xx_uart_port *ourport = to_ourport(port);
48072 int ret;
48073
48074 + /* Startup sequence is different for s3c64xx and higher SoC's */
48075 + if (s3c24xx_serial_has_interrupt_mask(port))
48076 + return s3c64xx_serial_startup(port);
48077 +
48078 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48079 port->mapbase, port->membase);
48080
48081 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48082 /* setup info for port */
48083 port->dev = &platdev->dev;
48084
48085 - /* Startup sequence is different for s3c64xx and higher SoC's */
48086 - if (s3c24xx_serial_has_interrupt_mask(port))
48087 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48088 -
48089 port->uartclk = 1;
48090
48091 if (cfg->uart_flags & UPF_CONS_FLOW) {
48092 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48093 index 28cdd28..56f1d60 100644
48094 --- a/drivers/tty/serial/serial_core.c
48095 +++ b/drivers/tty/serial/serial_core.c
48096 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48097 uart_flush_buffer(tty);
48098 uart_shutdown(tty, state);
48099 spin_lock_irqsave(&port->lock, flags);
48100 - port->count = 0;
48101 + atomic_set(&port->count, 0);
48102 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48103 spin_unlock_irqrestore(&port->lock, flags);
48104 tty_port_tty_set(port, NULL);
48105 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48106 goto end;
48107 }
48108
48109 - port->count++;
48110 + atomic_inc(&port->count);
48111 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48112 retval = -ENXIO;
48113 goto err_dec_count;
48114 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48115 /*
48116 * Make sure the device is in D0 state.
48117 */
48118 - if (port->count == 1)
48119 + if (atomic_read(&port->count) == 1)
48120 uart_change_pm(state, UART_PM_STATE_ON);
48121
48122 /*
48123 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48124 end:
48125 return retval;
48126 err_dec_count:
48127 - port->count--;
48128 + atomic_inc(&port->count);
48129 mutex_unlock(&port->mutex);
48130 goto end;
48131 }
48132 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48133 index 8eaf1ab..85c030d 100644
48134 --- a/drivers/tty/synclink.c
48135 +++ b/drivers/tty/synclink.c
48136 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48137
48138 if (debug_level >= DEBUG_LEVEL_INFO)
48139 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48140 - __FILE__,__LINE__, info->device_name, info->port.count);
48141 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48142
48143 if (tty_port_close_start(&info->port, tty, filp) == 0)
48144 goto cleanup;
48145 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48146 cleanup:
48147 if (debug_level >= DEBUG_LEVEL_INFO)
48148 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48149 - tty->driver->name, info->port.count);
48150 + tty->driver->name, atomic_read(&info->port.count));
48151
48152 } /* end of mgsl_close() */
48153
48154 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48155
48156 mgsl_flush_buffer(tty);
48157 shutdown(info);
48158 -
48159 - info->port.count = 0;
48160 +
48161 + atomic_set(&info->port.count, 0);
48162 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48163 info->port.tty = NULL;
48164
48165 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48166
48167 if (debug_level >= DEBUG_LEVEL_INFO)
48168 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48169 - __FILE__,__LINE__, tty->driver->name, port->count );
48170 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48171
48172 spin_lock_irqsave(&info->irq_spinlock, flags);
48173 if (!tty_hung_up_p(filp)) {
48174 extra_count = true;
48175 - port->count--;
48176 + atomic_dec(&port->count);
48177 }
48178 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48179 port->blocked_open++;
48180 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48181
48182 if (debug_level >= DEBUG_LEVEL_INFO)
48183 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48184 - __FILE__,__LINE__, tty->driver->name, port->count );
48185 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48186
48187 tty_unlock(tty);
48188 schedule();
48189 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48190
48191 /* FIXME: Racy on hangup during close wait */
48192 if (extra_count)
48193 - port->count++;
48194 + atomic_inc(&port->count);
48195 port->blocked_open--;
48196
48197 if (debug_level >= DEBUG_LEVEL_INFO)
48198 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48199 - __FILE__,__LINE__, tty->driver->name, port->count );
48200 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48201
48202 if (!retval)
48203 port->flags |= ASYNC_NORMAL_ACTIVE;
48204 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48205
48206 if (debug_level >= DEBUG_LEVEL_INFO)
48207 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48208 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48209 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48210
48211 /* If port is closing, signal caller to try again */
48212 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48213 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48214 spin_unlock_irqrestore(&info->netlock, flags);
48215 goto cleanup;
48216 }
48217 - info->port.count++;
48218 + atomic_inc(&info->port.count);
48219 spin_unlock_irqrestore(&info->netlock, flags);
48220
48221 - if (info->port.count == 1) {
48222 + if (atomic_read(&info->port.count) == 1) {
48223 /* 1st open on this device, init hardware */
48224 retval = startup(info);
48225 if (retval < 0)
48226 @@ -3446,8 +3446,8 @@ cleanup:
48227 if (retval) {
48228 if (tty->count == 1)
48229 info->port.tty = NULL; /* tty layer will release tty struct */
48230 - if(info->port.count)
48231 - info->port.count--;
48232 + if (atomic_read(&info->port.count))
48233 + atomic_dec(&info->port.count);
48234 }
48235
48236 return retval;
48237 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48238 unsigned short new_crctype;
48239
48240 /* return error if TTY interface open */
48241 - if (info->port.count)
48242 + if (atomic_read(&info->port.count))
48243 return -EBUSY;
48244
48245 switch (encoding)
48246 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48247
48248 /* arbitrate between network and tty opens */
48249 spin_lock_irqsave(&info->netlock, flags);
48250 - if (info->port.count != 0 || info->netcount != 0) {
48251 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48252 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48253 spin_unlock_irqrestore(&info->netlock, flags);
48254 return -EBUSY;
48255 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48256 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48257
48258 /* return error if TTY interface open */
48259 - if (info->port.count)
48260 + if (atomic_read(&info->port.count))
48261 return -EBUSY;
48262
48263 if (cmd != SIOCWANDEV)
48264 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48265 index 1abf946..1ee34fc 100644
48266 --- a/drivers/tty/synclink_gt.c
48267 +++ b/drivers/tty/synclink_gt.c
48268 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48269 tty->driver_data = info;
48270 info->port.tty = tty;
48271
48272 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48273 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48274
48275 /* If port is closing, signal caller to try again */
48276 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48277 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48278 mutex_unlock(&info->port.mutex);
48279 goto cleanup;
48280 }
48281 - info->port.count++;
48282 + atomic_inc(&info->port.count);
48283 spin_unlock_irqrestore(&info->netlock, flags);
48284
48285 - if (info->port.count == 1) {
48286 + if (atomic_read(&info->port.count) == 1) {
48287 /* 1st open on this device, init hardware */
48288 retval = startup(info);
48289 if (retval < 0) {
48290 @@ -715,8 +715,8 @@ cleanup:
48291 if (retval) {
48292 if (tty->count == 1)
48293 info->port.tty = NULL; /* tty layer will release tty struct */
48294 - if(info->port.count)
48295 - info->port.count--;
48296 + if(atomic_read(&info->port.count))
48297 + atomic_dec(&info->port.count);
48298 }
48299
48300 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48301 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48302
48303 if (sanity_check(info, tty->name, "close"))
48304 return;
48305 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48306 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48307
48308 if (tty_port_close_start(&info->port, tty, filp) == 0)
48309 goto cleanup;
48310 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48311 tty_port_close_end(&info->port, tty);
48312 info->port.tty = NULL;
48313 cleanup:
48314 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48315 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48316 }
48317
48318 static void hangup(struct tty_struct *tty)
48319 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48320 shutdown(info);
48321
48322 spin_lock_irqsave(&info->port.lock, flags);
48323 - info->port.count = 0;
48324 + atomic_set(&info->port.count, 0);
48325 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48326 info->port.tty = NULL;
48327 spin_unlock_irqrestore(&info->port.lock, flags);
48328 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48329 unsigned short new_crctype;
48330
48331 /* return error if TTY interface open */
48332 - if (info->port.count)
48333 + if (atomic_read(&info->port.count))
48334 return -EBUSY;
48335
48336 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48337 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48338
48339 /* arbitrate between network and tty opens */
48340 spin_lock_irqsave(&info->netlock, flags);
48341 - if (info->port.count != 0 || info->netcount != 0) {
48342 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48343 DBGINFO(("%s hdlc_open busy\n", dev->name));
48344 spin_unlock_irqrestore(&info->netlock, flags);
48345 return -EBUSY;
48346 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48347 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48348
48349 /* return error if TTY interface open */
48350 - if (info->port.count)
48351 + if (atomic_read(&info->port.count))
48352 return -EBUSY;
48353
48354 if (cmd != SIOCWANDEV)
48355 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48356 if (port == NULL)
48357 continue;
48358 spin_lock(&port->lock);
48359 - if ((port->port.count || port->netcount) &&
48360 + if ((atomic_read(&port->port.count) || port->netcount) &&
48361 port->pending_bh && !port->bh_running &&
48362 !port->bh_requested) {
48363 DBGISR(("%s bh queued\n", port->device_name));
48364 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48365 spin_lock_irqsave(&info->lock, flags);
48366 if (!tty_hung_up_p(filp)) {
48367 extra_count = true;
48368 - port->count--;
48369 + atomic_dec(&port->count);
48370 }
48371 spin_unlock_irqrestore(&info->lock, flags);
48372 port->blocked_open++;
48373 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48374 remove_wait_queue(&port->open_wait, &wait);
48375
48376 if (extra_count)
48377 - port->count++;
48378 + atomic_inc(&port->count);
48379 port->blocked_open--;
48380
48381 if (!retval)
48382 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48383 index dc6e969..5dc8786 100644
48384 --- a/drivers/tty/synclinkmp.c
48385 +++ b/drivers/tty/synclinkmp.c
48386 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48387
48388 if (debug_level >= DEBUG_LEVEL_INFO)
48389 printk("%s(%d):%s open(), old ref count = %d\n",
48390 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48391 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48392
48393 /* If port is closing, signal caller to try again */
48394 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48395 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48396 spin_unlock_irqrestore(&info->netlock, flags);
48397 goto cleanup;
48398 }
48399 - info->port.count++;
48400 + atomic_inc(&info->port.count);
48401 spin_unlock_irqrestore(&info->netlock, flags);
48402
48403 - if (info->port.count == 1) {
48404 + if (atomic_read(&info->port.count) == 1) {
48405 /* 1st open on this device, init hardware */
48406 retval = startup(info);
48407 if (retval < 0)
48408 @@ -796,8 +796,8 @@ cleanup:
48409 if (retval) {
48410 if (tty->count == 1)
48411 info->port.tty = NULL; /* tty layer will release tty struct */
48412 - if(info->port.count)
48413 - info->port.count--;
48414 + if(atomic_read(&info->port.count))
48415 + atomic_dec(&info->port.count);
48416 }
48417
48418 return retval;
48419 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48420
48421 if (debug_level >= DEBUG_LEVEL_INFO)
48422 printk("%s(%d):%s close() entry, count=%d\n",
48423 - __FILE__,__LINE__, info->device_name, info->port.count);
48424 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48425
48426 if (tty_port_close_start(&info->port, tty, filp) == 0)
48427 goto cleanup;
48428 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48429 cleanup:
48430 if (debug_level >= DEBUG_LEVEL_INFO)
48431 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48432 - tty->driver->name, info->port.count);
48433 + tty->driver->name, atomic_read(&info->port.count));
48434 }
48435
48436 /* Called by tty_hangup() when a hangup is signaled.
48437 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48438 shutdown(info);
48439
48440 spin_lock_irqsave(&info->port.lock, flags);
48441 - info->port.count = 0;
48442 + atomic_set(&info->port.count, 0);
48443 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48444 info->port.tty = NULL;
48445 spin_unlock_irqrestore(&info->port.lock, flags);
48446 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48447 unsigned short new_crctype;
48448
48449 /* return error if TTY interface open */
48450 - if (info->port.count)
48451 + if (atomic_read(&info->port.count))
48452 return -EBUSY;
48453
48454 switch (encoding)
48455 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48456
48457 /* arbitrate between network and tty opens */
48458 spin_lock_irqsave(&info->netlock, flags);
48459 - if (info->port.count != 0 || info->netcount != 0) {
48460 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48461 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48462 spin_unlock_irqrestore(&info->netlock, flags);
48463 return -EBUSY;
48464 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48465 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48466
48467 /* return error if TTY interface open */
48468 - if (info->port.count)
48469 + if (atomic_read(&info->port.count))
48470 return -EBUSY;
48471
48472 if (cmd != SIOCWANDEV)
48473 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48474 * do not request bottom half processing if the
48475 * device is not open in a normal mode.
48476 */
48477 - if ( port && (port->port.count || port->netcount) &&
48478 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48479 port->pending_bh && !port->bh_running &&
48480 !port->bh_requested ) {
48481 if ( debug_level >= DEBUG_LEVEL_ISR )
48482 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48483
48484 if (debug_level >= DEBUG_LEVEL_INFO)
48485 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48486 - __FILE__,__LINE__, tty->driver->name, port->count );
48487 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48488
48489 spin_lock_irqsave(&info->lock, flags);
48490 if (!tty_hung_up_p(filp)) {
48491 extra_count = true;
48492 - port->count--;
48493 + atomic_dec(&port->count);
48494 }
48495 spin_unlock_irqrestore(&info->lock, flags);
48496 port->blocked_open++;
48497 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48498
48499 if (debug_level >= DEBUG_LEVEL_INFO)
48500 printk("%s(%d):%s block_til_ready() count=%d\n",
48501 - __FILE__,__LINE__, tty->driver->name, port->count );
48502 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48503
48504 tty_unlock(tty);
48505 schedule();
48506 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48507 remove_wait_queue(&port->open_wait, &wait);
48508
48509 if (extra_count)
48510 - port->count++;
48511 + atomic_inc(&port->count);
48512 port->blocked_open--;
48513
48514 if (debug_level >= DEBUG_LEVEL_INFO)
48515 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48516 - __FILE__,__LINE__, tty->driver->name, port->count );
48517 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48518
48519 if (!retval)
48520 port->flags |= ASYNC_NORMAL_ACTIVE;
48521 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48522 index d5cc3ac..3263411 100644
48523 --- a/drivers/tty/sysrq.c
48524 +++ b/drivers/tty/sysrq.c
48525 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48526 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48527 size_t count, loff_t *ppos)
48528 {
48529 - if (count) {
48530 + if (count && capable(CAP_SYS_ADMIN)) {
48531 char c;
48532
48533 if (get_user(c, buf))
48534 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48535 index 20689b9..7fd3a31 100644
48536 --- a/drivers/tty/tty_io.c
48537 +++ b/drivers/tty/tty_io.c
48538 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48539
48540 void tty_default_fops(struct file_operations *fops)
48541 {
48542 - *fops = tty_fops;
48543 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48544 }
48545
48546 /*
48547 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48548 index 1afe192..73d2c20 100644
48549 --- a/drivers/tty/tty_ldisc.c
48550 +++ b/drivers/tty/tty_ldisc.c
48551 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48552 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48553 tty_ldiscs[disc] = new_ldisc;
48554 new_ldisc->num = disc;
48555 - new_ldisc->refcount = 0;
48556 + atomic_set(&new_ldisc->refcount, 0);
48557 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48558
48559 return ret;
48560 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48561 return -EINVAL;
48562
48563 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48564 - if (tty_ldiscs[disc]->refcount)
48565 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48566 ret = -EBUSY;
48567 else
48568 tty_ldiscs[disc] = NULL;
48569 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48570 if (ldops) {
48571 ret = ERR_PTR(-EAGAIN);
48572 if (try_module_get(ldops->owner)) {
48573 - ldops->refcount++;
48574 + atomic_inc(&ldops->refcount);
48575 ret = ldops;
48576 }
48577 }
48578 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48579 unsigned long flags;
48580
48581 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48582 - ldops->refcount--;
48583 + atomic_dec(&ldops->refcount);
48584 module_put(ldops->owner);
48585 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48586 }
48587 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48588 /* unreleased reader reference(s) will cause this WARN */
48589 WARN_ON(!atomic_dec_and_test(&ld->users));
48590
48591 - ld->ops->refcount--;
48592 + atomic_dec(&ld->ops->refcount);
48593 module_put(ld->ops->owner);
48594 kfree(ld);
48595 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48596 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48597 index f597e88..b7f68ed 100644
48598 --- a/drivers/tty/tty_port.c
48599 +++ b/drivers/tty/tty_port.c
48600 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48601 unsigned long flags;
48602
48603 spin_lock_irqsave(&port->lock, flags);
48604 - port->count = 0;
48605 + atomic_set(&port->count, 0);
48606 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48607 tty = port->tty;
48608 if (tty)
48609 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48610 /* The port lock protects the port counts */
48611 spin_lock_irqsave(&port->lock, flags);
48612 if (!tty_hung_up_p(filp))
48613 - port->count--;
48614 + atomic_dec(&port->count);
48615 port->blocked_open++;
48616 spin_unlock_irqrestore(&port->lock, flags);
48617
48618 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48619 we must not mess that up further */
48620 spin_lock_irqsave(&port->lock, flags);
48621 if (!tty_hung_up_p(filp))
48622 - port->count++;
48623 + atomic_inc(&port->count);
48624 port->blocked_open--;
48625 if (retval == 0)
48626 port->flags |= ASYNC_NORMAL_ACTIVE;
48627 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48628 return 0;
48629 }
48630
48631 - if (tty->count == 1 && port->count != 1) {
48632 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48633 printk(KERN_WARNING
48634 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48635 - port->count);
48636 - port->count = 1;
48637 + atomic_read(&port->count));
48638 + atomic_set(&port->count, 1);
48639 }
48640 - if (--port->count < 0) {
48641 + if (atomic_dec_return(&port->count) < 0) {
48642 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48643 - port->count);
48644 - port->count = 0;
48645 + atomic_read(&port->count));
48646 + atomic_set(&port->count, 0);
48647 }
48648
48649 - if (port->count) {
48650 + if (atomic_read(&port->count)) {
48651 spin_unlock_irqrestore(&port->lock, flags);
48652 if (port->ops->drop)
48653 port->ops->drop(port);
48654 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48655 {
48656 spin_lock_irq(&port->lock);
48657 if (!tty_hung_up_p(filp))
48658 - ++port->count;
48659 + atomic_inc(&port->count);
48660 spin_unlock_irq(&port->lock);
48661 tty_port_tty_set(port, tty);
48662
48663 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48664 index a9af1b9a..1e08e7f 100644
48665 --- a/drivers/tty/vt/keyboard.c
48666 +++ b/drivers/tty/vt/keyboard.c
48667 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48668 kbd->kbdmode == VC_OFF) &&
48669 value != KVAL(K_SAK))
48670 return; /* SAK is allowed even in raw mode */
48671 +
48672 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48673 + {
48674 + void *func = fn_handler[value];
48675 + if (func == fn_show_state || func == fn_show_ptregs ||
48676 + func == fn_show_mem)
48677 + return;
48678 + }
48679 +#endif
48680 +
48681 fn_handler[value](vc);
48682 }
48683
48684 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48685 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48686 return -EFAULT;
48687
48688 - if (!capable(CAP_SYS_TTY_CONFIG))
48689 - perm = 0;
48690 -
48691 switch (cmd) {
48692 case KDGKBENT:
48693 /* Ensure another thread doesn't free it under us */
48694 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48695 spin_unlock_irqrestore(&kbd_event_lock, flags);
48696 return put_user(val, &user_kbe->kb_value);
48697 case KDSKBENT:
48698 + if (!capable(CAP_SYS_TTY_CONFIG))
48699 + perm = 0;
48700 +
48701 if (!perm)
48702 return -EPERM;
48703 if (!i && v == K_NOSUCHMAP) {
48704 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48705 int i, j, k;
48706 int ret;
48707
48708 - if (!capable(CAP_SYS_TTY_CONFIG))
48709 - perm = 0;
48710 -
48711 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48712 if (!kbs) {
48713 ret = -ENOMEM;
48714 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48715 kfree(kbs);
48716 return ((p && *p) ? -EOVERFLOW : 0);
48717 case KDSKBSENT:
48718 + if (!capable(CAP_SYS_TTY_CONFIG))
48719 + perm = 0;
48720 +
48721 if (!perm) {
48722 ret = -EPERM;
48723 goto reterr;
48724 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48725 index 3b96f18..6f6a8f1 100644
48726 --- a/drivers/uio/uio.c
48727 +++ b/drivers/uio/uio.c
48728 @@ -25,6 +25,7 @@
48729 #include <linux/kobject.h>
48730 #include <linux/cdev.h>
48731 #include <linux/uio_driver.h>
48732 +#include <asm/local.h>
48733
48734 #define UIO_MAX_DEVICES (1U << MINORBITS)
48735
48736 @@ -32,10 +33,10 @@ struct uio_device {
48737 struct module *owner;
48738 struct device *dev;
48739 int minor;
48740 - atomic_t event;
48741 + atomic_unchecked_t event;
48742 struct fasync_struct *async_queue;
48743 wait_queue_head_t wait;
48744 - int vma_count;
48745 + local_t vma_count;
48746 struct uio_info *info;
48747 struct kobject *map_dir;
48748 struct kobject *portio_dir;
48749 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48750 struct device_attribute *attr, char *buf)
48751 {
48752 struct uio_device *idev = dev_get_drvdata(dev);
48753 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48754 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48755 }
48756
48757 static struct device_attribute uio_class_attributes[] = {
48758 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48759 {
48760 struct uio_device *idev = info->uio_dev;
48761
48762 - atomic_inc(&idev->event);
48763 + atomic_inc_unchecked(&idev->event);
48764 wake_up_interruptible(&idev->wait);
48765 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48766 }
48767 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48768 }
48769
48770 listener->dev = idev;
48771 - listener->event_count = atomic_read(&idev->event);
48772 + listener->event_count = atomic_read_unchecked(&idev->event);
48773 filep->private_data = listener;
48774
48775 if (idev->info->open) {
48776 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48777 return -EIO;
48778
48779 poll_wait(filep, &idev->wait, wait);
48780 - if (listener->event_count != atomic_read(&idev->event))
48781 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48782 return POLLIN | POLLRDNORM;
48783 return 0;
48784 }
48785 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48786 do {
48787 set_current_state(TASK_INTERRUPTIBLE);
48788
48789 - event_count = atomic_read(&idev->event);
48790 + event_count = atomic_read_unchecked(&idev->event);
48791 if (event_count != listener->event_count) {
48792 if (copy_to_user(buf, &event_count, count))
48793 retval = -EFAULT;
48794 @@ -584,9 +585,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48795 static int uio_find_mem_index(struct vm_area_struct *vma)
48796 {
48797 struct uio_device *idev = vma->vm_private_data;
48798 + unsigned long size;
48799
48800 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48801 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48802 + size = idev->info->mem[vma->vm_pgoff].size;
48803 + if (size == 0)
48804 + return -1;
48805 + if (vma->vm_end - vma->vm_start > size)
48806 return -1;
48807 return (int)vma->vm_pgoff;
48808 }
48809 @@ -596,13 +601,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48810 static void uio_vma_open(struct vm_area_struct *vma)
48811 {
48812 struct uio_device *idev = vma->vm_private_data;
48813 - idev->vma_count++;
48814 + local_inc(&idev->vma_count);
48815 }
48816
48817 static void uio_vma_close(struct vm_area_struct *vma)
48818 {
48819 struct uio_device *idev = vma->vm_private_data;
48820 - idev->vma_count--;
48821 + local_dec(&idev->vma_count);
48822 }
48823
48824 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48825 @@ -640,14 +645,25 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
48826 {
48827 struct uio_device *idev = vma->vm_private_data;
48828 int mi = uio_find_mem_index(vma);
48829 + struct uio_mem *mem;
48830 if (mi < 0)
48831 return -EINVAL;
48832 + mem = idev->info->mem + mi;
48833
48834 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
48835
48836 + /*
48837 + * We cannot use the vm_iomap_memory() helper here,
48838 + * because vma->vm_pgoff is the map index we looked
48839 + * up above in uio_find_mem_index(), rather than an
48840 + * actual page offset into the mmap.
48841 + *
48842 + * So we just do the physical mmap without a page
48843 + * offset.
48844 + */
48845 return remap_pfn_range(vma,
48846 vma->vm_start,
48847 - idev->info->mem[mi].addr >> PAGE_SHIFT,
48848 + mem->addr >> PAGE_SHIFT,
48849 vma->vm_end - vma->vm_start,
48850 vma->vm_page_prot);
48851 }
48852 @@ -809,7 +825,7 @@ int __uio_register_device(struct module *owner,
48853 idev->owner = owner;
48854 idev->info = info;
48855 init_waitqueue_head(&idev->wait);
48856 - atomic_set(&idev->event, 0);
48857 + atomic_set_unchecked(&idev->event, 0);
48858
48859 ret = uio_get_minor(idev);
48860 if (ret)
48861 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48862 index 8a7eb77..c00402f 100644
48863 --- a/drivers/usb/atm/cxacru.c
48864 +++ b/drivers/usb/atm/cxacru.c
48865 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48866 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48867 if (ret < 2)
48868 return -EINVAL;
48869 - if (index < 0 || index > 0x7f)
48870 + if (index > 0x7f)
48871 return -EINVAL;
48872 pos += tmp;
48873
48874 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48875 index 5e0d33a..cc10579 100644
48876 --- a/drivers/usb/atm/usbatm.c
48877 +++ b/drivers/usb/atm/usbatm.c
48878 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48879 if (printk_ratelimit())
48880 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48881 __func__, vpi, vci);
48882 - atomic_inc(&vcc->stats->rx_err);
48883 + atomic_inc_unchecked(&vcc->stats->rx_err);
48884 return;
48885 }
48886
48887 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48888 if (length > ATM_MAX_AAL5_PDU) {
48889 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48890 __func__, length, vcc);
48891 - atomic_inc(&vcc->stats->rx_err);
48892 + atomic_inc_unchecked(&vcc->stats->rx_err);
48893 goto out;
48894 }
48895
48896 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48897 if (sarb->len < pdu_length) {
48898 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48899 __func__, pdu_length, sarb->len, vcc);
48900 - atomic_inc(&vcc->stats->rx_err);
48901 + atomic_inc_unchecked(&vcc->stats->rx_err);
48902 goto out;
48903 }
48904
48905 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48906 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48907 __func__, vcc);
48908 - atomic_inc(&vcc->stats->rx_err);
48909 + atomic_inc_unchecked(&vcc->stats->rx_err);
48910 goto out;
48911 }
48912
48913 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48914 if (printk_ratelimit())
48915 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48916 __func__, length);
48917 - atomic_inc(&vcc->stats->rx_drop);
48918 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48919 goto out;
48920 }
48921
48922 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48923
48924 vcc->push(vcc, skb);
48925
48926 - atomic_inc(&vcc->stats->rx);
48927 + atomic_inc_unchecked(&vcc->stats->rx);
48928 out:
48929 skb_trim(sarb, 0);
48930 }
48931 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48932 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48933
48934 usbatm_pop(vcc, skb);
48935 - atomic_inc(&vcc->stats->tx);
48936 + atomic_inc_unchecked(&vcc->stats->tx);
48937
48938 skb = skb_dequeue(&instance->sndqueue);
48939 }
48940 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48941 if (!left--)
48942 return sprintf(page,
48943 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48944 - atomic_read(&atm_dev->stats.aal5.tx),
48945 - atomic_read(&atm_dev->stats.aal5.tx_err),
48946 - atomic_read(&atm_dev->stats.aal5.rx),
48947 - atomic_read(&atm_dev->stats.aal5.rx_err),
48948 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48949 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48950 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48951 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48952 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48953 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48954
48955 if (!left--) {
48956 if (instance->disconnected)
48957 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48958 index 2a3bbdf..91d72cf 100644
48959 --- a/drivers/usb/core/devices.c
48960 +++ b/drivers/usb/core/devices.c
48961 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48962 * time it gets called.
48963 */
48964 static struct device_connect_event {
48965 - atomic_t count;
48966 + atomic_unchecked_t count;
48967 wait_queue_head_t wait;
48968 } device_event = {
48969 .count = ATOMIC_INIT(1),
48970 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48971
48972 void usbfs_conn_disc_event(void)
48973 {
48974 - atomic_add(2, &device_event.count);
48975 + atomic_add_unchecked(2, &device_event.count);
48976 wake_up(&device_event.wait);
48977 }
48978
48979 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48980
48981 poll_wait(file, &device_event.wait, wait);
48982
48983 - event_count = atomic_read(&device_event.count);
48984 + event_count = atomic_read_unchecked(&device_event.count);
48985 if (file->f_version != event_count) {
48986 file->f_version = event_count;
48987 return POLLIN | POLLRDNORM;
48988 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48989 index 014dc99..4d25fd7 100644
48990 --- a/drivers/usb/core/hcd.c
48991 +++ b/drivers/usb/core/hcd.c
48992 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48993 */
48994 usb_get_urb(urb);
48995 atomic_inc(&urb->use_count);
48996 - atomic_inc(&urb->dev->urbnum);
48997 + atomic_inc_unchecked(&urb->dev->urbnum);
48998 usbmon_urb_submit(&hcd->self, urb);
48999
49000 /* NOTE requirements on root-hub callers (usbfs and the hub
49001 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49002 urb->hcpriv = NULL;
49003 INIT_LIST_HEAD(&urb->urb_list);
49004 atomic_dec(&urb->use_count);
49005 - atomic_dec(&urb->dev->urbnum);
49006 + atomic_dec_unchecked(&urb->dev->urbnum);
49007 if (atomic_read(&urb->reject))
49008 wake_up(&usb_kill_urb_queue);
49009 usb_put_urb(urb);
49010 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49011 index 17c3785..deffb11 100644
49012 --- a/drivers/usb/core/hub.c
49013 +++ b/drivers/usb/core/hub.c
49014 @@ -27,6 +27,7 @@
49015 #include <linux/freezer.h>
49016 #include <linux/random.h>
49017 #include <linux/pm_qos.h>
49018 +#include <linux/grsecurity.h>
49019
49020 #include <asm/uaccess.h>
49021 #include <asm/byteorder.h>
49022 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49023 goto done;
49024 return;
49025 }
49026 +
49027 + if (gr_handle_new_usb())
49028 + goto done;
49029 +
49030 if (hub_is_superspeed(hub->hdev))
49031 unit_load = 150;
49032 else
49033 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49034 index e7ee1e4..1dfc9ea4 100644
49035 --- a/drivers/usb/core/message.c
49036 +++ b/drivers/usb/core/message.c
49037 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49038 * method can wait for it to complete. Since you don't have a handle on the
49039 * URB used, you can't cancel the request.
49040 */
49041 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49042 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49043 __u8 requesttype, __u16 value, __u16 index, void *data,
49044 __u16 size, int timeout)
49045 {
49046 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49047 index d9284b9..17023c7 100644
49048 --- a/drivers/usb/core/sysfs.c
49049 +++ b/drivers/usb/core/sysfs.c
49050 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49051 struct usb_device *udev;
49052
49053 udev = to_usb_device(dev);
49054 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49055 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49056 }
49057 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49058
49059 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49060 index 7dad603..350f7a9 100644
49061 --- a/drivers/usb/core/usb.c
49062 +++ b/drivers/usb/core/usb.c
49063 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49064 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49065 dev->state = USB_STATE_ATTACHED;
49066 dev->lpm_disable_count = 1;
49067 - atomic_set(&dev->urbnum, 0);
49068 + atomic_set_unchecked(&dev->urbnum, 0);
49069
49070 INIT_LIST_HEAD(&dev->ep0.urb_list);
49071 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49072 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49073 index 14d28d6..5f511ac 100644
49074 --- a/drivers/usb/dwc3/gadget.c
49075 +++ b/drivers/usb/dwc3/gadget.c
49076 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49077 if (!usb_endpoint_xfer_isoc(desc))
49078 return 0;
49079
49080 - memset(&trb_link, 0, sizeof(trb_link));
49081 -
49082 /* Link TRB for ISOC. The HWO bit is never reset */
49083 trb_st_hw = &dep->trb_pool[0];
49084
49085 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49086 index 5e29dde..eca992f 100644
49087 --- a/drivers/usb/early/ehci-dbgp.c
49088 +++ b/drivers/usb/early/ehci-dbgp.c
49089 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49090
49091 #ifdef CONFIG_KGDB
49092 static struct kgdb_io kgdbdbgp_io_ops;
49093 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49094 +static struct kgdb_io kgdbdbgp_io_ops_console;
49095 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49096 #else
49097 #define dbgp_kgdb_mode (0)
49098 #endif
49099 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49100 .write_char = kgdbdbgp_write_char,
49101 };
49102
49103 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49104 + .name = "kgdbdbgp",
49105 + .read_char = kgdbdbgp_read_char,
49106 + .write_char = kgdbdbgp_write_char,
49107 + .is_console = 1
49108 +};
49109 +
49110 static int kgdbdbgp_wait_time;
49111
49112 static int __init kgdbdbgp_parse_config(char *str)
49113 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49114 ptr++;
49115 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49116 }
49117 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49118 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49119 + if (early_dbgp_console.index != -1)
49120 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49121 + else
49122 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49123
49124 return 0;
49125 }
49126 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49127 index b369292..9f3ba40 100644
49128 --- a/drivers/usb/gadget/u_serial.c
49129 +++ b/drivers/usb/gadget/u_serial.c
49130 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49131 spin_lock_irq(&port->port_lock);
49132
49133 /* already open? Great. */
49134 - if (port->port.count) {
49135 + if (atomic_read(&port->port.count)) {
49136 status = 0;
49137 - port->port.count++;
49138 + atomic_inc(&port->port.count);
49139
49140 /* currently opening/closing? wait ... */
49141 } else if (port->openclose) {
49142 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49143 tty->driver_data = port;
49144 port->port.tty = tty;
49145
49146 - port->port.count = 1;
49147 + atomic_set(&port->port.count, 1);
49148 port->openclose = false;
49149
49150 /* if connected, start the I/O stream */
49151 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49152
49153 spin_lock_irq(&port->port_lock);
49154
49155 - if (port->port.count != 1) {
49156 - if (port->port.count == 0)
49157 + if (atomic_read(&port->port.count) != 1) {
49158 + if (atomic_read(&port->port.count) == 0)
49159 WARN_ON(1);
49160 else
49161 - --port->port.count;
49162 + atomic_dec(&port->port.count);
49163 goto exit;
49164 }
49165
49166 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49167 * and sleep if necessary
49168 */
49169 port->openclose = true;
49170 - port->port.count = 0;
49171 + atomic_set(&port->port.count, 0);
49172
49173 gser = port->port_usb;
49174 if (gser && gser->disconnect)
49175 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49176 int cond;
49177
49178 spin_lock_irq(&port->port_lock);
49179 - cond = (port->port.count == 0) && !port->openclose;
49180 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49181 spin_unlock_irq(&port->port_lock);
49182 return cond;
49183 }
49184 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49185 /* if it's already open, start I/O ... and notify the serial
49186 * protocol about open/close status (connect/disconnect).
49187 */
49188 - if (port->port.count) {
49189 + if (atomic_read(&port->port.count)) {
49190 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49191 gs_start_io(port);
49192 if (gser->connect)
49193 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49194
49195 port->port_usb = NULL;
49196 gser->ioport = NULL;
49197 - if (port->port.count > 0 || port->openclose) {
49198 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49199 wake_up_interruptible(&port->drain_wait);
49200 if (port->port.tty)
49201 tty_hangup(port->port.tty);
49202 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49203
49204 /* finally, free any unused/unusable I/O buffers */
49205 spin_lock_irqsave(&port->port_lock, flags);
49206 - if (port->port.count == 0 && !port->openclose)
49207 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49208 gs_buf_free(&port->port_write_buf);
49209 gs_free_requests(gser->out, &port->read_pool, NULL);
49210 gs_free_requests(gser->out, &port->read_queue, NULL);
49211 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49212 index ba6a5d6..f88f7f3 100644
49213 --- a/drivers/usb/misc/appledisplay.c
49214 +++ b/drivers/usb/misc/appledisplay.c
49215 @@ -83,7 +83,7 @@ struct appledisplay {
49216 spinlock_t lock;
49217 };
49218
49219 -static atomic_t count_displays = ATOMIC_INIT(0);
49220 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49221 static struct workqueue_struct *wq;
49222
49223 static void appledisplay_complete(struct urb *urb)
49224 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49225
49226 /* Register backlight device */
49227 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49228 - atomic_inc_return(&count_displays) - 1);
49229 + atomic_inc_return_unchecked(&count_displays) - 1);
49230 memset(&props, 0, sizeof(struct backlight_properties));
49231 props.type = BACKLIGHT_RAW;
49232 props.max_brightness = 0xff;
49233 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49234 index afb50ea..7b0b1cf 100644
49235 --- a/drivers/usb/serial/console.c
49236 +++ b/drivers/usb/serial/console.c
49237 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49238
49239 info->port = port;
49240
49241 - ++port->port.count;
49242 + atomic_inc(&port->port.count);
49243 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49244 if (serial->type->set_termios) {
49245 /*
49246 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49247 }
49248 /* Now that any required fake tty operations are completed restore
49249 * the tty port count */
49250 - --port->port.count;
49251 + atomic_dec(&port->port.count);
49252 /* The console is special in terms of closing the device so
49253 * indicate this port is now acting as a system console. */
49254 port->port.console = 1;
49255 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49256 free_tty:
49257 kfree(tty);
49258 reset_open_count:
49259 - port->port.count = 0;
49260 + atomic_set(&port->port.count, 0);
49261 usb_autopm_put_interface(serial->interface);
49262 error_get_interface:
49263 usb_serial_put(serial);
49264 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49265 index 75f70f0..d467e1a 100644
49266 --- a/drivers/usb/storage/usb.h
49267 +++ b/drivers/usb/storage/usb.h
49268 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49269 __u8 useProtocol;
49270 __u8 useTransport;
49271 int (*initFunction)(struct us_data *);
49272 -};
49273 +} __do_const;
49274
49275
49276 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49277 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49278 index d6bea3e..60b250e 100644
49279 --- a/drivers/usb/wusbcore/wa-hc.h
49280 +++ b/drivers/usb/wusbcore/wa-hc.h
49281 @@ -192,7 +192,7 @@ struct wahc {
49282 struct list_head xfer_delayed_list;
49283 spinlock_t xfer_list_lock;
49284 struct work_struct xfer_work;
49285 - atomic_t xfer_id_count;
49286 + atomic_unchecked_t xfer_id_count;
49287 };
49288
49289
49290 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49291 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49292 spin_lock_init(&wa->xfer_list_lock);
49293 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49294 - atomic_set(&wa->xfer_id_count, 1);
49295 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49296 }
49297
49298 /**
49299 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49300 index d3493ca..0c33b7e 100644
49301 --- a/drivers/usb/wusbcore/wa-xfer.c
49302 +++ b/drivers/usb/wusbcore/wa-xfer.c
49303 @@ -297,7 +297,7 @@ out:
49304 */
49305 static void wa_xfer_id_init(struct wa_xfer *xfer)
49306 {
49307 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49308 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49309 }
49310
49311 /*
49312 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49313 index 842f450..d1d7409 100644
49314 --- a/drivers/vfio/vfio.c
49315 +++ b/drivers/vfio/vfio.c
49316 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49317 return 0;
49318
49319 /* TODO Prevent device auto probing */
49320 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49321 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49322 iommu_group_id(group->iommu_group));
49323
49324 return 0;
49325 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49326 index 5174eba..86e764a 100644
49327 --- a/drivers/vhost/vringh.c
49328 +++ b/drivers/vhost/vringh.c
49329 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49330
49331 static inline int putu16_kern(u16 *p, u16 val)
49332 {
49333 - ACCESS_ONCE(*p) = val;
49334 + ACCESS_ONCE_RW(*p) = val;
49335 return 0;
49336 }
49337
49338 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49339 index a4dfe8c..297ddd9 100644
49340 --- a/drivers/video/aty/aty128fb.c
49341 +++ b/drivers/video/aty/aty128fb.c
49342 @@ -149,7 +149,7 @@ enum {
49343 };
49344
49345 /* Must match above enum */
49346 -static char * const r128_family[] = {
49347 +static const char * const r128_family[] = {
49348 "AGP",
49349 "PCI",
49350 "PRO AGP",
49351 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49352 index 9b0f12c..024673d 100644
49353 --- a/drivers/video/aty/atyfb_base.c
49354 +++ b/drivers/video/aty/atyfb_base.c
49355 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49356 par->accel_flags = var->accel_flags; /* hack */
49357
49358 if (var->accel_flags) {
49359 - info->fbops->fb_sync = atyfb_sync;
49360 + pax_open_kernel();
49361 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49362 + pax_close_kernel();
49363 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49364 } else {
49365 - info->fbops->fb_sync = NULL;
49366 + pax_open_kernel();
49367 + *(void **)&info->fbops->fb_sync = NULL;
49368 + pax_close_kernel();
49369 info->flags |= FBINFO_HWACCEL_DISABLED;
49370 }
49371
49372 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49373 index 95ec042..e6affdd 100644
49374 --- a/drivers/video/aty/mach64_cursor.c
49375 +++ b/drivers/video/aty/mach64_cursor.c
49376 @@ -7,6 +7,7 @@
49377 #include <linux/string.h>
49378
49379 #include <asm/io.h>
49380 +#include <asm/pgtable.h>
49381
49382 #ifdef __sparc__
49383 #include <asm/fbio.h>
49384 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49385 info->sprite.buf_align = 16; /* and 64 lines tall. */
49386 info->sprite.flags = FB_PIXMAP_IO;
49387
49388 - info->fbops->fb_cursor = atyfb_cursor;
49389 + pax_open_kernel();
49390 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49391 + pax_close_kernel();
49392
49393 return 0;
49394 }
49395 diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
49396 index a54ccdc..22ad8524 100644
49397 --- a/drivers/video/au1100fb.c
49398 +++ b/drivers/video/au1100fb.c
49399 @@ -361,37 +361,13 @@ void au1100fb_fb_rotate(struct fb_info *fbi, int angle)
49400 int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
49401 {
49402 struct au1100fb_device *fbdev;
49403 - unsigned int len;
49404 - unsigned long start=0, off;
49405
49406 fbdev = to_au1100fb_device(fbi);
49407
49408 - if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
49409 - return -EINVAL;
49410 - }
49411 -
49412 - start = fbdev->fb_phys & PAGE_MASK;
49413 - len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
49414 -
49415 - off = vma->vm_pgoff << PAGE_SHIFT;
49416 -
49417 - if ((vma->vm_end - vma->vm_start + off) > len) {
49418 - return -EINVAL;
49419 - }
49420 -
49421 - off += start;
49422 - vma->vm_pgoff = off >> PAGE_SHIFT;
49423 -
49424 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
49425 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
49426
49427 - if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
49428 - vma->vm_end - vma->vm_start,
49429 - vma->vm_page_prot)) {
49430 - return -EAGAIN;
49431 - }
49432 -
49433 - return 0;
49434 + return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
49435 }
49436
49437 static struct fb_ops au1100fb_ops =
49438 diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
49439 index 301224e..1d02897 100644
49440 --- a/drivers/video/au1200fb.c
49441 +++ b/drivers/video/au1200fb.c
49442 @@ -1233,34 +1233,13 @@ static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi)
49443 * method mainly to allow the use of the TLB streaming flag (CCA=6)
49444 */
49445 static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
49446 -
49447 {
49448 - unsigned int len;
49449 - unsigned long start=0, off;
49450 struct au1200fb_device *fbdev = info->par;
49451
49452 - if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
49453 - return -EINVAL;
49454 - }
49455 -
49456 - start = fbdev->fb_phys & PAGE_MASK;
49457 - len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
49458 -
49459 - off = vma->vm_pgoff << PAGE_SHIFT;
49460 -
49461 - if ((vma->vm_end - vma->vm_start + off) > len) {
49462 - return -EINVAL;
49463 - }
49464 -
49465 - off += start;
49466 - vma->vm_pgoff = off >> PAGE_SHIFT;
49467 -
49468 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
49469 pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */
49470
49471 - return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
49472 - vma->vm_end - vma->vm_start,
49473 - vma->vm_page_prot);
49474 + return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
49475 }
49476
49477 static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata)
49478 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49479 index bca6ccc..252107e 100644
49480 --- a/drivers/video/backlight/kb3886_bl.c
49481 +++ b/drivers/video/backlight/kb3886_bl.c
49482 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49483 static unsigned long kb3886bl_flags;
49484 #define KB3886BL_SUSPENDED 0x01
49485
49486 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49487 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49488 {
49489 .ident = "Sahara Touch-iT",
49490 .matches = {
49491 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49492 index 900aa4e..6d49418 100644
49493 --- a/drivers/video/fb_defio.c
49494 +++ b/drivers/video/fb_defio.c
49495 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49496
49497 BUG_ON(!fbdefio);
49498 mutex_init(&fbdefio->lock);
49499 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49500 + pax_open_kernel();
49501 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49502 + pax_close_kernel();
49503 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49504 INIT_LIST_HEAD(&fbdefio->pagelist);
49505 if (fbdefio->delay == 0) /* set a default of 1 s */
49506 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49507 page->mapping = NULL;
49508 }
49509
49510 - info->fbops->fb_mmap = NULL;
49511 + *(void **)&info->fbops->fb_mmap = NULL;
49512 mutex_destroy(&fbdefio->lock);
49513 }
49514 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49515 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49516 index 5c3960d..15cf8fc 100644
49517 --- a/drivers/video/fbcmap.c
49518 +++ b/drivers/video/fbcmap.c
49519 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49520 rc = -ENODEV;
49521 goto out;
49522 }
49523 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49524 - !info->fbops->fb_setcmap)) {
49525 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49526 rc = -EINVAL;
49527 goto out1;
49528 }
49529 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49530 index 36e1fe2..c744820 100644
49531 --- a/drivers/video/fbmem.c
49532 +++ b/drivers/video/fbmem.c
49533 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49534 image->dx += image->width + 8;
49535 }
49536 } else if (rotate == FB_ROTATE_UD) {
49537 - for (x = 0; x < num && image->dx >= 0; x++) {
49538 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49539 info->fbops->fb_imageblit(info, image);
49540 image->dx -= image->width + 8;
49541 }
49542 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49543 image->dy += image->height + 8;
49544 }
49545 } else if (rotate == FB_ROTATE_CCW) {
49546 - for (x = 0; x < num && image->dy >= 0; x++) {
49547 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49548 info->fbops->fb_imageblit(info, image);
49549 image->dy -= image->height + 8;
49550 }
49551 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49552 return -EFAULT;
49553 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49554 return -EINVAL;
49555 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49556 + if (con2fb.framebuffer >= FB_MAX)
49557 return -EINVAL;
49558 if (!registered_fb[con2fb.framebuffer])
49559 request_module("fb%d", con2fb.framebuffer);
49560 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49561 index d4d2c5f..ebbd113 100644
49562 --- a/drivers/video/hyperv_fb.c
49563 +++ b/drivers/video/hyperv_fb.c
49564 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49565 static inline int synthvid_send(struct hv_device *hdev,
49566 struct synthvid_msg *msg)
49567 {
49568 - static atomic64_t request_id = ATOMIC64_INIT(0);
49569 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49570 int ret;
49571
49572 msg->pipe_hdr.type = PIPE_MSG_DATA;
49573 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49574
49575 ret = vmbus_sendpacket(hdev->channel, msg,
49576 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49577 - atomic64_inc_return(&request_id),
49578 + atomic64_inc_return_unchecked(&request_id),
49579 VM_PKT_DATA_INBAND, 0);
49580
49581 if (ret)
49582 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49583 index 7672d2e..b56437f 100644
49584 --- a/drivers/video/i810/i810_accel.c
49585 +++ b/drivers/video/i810/i810_accel.c
49586 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49587 }
49588 }
49589 printk("ringbuffer lockup!!!\n");
49590 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49591 i810_report_error(mmio);
49592 par->dev_flags |= LOCKUP;
49593 info->pixmap.scan_align = 1;
49594 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49595 index 285d552..eafa544 100644
49596 --- a/drivers/video/logo/logo_linux_clut224.ppm
49597 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49598 @@ -1,883 +1,1123 @@
49599 P3
49600 80 80
49601 255
49602 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49603 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49604 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49605 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49606 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49607 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49608 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49609 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49610 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49611 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49612 -
49613 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49614 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49615 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49616 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49617 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49618 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49619 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49620 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49621 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49622 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49623 -
49624 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49625 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49626 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49627 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49628 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49629 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49630 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49631 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49632 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49633 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49634 -
49635 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49636 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49637 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49638 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49639 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49640 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49641 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49642 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49643 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49644 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49645 -
49646 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49647 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49648 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49649 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49650 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49651 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49652 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49653 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49654 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49655 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49656 -
49657 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49658 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49659 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49660 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49661 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49662 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49663 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49664 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49665 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49666 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49667 -
49668 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49669 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49670 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49671 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49672 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49673 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49674 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49675 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49676 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49677 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49678 -
49679 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49680 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49681 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49682 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49683 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49684 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49685 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49686 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49687 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49688 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49689 -
49690 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49691 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49692 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49693 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49694 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49695 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49696 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49697 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49698 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49699 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49700 -
49701 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49702 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49703 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49704 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49705 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49706 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49707 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49708 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49709 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49710 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49711 -
49712 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49713 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49714 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49715 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49716 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49717 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49718 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49719 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49720 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49721 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49722 -
49723 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49724 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49725 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49726 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49727 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49728 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49729 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49730 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49731 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49732 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49733 -
49734 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49735 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49736 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49737 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49738 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49739 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49740 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49741 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49742 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49743 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49744 -
49745 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49746 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49747 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49748 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49749 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49750 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49751 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49752 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49753 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49754 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49755 -
49756 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49757 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49758 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49759 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49760 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49761 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49762 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49763 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49764 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49765 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49766 -
49767 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49768 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49769 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49770 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49771 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49772 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49773 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49774 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49775 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49776 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49777 -
49778 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49779 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49780 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49781 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49782 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49783 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49784 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49785 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49786 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49787 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49788 -
49789 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49790 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49791 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49792 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49793 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49794 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49795 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49796 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49797 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49798 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49799 -
49800 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49801 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49802 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49803 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49804 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49805 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49806 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49807 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49808 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49809 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49810 -
49811 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49812 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49813 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49814 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49815 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49816 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49817 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49818 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49819 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49820 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49821 -
49822 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49823 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49824 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49825 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49826 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49827 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49828 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49829 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49830 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49831 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49832 -
49833 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49834 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49835 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49836 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49837 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49838 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49839 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49840 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49841 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49842 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49843 -
49844 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49845 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49846 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49847 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49848 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49849 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49850 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49851 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49852 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49853 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49854 -
49855 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49856 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49857 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49858 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49859 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49860 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49861 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49862 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49863 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49864 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49865 -
49866 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49867 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49868 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49869 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49870 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49871 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49872 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49873 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49874 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49875 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49876 -
49877 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49878 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49879 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49880 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49881 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49882 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49883 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49884 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49885 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49886 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49887 -
49888 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49889 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49890 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49891 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49892 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49893 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49894 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49895 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49896 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49897 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49898 -
49899 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49900 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49901 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49902 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49903 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49904 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49905 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49906 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49907 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49908 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49909 -
49910 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49911 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49912 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49913 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49914 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49915 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49916 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49917 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49918 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49919 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49920 -
49921 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49922 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49923 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49924 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49925 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49926 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49927 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49928 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49929 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49930 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49931 -
49932 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49933 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49934 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49935 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49936 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49937 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49938 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49939 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49940 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49941 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49942 -
49943 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49944 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49945 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49946 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49947 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49948 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49949 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49950 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49951 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49952 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49953 -
49954 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
49955 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49956 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49957 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49958 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49959 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49960 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49961 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
49962 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49963 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49964 -
49965 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49966 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49967 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
49968 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49969 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49970 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49971 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49972 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
49973 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49974 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49975 -
49976 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49977 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49978 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49979 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49980 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49981 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49982 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49983 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
49984 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49985 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49986 -
49987 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49988 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
49989 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49990 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49991 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49992 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49993 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49994 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
49995 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49996 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49997 -
49998 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49999 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
50000 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
50001 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
50002 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
50003 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
50004 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
50005 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
50006 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50007 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50008 -
50009 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50010 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
50011 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
50012 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
50013 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
50014 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
50015 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
50016 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
50017 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50018 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50019 -
50020 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50021 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
50022 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
50023 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50024 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50025 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50026 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50027 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50028 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50029 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50030 -
50031 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50032 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50033 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50034 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50035 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50036 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50037 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50038 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50039 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50040 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50041 -
50042 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50043 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50044 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50045 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50046 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50047 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50048 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50049 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50050 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50051 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50052 -
50053 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50054 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50055 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50056 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50057 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50058 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50059 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50060 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50061 -58 58 58 22 22 22 6 6 6 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50063 -
50064 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50065 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50066 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50067 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50068 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50069 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50070 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50071 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50072 -78 78 78 30 30 30 10 10 10 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50074 -
50075 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 21 30 33
50077 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50078 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50079 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50080 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50081 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50082 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50083 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50084 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50085 -
50086 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50087 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50088 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50089 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50090 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50091 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50092 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50093 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50094 -74 74 74 58 58 58 22 22 22 6 6 6 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 0 0 0 0 0 0 0 0 0 0 0 0
50096 -
50097 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50099 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50100 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50101 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50102 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50103 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50104 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50105 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50106 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50107 -
50108 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50110 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50111 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50112 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50113 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50114 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50115 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50116 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50117 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50118 -
50119 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50121 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50122 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50123 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50124 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50125 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50126 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50127 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50128 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50129 -
50130 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 6 6 6
50132 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50133 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50134 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50135 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50136 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50137 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50138 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50139 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50140 -
50141 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50142 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50143 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50144 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50145 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50146 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50147 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50148 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50149 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50150 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50151 -
50152 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 10 10 10
50154 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50155 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50156 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50157 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50158 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50159 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50160 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50161 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50162 -
50163 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50164 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50165 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50166 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50167 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50168 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50169 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50170 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50171 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50172 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50173 -
50174 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 6 6 6 18 18 18
50176 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50177 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50179 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50180 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50181 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50182 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50183 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50184 -
50185 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50186 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50187 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50188 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50189 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50190 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50191 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50192 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50193 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50194 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50195 -
50196 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50197 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50198 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50199 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50201 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50202 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50203 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50204 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50205 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50206 -
50207 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50208 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50209 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50210 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50211 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50212 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50213 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50214 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50215 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50216 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50217 -
50218 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50219 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50220 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50221 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50223 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50224 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50225 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50226 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50227 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50228 -
50229 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50230 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50231 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50232 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50233 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50234 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50235 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50236 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50237 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50238 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50239 -
50240 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50241 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50242 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50243 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50244 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50245 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50246 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50247 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50248 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50249 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50250 -
50251 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50252 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50253 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50254 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50255 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50256 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50257 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50258 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50259 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50260 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50261 -
50262 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50263 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50264 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50265 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50266 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50267 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50268 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50269 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50270 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50271 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50272 -
50273 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50274 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50275 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50276 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50277 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50278 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50279 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50280 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50281 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50282 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50283 -
50284 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50285 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50286 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50287 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50288 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50289 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50290 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50291 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50292 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50293 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50294 -
50295 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50296 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50297 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50298 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50299 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50300 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50301 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50302 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50303 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50304 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50305 -
50306 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50307 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50308 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50309 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50310 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50311 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50312 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50313 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50314 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50315 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50316 -
50317 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50318 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50319 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50320 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50321 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50322 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50323 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50324 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50325 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50326 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50327 -
50328 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50329 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50330 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50331 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50332 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50333 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50334 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50335 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50336 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50337 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50338 -
50339 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50340 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50341 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50342 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50343 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50344 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50345 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50346 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50347 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50348 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50349 -
50350 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50351 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50352 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50353 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50354 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50355 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50356 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50357 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50358 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50359 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50360 -
50361 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50362 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50363 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50364 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50365 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50366 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50367 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50368 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50369 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50370 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50371 -
50372 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50373 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50374 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50375 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50376 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50377 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50378 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50379 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50380 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50381 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50382 -
50383 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50384 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50385 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50386 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50387 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50388 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50389 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50390 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50391 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50392 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50393 -
50394 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50395 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50396 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50397 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50398 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50399 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50400 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50401 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50402 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50403 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50404 -
50405 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50406 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50407 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50408 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50409 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50410 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50411 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50412 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50413 -50 50 50 30 30 30 14 14 14 6 6 6 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 0 0 0 0 0 0 0 0 0 0 0 0
50415 -
50416 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50417 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50418 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50419 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50420 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50421 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50422 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50423 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50424 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50425 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50426 -
50427 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50428 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50429 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50430 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50431 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50432 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50433 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50434 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50435 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50436 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50437 -
50438 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 6 6 6 6 6 6 10 10 10
50440 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50441 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50442 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50443 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50444 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50445 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50446 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50447 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50448 -
50449 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50451 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50452 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50453 -30 30 30 14 14 14 6 6 6 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50455 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50456 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50457 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50459 -
50460 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50461 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50462 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50463 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50464 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50465 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50466 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50467 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50468 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50469 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50470 -
50471 -0 0 0 0 0 0 0 0 0 0 0 0 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 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 0 0 0 0 0 0 0 0 0 6 6 6
50474 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50475 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50477 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50478 -18 18 18 14 14 14 10 10 10 6 6 6 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 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 0 0 0 0 0 0 0 0 0 0 0 0
50481 -
50482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50495 +4 4 4 4 4 4
50496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50509 +4 4 4 4 4 4
50510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50523 +4 4 4 4 4 4
50524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50537 +4 4 4 4 4 4
50538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50551 +4 4 4 4 4 4
50552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50565 +4 4 4 4 4 4
50566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50570 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50571 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50575 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50576 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50577 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50579 +4 4 4 4 4 4
50580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50584 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50585 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50586 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50589 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50590 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50591 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50592 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50593 +4 4 4 4 4 4
50594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50598 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50599 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50600 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50603 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50604 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50605 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50606 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50607 +4 4 4 4 4 4
50608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50611 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50612 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50613 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50614 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50616 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50617 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50618 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50619 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50620 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50621 +4 4 4 4 4 4
50622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50625 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50626 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50627 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50628 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50629 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50630 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50631 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50632 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50633 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50634 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50635 +4 4 4 4 4 4
50636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50639 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50640 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50641 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50642 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50643 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50644 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50645 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50646 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50647 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50648 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50649 +4 4 4 4 4 4
50650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50652 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50653 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50654 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50655 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50656 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50657 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50658 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50659 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50660 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50661 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50662 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50663 +4 4 4 4 4 4
50664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50666 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50667 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50668 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50669 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50670 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50671 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50672 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50673 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50674 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50675 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50676 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50677 +4 4 4 4 4 4
50678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50680 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50681 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50682 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50683 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50684 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50685 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50686 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50687 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50688 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50689 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50690 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50691 +4 4 4 4 4 4
50692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50694 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50695 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50696 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50697 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50698 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50699 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50700 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50701 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50702 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50703 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50704 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50705 +4 4 4 4 4 4
50706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50707 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50708 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50709 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50710 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50711 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50712 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50713 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50714 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50715 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50716 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50717 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50718 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50719 +4 4 4 4 4 4
50720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50721 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50722 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50723 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50724 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50725 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50726 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50727 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50728 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50729 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50730 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50731 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50732 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50733 +0 0 0 4 4 4
50734 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50735 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50736 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50737 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50738 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50739 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50740 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50741 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50742 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50743 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50744 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50745 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50746 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50747 +2 0 0 0 0 0
50748 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50749 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50750 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50751 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50752 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50753 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50754 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50755 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50756 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50757 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50758 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50759 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50760 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50761 +37 38 37 0 0 0
50762 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50763 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50764 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50765 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50766 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50767 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50768 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50769 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50770 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50771 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50772 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50773 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50774 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50775 +85 115 134 4 0 0
50776 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50777 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50778 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50779 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50780 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50781 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50782 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50783 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50784 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50785 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50786 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50787 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50788 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50789 +60 73 81 4 0 0
50790 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50791 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50792 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50793 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50794 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50795 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50796 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50797 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50798 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50799 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50800 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50801 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50802 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50803 +16 19 21 4 0 0
50804 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50805 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50806 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50807 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50808 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50809 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50810 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50811 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50812 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50813 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50814 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50815 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50816 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50817 +4 0 0 4 3 3
50818 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50819 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50820 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50822 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50823 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50824 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50825 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50826 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50827 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50828 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50829 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50830 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50831 +3 2 2 4 4 4
50832 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50833 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50834 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50835 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50836 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50837 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50838 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50839 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50840 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50841 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50842 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50843 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50844 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50845 +4 4 4 4 4 4
50846 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50847 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50848 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50849 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50850 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50851 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50852 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50853 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50854 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50855 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50856 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50857 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50858 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50859 +4 4 4 4 4 4
50860 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50861 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50862 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50863 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50864 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50865 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50866 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50867 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50868 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50869 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50870 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50871 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50872 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50873 +5 5 5 5 5 5
50874 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50875 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50876 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50877 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50878 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50879 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50880 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50881 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50882 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50883 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50884 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50885 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50886 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50887 +5 5 5 4 4 4
50888 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50889 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50890 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50891 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50892 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50893 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50894 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50895 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50896 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50897 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50898 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50899 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50901 +4 4 4 4 4 4
50902 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50903 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50904 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50905 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50906 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50907 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50908 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50909 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50910 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50911 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50912 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50913 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50915 +4 4 4 4 4 4
50916 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50917 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50918 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50919 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50920 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50921 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50922 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50923 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50924 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50925 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50926 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50929 +4 4 4 4 4 4
50930 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50931 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50932 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50933 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50934 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50935 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50936 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50937 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50938 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50939 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50940 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50943 +4 4 4 4 4 4
50944 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50945 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50946 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50947 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50948 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50949 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50950 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50951 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50952 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50953 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50954 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50957 +4 4 4 4 4 4
50958 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50959 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50960 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50961 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50962 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50963 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50964 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50965 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50966 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50967 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50968 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50971 +4 4 4 4 4 4
50972 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50973 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50974 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50975 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50976 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50977 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50978 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50979 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50980 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50981 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50982 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50985 +4 4 4 4 4 4
50986 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50987 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50988 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50989 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50990 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50991 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50992 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50993 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50994 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50995 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50996 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50999 +4 4 4 4 4 4
51000 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51001 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51002 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51003 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51004 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51005 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51006 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51007 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51008 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51009 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51010 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51013 +4 4 4 4 4 4
51014 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51015 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51016 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51017 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51018 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51019 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51020 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51021 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51022 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51023 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51024 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51027 +4 4 4 4 4 4
51028 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51029 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51030 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51031 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51032 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51033 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51034 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51035 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51036 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51037 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51038 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51041 +4 4 4 4 4 4
51042 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51043 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51044 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51045 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51046 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51047 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51048 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51049 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51050 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51051 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51052 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51055 +4 4 4 4 4 4
51056 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51057 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51058 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51059 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51060 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51061 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51062 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51063 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51064 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51065 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51066 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51069 +4 4 4 4 4 4
51070 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51071 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51072 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51073 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51074 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51075 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51076 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51077 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51078 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51079 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51080 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51083 +4 4 4 4 4 4
51084 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51085 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51086 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51087 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51088 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51089 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51090 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51091 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51092 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51093 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51094 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51097 +4 4 4 4 4 4
51098 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51099 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51100 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51101 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51102 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51103 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51104 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51105 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51106 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51107 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51108 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51111 +4 4 4 4 4 4
51112 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51113 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51114 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51115 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51116 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51117 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51118 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51119 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51120 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51121 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51122 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51125 +4 4 4 4 4 4
51126 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51127 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51128 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51129 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51130 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51131 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51132 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51133 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51134 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51135 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51136 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51139 +4 4 4 4 4 4
51140 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51141 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51142 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51143 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51144 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51145 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51146 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51147 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51148 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51149 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51150 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51153 +4 4 4 4 4 4
51154 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51155 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51156 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51157 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51158 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51159 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51160 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51161 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51162 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51163 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51164 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51167 +4 4 4 4 4 4
51168 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51169 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51170 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51171 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51172 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51173 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51174 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51175 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51176 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51177 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51178 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51181 +4 4 4 4 4 4
51182 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51183 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51184 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51185 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51186 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51187 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51188 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51189 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51190 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51191 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51192 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51195 +4 4 4 4 4 4
51196 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51197 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51198 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51199 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51200 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51201 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51202 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51203 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51204 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51205 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51206 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51209 +4 4 4 4 4 4
51210 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51211 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51212 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51213 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51214 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51215 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51216 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51217 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51218 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51219 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51220 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51223 +4 4 4 4 4 4
51224 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51225 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51226 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51228 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51229 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51230 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51231 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51232 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51233 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51234 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51237 +4 4 4 4 4 4
51238 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51239 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51240 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51241 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51242 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51243 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51244 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51245 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51246 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51247 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51248 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51251 +4 4 4 4 4 4
51252 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51253 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51254 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51255 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51256 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51257 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51258 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51259 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51260 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51261 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51262 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51265 +4 4 4 4 4 4
51266 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51267 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51268 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51269 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51270 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51271 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51272 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51273 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51274 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51275 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51276 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51279 +4 4 4 4 4 4
51280 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51281 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51282 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51283 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51284 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51285 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51286 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51287 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51288 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51289 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51290 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51293 +4 4 4 4 4 4
51294 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51295 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51296 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51297 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51298 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51299 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51300 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51301 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51302 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51303 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51307 +4 4 4 4 4 4
51308 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51309 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51310 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51311 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51312 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51313 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51314 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51315 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51316 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51317 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51321 +4 4 4 4 4 4
51322 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51323 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51324 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51325 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51326 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51327 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51328 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51329 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51330 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51331 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51335 +4 4 4 4 4 4
51336 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51337 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51338 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51339 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51340 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51341 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51342 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51343 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51344 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51345 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51349 +4 4 4 4 4 4
51350 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51351 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51352 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51353 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51354 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51355 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51356 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51357 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51358 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51363 +4 4 4 4 4 4
51364 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51365 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51366 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51367 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51368 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51369 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51370 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51371 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51372 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51377 +4 4 4 4 4 4
51378 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51379 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51380 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51381 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51382 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51383 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51384 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51385 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51386 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51391 +4 4 4 4 4 4
51392 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51393 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51394 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51395 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51396 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51397 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51398 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51399 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51405 +4 4 4 4 4 4
51406 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51407 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51408 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51409 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51410 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51411 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51412 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51413 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51419 +4 4 4 4 4 4
51420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51421 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51422 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51423 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51424 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51425 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51426 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51427 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51433 +4 4 4 4 4 4
51434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51435 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51436 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51437 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51438 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51439 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51440 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51441 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51447 +4 4 4 4 4 4
51448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51449 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51450 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51451 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51452 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51453 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51454 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51455 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51461 +4 4 4 4 4 4
51462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51464 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51465 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51466 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51467 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51468 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51469 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51475 +4 4 4 4 4 4
51476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51479 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51480 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51481 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51482 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51489 +4 4 4 4 4 4
51490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51493 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51494 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51495 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51496 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51503 +4 4 4 4 4 4
51504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51507 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51508 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51509 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51510 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51517 +4 4 4 4 4 4
51518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51521 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51522 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51523 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51524 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51531 +4 4 4 4 4 4
51532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51536 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51537 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51538 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51545 +4 4 4 4 4 4
51546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51550 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51551 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51552 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51559 +4 4 4 4 4 4
51560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51564 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51565 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51566 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 4 4 4
51574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51578 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51579 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51587 +4 4 4 4 4 4
51588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51592 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51593 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51601 +4 4 4 4 4 4
51602 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51603 index fe92eed..106e085 100644
51604 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51605 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51606 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51607 struct mb862xxfb_par *par = info->par;
51608
51609 if (info->var.bits_per_pixel == 32) {
51610 - info->fbops->fb_fillrect = cfb_fillrect;
51611 - info->fbops->fb_copyarea = cfb_copyarea;
51612 - info->fbops->fb_imageblit = cfb_imageblit;
51613 + pax_open_kernel();
51614 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51615 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51616 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51617 + pax_close_kernel();
51618 } else {
51619 outreg(disp, GC_L0EM, 3);
51620 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51621 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51622 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51623 + pax_open_kernel();
51624 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51625 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51626 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51627 + pax_close_kernel();
51628 }
51629 outreg(draw, GDC_REG_DRAW_BASE, 0);
51630 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51631 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51632 index ff22871..b129bed 100644
51633 --- a/drivers/video/nvidia/nvidia.c
51634 +++ b/drivers/video/nvidia/nvidia.c
51635 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51636 info->fix.line_length = (info->var.xres_virtual *
51637 info->var.bits_per_pixel) >> 3;
51638 if (info->var.accel_flags) {
51639 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51640 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51641 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51642 - info->fbops->fb_sync = nvidiafb_sync;
51643 + pax_open_kernel();
51644 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51645 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51646 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51647 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51648 + pax_close_kernel();
51649 info->pixmap.scan_align = 4;
51650 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51651 info->flags |= FBINFO_READS_FAST;
51652 NVResetGraphics(info);
51653 } else {
51654 - info->fbops->fb_imageblit = cfb_imageblit;
51655 - info->fbops->fb_fillrect = cfb_fillrect;
51656 - info->fbops->fb_copyarea = cfb_copyarea;
51657 - info->fbops->fb_sync = NULL;
51658 + pax_open_kernel();
51659 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51660 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51661 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51662 + *(void **)&info->fbops->fb_sync = NULL;
51663 + pax_close_kernel();
51664 info->pixmap.scan_align = 1;
51665 info->flags |= FBINFO_HWACCEL_DISABLED;
51666 info->flags &= ~FBINFO_READS_FAST;
51667 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51668 info->pixmap.size = 8 * 1024;
51669 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51670
51671 - if (!hwcur)
51672 - info->fbops->fb_cursor = NULL;
51673 + if (!hwcur) {
51674 + pax_open_kernel();
51675 + *(void **)&info->fbops->fb_cursor = NULL;
51676 + pax_close_kernel();
51677 + }
51678
51679 info->var.accel_flags = (!noaccel);
51680
51681 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51682 index 05c2dc3..ea1f391 100644
51683 --- a/drivers/video/s1d13xxxfb.c
51684 +++ b/drivers/video/s1d13xxxfb.c
51685 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51686
51687 switch(prod_id) {
51688 case S1D13506_PROD_ID: /* activate acceleration */
51689 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51690 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51691 + pax_open_kernel();
51692 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51693 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51694 + pax_close_kernel();
51695 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51696 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51697 break;
51698 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51699 index e188ada..aac63c8 100644
51700 --- a/drivers/video/smscufx.c
51701 +++ b/drivers/video/smscufx.c
51702 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51703 fb_deferred_io_cleanup(info);
51704 kfree(info->fbdefio);
51705 info->fbdefio = NULL;
51706 - info->fbops->fb_mmap = ufx_ops_mmap;
51707 + pax_open_kernel();
51708 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51709 + pax_close_kernel();
51710 }
51711
51712 pr_debug("released /dev/fb%d user=%d count=%d",
51713 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51714 index d2e5bc3..4cb05d1 100644
51715 --- a/drivers/video/udlfb.c
51716 +++ b/drivers/video/udlfb.c
51717 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51718 dlfb_urb_completion(urb);
51719
51720 error:
51721 - atomic_add(bytes_sent, &dev->bytes_sent);
51722 - atomic_add(bytes_identical, &dev->bytes_identical);
51723 - atomic_add(width*height*2, &dev->bytes_rendered);
51724 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51725 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51726 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51727 end_cycles = get_cycles();
51728 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51729 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51730 >> 10)), /* Kcycles */
51731 &dev->cpu_kcycles_used);
51732
51733 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51734 dlfb_urb_completion(urb);
51735
51736 error:
51737 - atomic_add(bytes_sent, &dev->bytes_sent);
51738 - atomic_add(bytes_identical, &dev->bytes_identical);
51739 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51740 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51741 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51742 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51743 end_cycles = get_cycles();
51744 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51745 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51746 >> 10)), /* Kcycles */
51747 &dev->cpu_kcycles_used);
51748 }
51749 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51750 fb_deferred_io_cleanup(info);
51751 kfree(info->fbdefio);
51752 info->fbdefio = NULL;
51753 - info->fbops->fb_mmap = dlfb_ops_mmap;
51754 + pax_open_kernel();
51755 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51756 + pax_close_kernel();
51757 }
51758
51759 pr_warn("released /dev/fb%d user=%d count=%d\n",
51760 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51761 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51762 struct dlfb_data *dev = fb_info->par;
51763 return snprintf(buf, PAGE_SIZE, "%u\n",
51764 - atomic_read(&dev->bytes_rendered));
51765 + atomic_read_unchecked(&dev->bytes_rendered));
51766 }
51767
51768 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51769 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51770 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51771 struct dlfb_data *dev = fb_info->par;
51772 return snprintf(buf, PAGE_SIZE, "%u\n",
51773 - atomic_read(&dev->bytes_identical));
51774 + atomic_read_unchecked(&dev->bytes_identical));
51775 }
51776
51777 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51778 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51779 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51780 struct dlfb_data *dev = fb_info->par;
51781 return snprintf(buf, PAGE_SIZE, "%u\n",
51782 - atomic_read(&dev->bytes_sent));
51783 + atomic_read_unchecked(&dev->bytes_sent));
51784 }
51785
51786 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51787 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51788 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51789 struct dlfb_data *dev = fb_info->par;
51790 return snprintf(buf, PAGE_SIZE, "%u\n",
51791 - atomic_read(&dev->cpu_kcycles_used));
51792 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51793 }
51794
51795 static ssize_t edid_show(
51796 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51797 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51798 struct dlfb_data *dev = fb_info->par;
51799
51800 - atomic_set(&dev->bytes_rendered, 0);
51801 - atomic_set(&dev->bytes_identical, 0);
51802 - atomic_set(&dev->bytes_sent, 0);
51803 - atomic_set(&dev->cpu_kcycles_used, 0);
51804 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51805 + atomic_set_unchecked(&dev->bytes_identical, 0);
51806 + atomic_set_unchecked(&dev->bytes_sent, 0);
51807 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51808
51809 return count;
51810 }
51811 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51812 index 7aec6f3..e3b2d55 100644
51813 --- a/drivers/video/uvesafb.c
51814 +++ b/drivers/video/uvesafb.c
51815 @@ -19,6 +19,7 @@
51816 #include <linux/io.h>
51817 #include <linux/mutex.h>
51818 #include <linux/slab.h>
51819 +#include <linux/moduleloader.h>
51820 #include <video/edid.h>
51821 #include <video/uvesafb.h>
51822 #ifdef CONFIG_X86
51823 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51824 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51825 par->pmi_setpal = par->ypan = 0;
51826 } else {
51827 +
51828 +#ifdef CONFIG_PAX_KERNEXEC
51829 +#ifdef CONFIG_MODULES
51830 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51831 +#endif
51832 + if (!par->pmi_code) {
51833 + par->pmi_setpal = par->ypan = 0;
51834 + return 0;
51835 + }
51836 +#endif
51837 +
51838 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51839 + task->t.regs.edi);
51840 +
51841 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51842 + pax_open_kernel();
51843 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51844 + pax_close_kernel();
51845 +
51846 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51847 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51848 +#else
51849 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51850 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51851 +#endif
51852 +
51853 printk(KERN_INFO "uvesafb: protected mode interface info at "
51854 "%04x:%04x\n",
51855 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51856 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51857 par->ypan = ypan;
51858
51859 if (par->pmi_setpal || par->ypan) {
51860 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51861 if (__supported_pte_mask & _PAGE_NX) {
51862 par->pmi_setpal = par->ypan = 0;
51863 printk(KERN_WARNING "uvesafb: NX protection is active, "
51864 "better not use the PMI.\n");
51865 - } else {
51866 + } else
51867 +#endif
51868 uvesafb_vbe_getpmi(task, par);
51869 - }
51870 }
51871 #else
51872 /* The protected mode interface is not available on non-x86. */
51873 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51874 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51875
51876 /* Disable blanking if the user requested so. */
51877 - if (!blank)
51878 - info->fbops->fb_blank = NULL;
51879 + if (!blank) {
51880 + pax_open_kernel();
51881 + *(void **)&info->fbops->fb_blank = NULL;
51882 + pax_close_kernel();
51883 + }
51884
51885 /*
51886 * Find out how much IO memory is required for the mode with
51887 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51888 info->flags = FBINFO_FLAG_DEFAULT |
51889 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51890
51891 - if (!par->ypan)
51892 - info->fbops->fb_pan_display = NULL;
51893 + if (!par->ypan) {
51894 + pax_open_kernel();
51895 + *(void **)&info->fbops->fb_pan_display = NULL;
51896 + pax_close_kernel();
51897 + }
51898 }
51899
51900 static void uvesafb_init_mtrr(struct fb_info *info)
51901 @@ -1796,6 +1826,11 @@ out:
51902 if (par->vbe_modes)
51903 kfree(par->vbe_modes);
51904
51905 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51906 + if (par->pmi_code)
51907 + module_free_exec(NULL, par->pmi_code);
51908 +#endif
51909 +
51910 framebuffer_release(info);
51911 return err;
51912 }
51913 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51914 kfree(par->vbe_state_orig);
51915 if (par->vbe_state_saved)
51916 kfree(par->vbe_state_saved);
51917 +
51918 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51919 + if (par->pmi_code)
51920 + module_free_exec(NULL, par->pmi_code);
51921 +#endif
51922 +
51923 }
51924
51925 framebuffer_release(info);
51926 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51927 index 501b340..d80aa17 100644
51928 --- a/drivers/video/vesafb.c
51929 +++ b/drivers/video/vesafb.c
51930 @@ -9,6 +9,7 @@
51931 */
51932
51933 #include <linux/module.h>
51934 +#include <linux/moduleloader.h>
51935 #include <linux/kernel.h>
51936 #include <linux/errno.h>
51937 #include <linux/string.h>
51938 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51939 static int vram_total __initdata; /* Set total amount of memory */
51940 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51941 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51942 -static void (*pmi_start)(void) __read_mostly;
51943 -static void (*pmi_pal) (void) __read_mostly;
51944 +static void (*pmi_start)(void) __read_only;
51945 +static void (*pmi_pal) (void) __read_only;
51946 static int depth __read_mostly;
51947 static int vga_compat __read_mostly;
51948 /* --------------------------------------------------------------------- */
51949 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51950 unsigned int size_vmode;
51951 unsigned int size_remap;
51952 unsigned int size_total;
51953 + void *pmi_code = NULL;
51954
51955 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51956 return -ENODEV;
51957 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51958 size_remap = size_total;
51959 vesafb_fix.smem_len = size_remap;
51960
51961 -#ifndef __i386__
51962 - screen_info.vesapm_seg = 0;
51963 -#endif
51964 -
51965 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51966 printk(KERN_WARNING
51967 "vesafb: cannot reserve video memory at 0x%lx\n",
51968 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51969 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51970 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51971
51972 +#ifdef __i386__
51973 +
51974 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51975 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51976 + if (!pmi_code)
51977 +#elif !defined(CONFIG_PAX_KERNEXEC)
51978 + if (0)
51979 +#endif
51980 +
51981 +#endif
51982 + screen_info.vesapm_seg = 0;
51983 +
51984 if (screen_info.vesapm_seg) {
51985 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51986 - screen_info.vesapm_seg,screen_info.vesapm_off);
51987 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51988 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51989 }
51990
51991 if (screen_info.vesapm_seg < 0xc000)
51992 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51993
51994 if (ypan || pmi_setpal) {
51995 unsigned short *pmi_base;
51996 +
51997 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51998 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51999 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52000 +
52001 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52002 + pax_open_kernel();
52003 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52004 +#else
52005 + pmi_code = pmi_base;
52006 +#endif
52007 +
52008 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52009 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52010 +
52011 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52012 + pmi_start = ktva_ktla(pmi_start);
52013 + pmi_pal = ktva_ktla(pmi_pal);
52014 + pax_close_kernel();
52015 +#endif
52016 +
52017 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52018 if (pmi_base[3]) {
52019 printk(KERN_INFO "vesafb: pmi: ports = ");
52020 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52021 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52022 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52023
52024 - if (!ypan)
52025 - info->fbops->fb_pan_display = NULL;
52026 + if (!ypan) {
52027 + pax_open_kernel();
52028 + *(void **)&info->fbops->fb_pan_display = NULL;
52029 + pax_close_kernel();
52030 + }
52031
52032 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52033 err = -ENOMEM;
52034 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52035 info->node, info->fix.id);
52036 return 0;
52037 err:
52038 +
52039 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52040 + module_free_exec(NULL, pmi_code);
52041 +#endif
52042 +
52043 if (info->screen_base)
52044 iounmap(info->screen_base);
52045 framebuffer_release(info);
52046 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52047 index 88714ae..16c2e11 100644
52048 --- a/drivers/video/via/via_clock.h
52049 +++ b/drivers/video/via/via_clock.h
52050 @@ -56,7 +56,7 @@ struct via_clock {
52051
52052 void (*set_engine_pll_state)(u8 state);
52053 void (*set_engine_pll)(struct via_pll_config config);
52054 -};
52055 +} __no_const;
52056
52057
52058 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52059 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52060 index fef20db..d28b1ab 100644
52061 --- a/drivers/xen/xenfs/xenstored.c
52062 +++ b/drivers/xen/xenfs/xenstored.c
52063 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52064 static int xsd_kva_open(struct inode *inode, struct file *file)
52065 {
52066 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52067 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52068 + NULL);
52069 +#else
52070 xen_store_interface);
52071 +#endif
52072 +
52073 if (!file->private_data)
52074 return -ENOMEM;
52075 return 0;
52076 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52077 index 9ff073f..05cef23 100644
52078 --- a/fs/9p/vfs_addr.c
52079 +++ b/fs/9p/vfs_addr.c
52080 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52081
52082 retval = v9fs_file_write_internal(inode,
52083 v9inode->writeback_fid,
52084 - (__force const char __user *)buffer,
52085 + (const char __force_user *)buffer,
52086 len, &offset, 0);
52087 if (retval > 0)
52088 retval = 0;
52089 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52090 index 25b018e..b941525 100644
52091 --- a/fs/9p/vfs_inode.c
52092 +++ b/fs/9p/vfs_inode.c
52093 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52094 void
52095 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52096 {
52097 - char *s = nd_get_link(nd);
52098 + const char *s = nd_get_link(nd);
52099
52100 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52101 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52102 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52103 index 370b24c..ff0be7b 100644
52104 --- a/fs/Kconfig.binfmt
52105 +++ b/fs/Kconfig.binfmt
52106 @@ -103,7 +103,7 @@ config HAVE_AOUT
52107
52108 config BINFMT_AOUT
52109 tristate "Kernel support for a.out and ECOFF binaries"
52110 - depends on HAVE_AOUT
52111 + depends on HAVE_AOUT && BROKEN
52112 ---help---
52113 A.out (Assembler.OUTput) is a set of formats for libraries and
52114 executables used in the earliest versions of UNIX. Linux used
52115 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52116 index 789bc25..fafaeea 100644
52117 --- a/fs/afs/inode.c
52118 +++ b/fs/afs/inode.c
52119 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52120 struct afs_vnode *vnode;
52121 struct super_block *sb;
52122 struct inode *inode;
52123 - static atomic_t afs_autocell_ino;
52124 + static atomic_unchecked_t afs_autocell_ino;
52125
52126 _enter("{%x:%u},%*.*s,",
52127 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52128 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52129 data.fid.unique = 0;
52130 data.fid.vnode = 0;
52131
52132 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52133 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52134 afs_iget5_autocell_test, afs_iget5_set,
52135 &data);
52136 if (!inode) {
52137 diff --git a/fs/aio.c b/fs/aio.c
52138 index 9b5ca11..c530886 100644
52139 --- a/fs/aio.c
52140 +++ b/fs/aio.c
52141 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52142 size += sizeof(struct io_event) * nr_events;
52143 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52144
52145 - if (nr_pages < 0)
52146 + if (nr_pages <= 0)
52147 return -EINVAL;
52148
52149 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52150 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52151 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52152 {
52153 ssize_t ret;
52154 + struct iovec iovstack;
52155
52156 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52157
52158 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52159 if (compat)
52160 ret = compat_rw_copy_check_uvector(rw,
52161 (struct compat_iovec __user *)kiocb->ki_buf,
52162 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52163 + kiocb->ki_nr_segs, 1, &iovstack,
52164 &kiocb->ki_iovec);
52165 else
52166 #endif
52167 ret = rw_copy_check_uvector(rw,
52168 (struct iovec __user *)kiocb->ki_buf,
52169 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52170 + kiocb->ki_nr_segs, 1, &iovstack,
52171 &kiocb->ki_iovec);
52172 if (ret < 0)
52173 return ret;
52174
52175 + if (kiocb->ki_iovec == &iovstack) {
52176 + kiocb->ki_inline_vec = iovstack;
52177 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52178 + }
52179 +
52180 /* ki_nbytes now reflect bytes instead of segs */
52181 kiocb->ki_nbytes = ret;
52182 return 0;
52183 diff --git a/fs/attr.c b/fs/attr.c
52184 index 1449adb..a2038c2 100644
52185 --- a/fs/attr.c
52186 +++ b/fs/attr.c
52187 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52188 unsigned long limit;
52189
52190 limit = rlimit(RLIMIT_FSIZE);
52191 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52192 if (limit != RLIM_INFINITY && offset > limit)
52193 goto out_sig;
52194 if (offset > inode->i_sb->s_maxbytes)
52195 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52196 index 3db70da..7aeec5b 100644
52197 --- a/fs/autofs4/waitq.c
52198 +++ b/fs/autofs4/waitq.c
52199 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52200 {
52201 unsigned long sigpipe, flags;
52202 mm_segment_t fs;
52203 - const char *data = (const char *)addr;
52204 + const char __user *data = (const char __force_user *)addr;
52205 ssize_t wr = 0;
52206
52207 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52208 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52209 return 1;
52210 }
52211
52212 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52213 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52214 +#endif
52215 +
52216 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52217 enum autofs_notify notify)
52218 {
52219 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52220
52221 /* If this is a direct mount request create a dummy name */
52222 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52223 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52224 + /* this name does get written to userland via autofs4_write() */
52225 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52226 +#else
52227 qstr.len = sprintf(name, "%p", dentry);
52228 +#endif
52229 else {
52230 qstr.len = autofs4_getpath(sbi, dentry, &name);
52231 if (!qstr.len) {
52232 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52233 index 2722387..c8dd2a7 100644
52234 --- a/fs/befs/endian.h
52235 +++ b/fs/befs/endian.h
52236 @@ -11,7 +11,7 @@
52237
52238 #include <asm/byteorder.h>
52239
52240 -static inline u64
52241 +static inline u64 __intentional_overflow(-1)
52242 fs64_to_cpu(const struct super_block *sb, fs64 n)
52243 {
52244 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52245 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52246 return (__force fs64)cpu_to_be64(n);
52247 }
52248
52249 -static inline u32
52250 +static inline u32 __intentional_overflow(-1)
52251 fs32_to_cpu(const struct super_block *sb, fs32 n)
52252 {
52253 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52254 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52255 index e9c75e2..1baece1 100644
52256 --- a/fs/befs/linuxvfs.c
52257 +++ b/fs/befs/linuxvfs.c
52258 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52259 {
52260 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52261 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52262 - char *link = nd_get_link(nd);
52263 + const char *link = nd_get_link(nd);
52264 if (!IS_ERR(link))
52265 kfree(link);
52266 }
52267 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52268 index 89dec7f..361b0d75 100644
52269 --- a/fs/binfmt_aout.c
52270 +++ b/fs/binfmt_aout.c
52271 @@ -16,6 +16,7 @@
52272 #include <linux/string.h>
52273 #include <linux/fs.h>
52274 #include <linux/file.h>
52275 +#include <linux/security.h>
52276 #include <linux/stat.h>
52277 #include <linux/fcntl.h>
52278 #include <linux/ptrace.h>
52279 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52280 #endif
52281 # define START_STACK(u) ((void __user *)u.start_stack)
52282
52283 + memset(&dump, 0, sizeof(dump));
52284 +
52285 fs = get_fs();
52286 set_fs(KERNEL_DS);
52287 has_dumped = 1;
52288 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52289
52290 /* If the size of the dump file exceeds the rlimit, then see what would happen
52291 if we wrote the stack, but not the data area. */
52292 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52293 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52294 dump.u_dsize = 0;
52295
52296 /* Make sure we have enough room to write the stack and data areas. */
52297 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52298 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52299 dump.u_ssize = 0;
52300
52301 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52302 rlim = rlimit(RLIMIT_DATA);
52303 if (rlim >= RLIM_INFINITY)
52304 rlim = ~0;
52305 +
52306 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52307 if (ex.a_data + ex.a_bss > rlim)
52308 return -ENOMEM;
52309
52310 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52311
52312 install_exec_creds(bprm);
52313
52314 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52315 + current->mm->pax_flags = 0UL;
52316 +#endif
52317 +
52318 +#ifdef CONFIG_PAX_PAGEEXEC
52319 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52320 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52321 +
52322 +#ifdef CONFIG_PAX_EMUTRAMP
52323 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52324 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52325 +#endif
52326 +
52327 +#ifdef CONFIG_PAX_MPROTECT
52328 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52329 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52330 +#endif
52331 +
52332 + }
52333 +#endif
52334 +
52335 if (N_MAGIC(ex) == OMAGIC) {
52336 unsigned long text_addr, map_size;
52337 loff_t pos;
52338 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52339 }
52340
52341 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52342 - PROT_READ | PROT_WRITE | PROT_EXEC,
52343 + PROT_READ | PROT_WRITE,
52344 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52345 fd_offset + ex.a_text);
52346 if (error != N_DATADDR(ex)) {
52347 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52348 index 4c94a79..f428019 100644
52349 --- a/fs/binfmt_elf.c
52350 +++ b/fs/binfmt_elf.c
52351 @@ -34,6 +34,7 @@
52352 #include <linux/utsname.h>
52353 #include <linux/coredump.h>
52354 #include <linux/sched.h>
52355 +#include <linux/xattr.h>
52356 #include <asm/uaccess.h>
52357 #include <asm/param.h>
52358 #include <asm/page.h>
52359 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52360 #define elf_core_dump NULL
52361 #endif
52362
52363 +#ifdef CONFIG_PAX_MPROTECT
52364 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52365 +#endif
52366 +
52367 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52368 +static void elf_handle_mmap(struct file *file);
52369 +#endif
52370 +
52371 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52372 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52373 #else
52374 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52375 .load_binary = load_elf_binary,
52376 .load_shlib = load_elf_library,
52377 .core_dump = elf_core_dump,
52378 +
52379 +#ifdef CONFIG_PAX_MPROTECT
52380 + .handle_mprotect= elf_handle_mprotect,
52381 +#endif
52382 +
52383 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52384 + .handle_mmap = elf_handle_mmap,
52385 +#endif
52386 +
52387 .min_coredump = ELF_EXEC_PAGESIZE,
52388 };
52389
52390 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52391
52392 static int set_brk(unsigned long start, unsigned long end)
52393 {
52394 + unsigned long e = end;
52395 +
52396 start = ELF_PAGEALIGN(start);
52397 end = ELF_PAGEALIGN(end);
52398 if (end > start) {
52399 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52400 if (BAD_ADDR(addr))
52401 return addr;
52402 }
52403 - current->mm->start_brk = current->mm->brk = end;
52404 + current->mm->start_brk = current->mm->brk = e;
52405 return 0;
52406 }
52407
52408 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52409 elf_addr_t __user *u_rand_bytes;
52410 const char *k_platform = ELF_PLATFORM;
52411 const char *k_base_platform = ELF_BASE_PLATFORM;
52412 - unsigned char k_rand_bytes[16];
52413 + u32 k_rand_bytes[4];
52414 int items;
52415 elf_addr_t *elf_info;
52416 int ei_index = 0;
52417 const struct cred *cred = current_cred();
52418 struct vm_area_struct *vma;
52419 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52420
52421 /*
52422 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52423 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52424 * Generate 16 random bytes for userspace PRNG seeding.
52425 */
52426 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52427 - u_rand_bytes = (elf_addr_t __user *)
52428 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52429 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52430 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52431 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52432 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52433 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52434 + u_rand_bytes = (elf_addr_t __user *) p;
52435 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52436 return -EFAULT;
52437
52438 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52439 return -EFAULT;
52440 current->mm->env_end = p;
52441
52442 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52443 +
52444 /* Put the elf_info on the stack in the right place. */
52445 sp = (elf_addr_t __user *)envp + 1;
52446 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52447 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52448 return -EFAULT;
52449 return 0;
52450 }
52451 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52452 an ELF header */
52453
52454 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52455 - struct file *interpreter, unsigned long *interp_map_addr,
52456 - unsigned long no_base)
52457 + struct file *interpreter, unsigned long no_base)
52458 {
52459 struct elf_phdr *elf_phdata;
52460 struct elf_phdr *eppnt;
52461 - unsigned long load_addr = 0;
52462 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52463 int load_addr_set = 0;
52464 unsigned long last_bss = 0, elf_bss = 0;
52465 - unsigned long error = ~0UL;
52466 + unsigned long error = -EINVAL;
52467 unsigned long total_size;
52468 int retval, i, size;
52469
52470 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52471 goto out_close;
52472 }
52473
52474 +#ifdef CONFIG_PAX_SEGMEXEC
52475 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52476 + pax_task_size = SEGMEXEC_TASK_SIZE;
52477 +#endif
52478 +
52479 eppnt = elf_phdata;
52480 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52481 if (eppnt->p_type == PT_LOAD) {
52482 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52483 map_addr = elf_map(interpreter, load_addr + vaddr,
52484 eppnt, elf_prot, elf_type, total_size);
52485 total_size = 0;
52486 - if (!*interp_map_addr)
52487 - *interp_map_addr = map_addr;
52488 error = map_addr;
52489 if (BAD_ADDR(map_addr))
52490 goto out_close;
52491 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52492 k = load_addr + eppnt->p_vaddr;
52493 if (BAD_ADDR(k) ||
52494 eppnt->p_filesz > eppnt->p_memsz ||
52495 - eppnt->p_memsz > TASK_SIZE ||
52496 - TASK_SIZE - eppnt->p_memsz < k) {
52497 + eppnt->p_memsz > pax_task_size ||
52498 + pax_task_size - eppnt->p_memsz < k) {
52499 error = -ENOMEM;
52500 goto out_close;
52501 }
52502 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52503 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52504
52505 /* Map the last of the bss segment */
52506 - error = vm_brk(elf_bss, last_bss - elf_bss);
52507 - if (BAD_ADDR(error))
52508 - goto out_close;
52509 + if (last_bss > elf_bss) {
52510 + error = vm_brk(elf_bss, last_bss - elf_bss);
52511 + if (BAD_ADDR(error))
52512 + goto out_close;
52513 + }
52514 }
52515
52516 error = load_addr;
52517 @@ -538,6 +569,315 @@ out:
52518 return error;
52519 }
52520
52521 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52522 +#ifdef CONFIG_PAX_SOFTMODE
52523 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52524 +{
52525 + unsigned long pax_flags = 0UL;
52526 +
52527 +#ifdef CONFIG_PAX_PAGEEXEC
52528 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52529 + pax_flags |= MF_PAX_PAGEEXEC;
52530 +#endif
52531 +
52532 +#ifdef CONFIG_PAX_SEGMEXEC
52533 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52534 + pax_flags |= MF_PAX_SEGMEXEC;
52535 +#endif
52536 +
52537 +#ifdef CONFIG_PAX_EMUTRAMP
52538 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52539 + pax_flags |= MF_PAX_EMUTRAMP;
52540 +#endif
52541 +
52542 +#ifdef CONFIG_PAX_MPROTECT
52543 + if (elf_phdata->p_flags & PF_MPROTECT)
52544 + pax_flags |= MF_PAX_MPROTECT;
52545 +#endif
52546 +
52547 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52548 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52549 + pax_flags |= MF_PAX_RANDMMAP;
52550 +#endif
52551 +
52552 + return pax_flags;
52553 +}
52554 +#endif
52555 +
52556 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52557 +{
52558 + unsigned long pax_flags = 0UL;
52559 +
52560 +#ifdef CONFIG_PAX_PAGEEXEC
52561 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52562 + pax_flags |= MF_PAX_PAGEEXEC;
52563 +#endif
52564 +
52565 +#ifdef CONFIG_PAX_SEGMEXEC
52566 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52567 + pax_flags |= MF_PAX_SEGMEXEC;
52568 +#endif
52569 +
52570 +#ifdef CONFIG_PAX_EMUTRAMP
52571 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52572 + pax_flags |= MF_PAX_EMUTRAMP;
52573 +#endif
52574 +
52575 +#ifdef CONFIG_PAX_MPROTECT
52576 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52577 + pax_flags |= MF_PAX_MPROTECT;
52578 +#endif
52579 +
52580 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52581 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52582 + pax_flags |= MF_PAX_RANDMMAP;
52583 +#endif
52584 +
52585 + return pax_flags;
52586 +}
52587 +#endif
52588 +
52589 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52590 +#ifdef CONFIG_PAX_SOFTMODE
52591 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52592 +{
52593 + unsigned long pax_flags = 0UL;
52594 +
52595 +#ifdef CONFIG_PAX_PAGEEXEC
52596 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52597 + pax_flags |= MF_PAX_PAGEEXEC;
52598 +#endif
52599 +
52600 +#ifdef CONFIG_PAX_SEGMEXEC
52601 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52602 + pax_flags |= MF_PAX_SEGMEXEC;
52603 +#endif
52604 +
52605 +#ifdef CONFIG_PAX_EMUTRAMP
52606 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52607 + pax_flags |= MF_PAX_EMUTRAMP;
52608 +#endif
52609 +
52610 +#ifdef CONFIG_PAX_MPROTECT
52611 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52612 + pax_flags |= MF_PAX_MPROTECT;
52613 +#endif
52614 +
52615 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52616 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52617 + pax_flags |= MF_PAX_RANDMMAP;
52618 +#endif
52619 +
52620 + return pax_flags;
52621 +}
52622 +#endif
52623 +
52624 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52625 +{
52626 + unsigned long pax_flags = 0UL;
52627 +
52628 +#ifdef CONFIG_PAX_PAGEEXEC
52629 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52630 + pax_flags |= MF_PAX_PAGEEXEC;
52631 +#endif
52632 +
52633 +#ifdef CONFIG_PAX_SEGMEXEC
52634 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52635 + pax_flags |= MF_PAX_SEGMEXEC;
52636 +#endif
52637 +
52638 +#ifdef CONFIG_PAX_EMUTRAMP
52639 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52640 + pax_flags |= MF_PAX_EMUTRAMP;
52641 +#endif
52642 +
52643 +#ifdef CONFIG_PAX_MPROTECT
52644 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52645 + pax_flags |= MF_PAX_MPROTECT;
52646 +#endif
52647 +
52648 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52649 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52650 + pax_flags |= MF_PAX_RANDMMAP;
52651 +#endif
52652 +
52653 + return pax_flags;
52654 +}
52655 +#endif
52656 +
52657 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52658 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52659 +{
52660 + unsigned long pax_flags = 0UL;
52661 +
52662 +#ifdef CONFIG_PAX_EI_PAX
52663 +
52664 +#ifdef CONFIG_PAX_PAGEEXEC
52665 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52666 + pax_flags |= MF_PAX_PAGEEXEC;
52667 +#endif
52668 +
52669 +#ifdef CONFIG_PAX_SEGMEXEC
52670 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52671 + pax_flags |= MF_PAX_SEGMEXEC;
52672 +#endif
52673 +
52674 +#ifdef CONFIG_PAX_EMUTRAMP
52675 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52676 + pax_flags |= MF_PAX_EMUTRAMP;
52677 +#endif
52678 +
52679 +#ifdef CONFIG_PAX_MPROTECT
52680 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52681 + pax_flags |= MF_PAX_MPROTECT;
52682 +#endif
52683 +
52684 +#ifdef CONFIG_PAX_ASLR
52685 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52686 + pax_flags |= MF_PAX_RANDMMAP;
52687 +#endif
52688 +
52689 +#else
52690 +
52691 +#ifdef CONFIG_PAX_PAGEEXEC
52692 + pax_flags |= MF_PAX_PAGEEXEC;
52693 +#endif
52694 +
52695 +#ifdef CONFIG_PAX_SEGMEXEC
52696 + pax_flags |= MF_PAX_SEGMEXEC;
52697 +#endif
52698 +
52699 +#ifdef CONFIG_PAX_MPROTECT
52700 + pax_flags |= MF_PAX_MPROTECT;
52701 +#endif
52702 +
52703 +#ifdef CONFIG_PAX_RANDMMAP
52704 + if (randomize_va_space)
52705 + pax_flags |= MF_PAX_RANDMMAP;
52706 +#endif
52707 +
52708 +#endif
52709 +
52710 + return pax_flags;
52711 +}
52712 +
52713 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52714 +{
52715 +
52716 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52717 + unsigned long i;
52718 +
52719 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52720 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52721 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52722 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52723 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52724 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52725 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52726 + return ~0UL;
52727 +
52728 +#ifdef CONFIG_PAX_SOFTMODE
52729 + if (pax_softmode)
52730 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52731 + else
52732 +#endif
52733 +
52734 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52735 + break;
52736 + }
52737 +#endif
52738 +
52739 + return ~0UL;
52740 +}
52741 +
52742 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52743 +{
52744 +
52745 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52746 + ssize_t xattr_size, i;
52747 + unsigned char xattr_value[sizeof("pemrs") - 1];
52748 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52749 +
52750 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52751 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52752 + return ~0UL;
52753 +
52754 + for (i = 0; i < xattr_size; i++)
52755 + switch (xattr_value[i]) {
52756 + default:
52757 + return ~0UL;
52758 +
52759 +#define parse_flag(option1, option2, flag) \
52760 + case option1: \
52761 + if (pax_flags_hardmode & MF_PAX_##flag) \
52762 + return ~0UL; \
52763 + pax_flags_hardmode |= MF_PAX_##flag; \
52764 + break; \
52765 + case option2: \
52766 + if (pax_flags_softmode & MF_PAX_##flag) \
52767 + return ~0UL; \
52768 + pax_flags_softmode |= MF_PAX_##flag; \
52769 + break;
52770 +
52771 + parse_flag('p', 'P', PAGEEXEC);
52772 + parse_flag('e', 'E', EMUTRAMP);
52773 + parse_flag('m', 'M', MPROTECT);
52774 + parse_flag('r', 'R', RANDMMAP);
52775 + parse_flag('s', 'S', SEGMEXEC);
52776 +
52777 +#undef parse_flag
52778 + }
52779 +
52780 + if (pax_flags_hardmode & pax_flags_softmode)
52781 + return ~0UL;
52782 +
52783 +#ifdef CONFIG_PAX_SOFTMODE
52784 + if (pax_softmode)
52785 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52786 + else
52787 +#endif
52788 +
52789 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52790 +#else
52791 + return ~0UL;
52792 +#endif
52793 +
52794 +}
52795 +
52796 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52797 +{
52798 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52799 +
52800 + pax_flags = pax_parse_ei_pax(elf_ex);
52801 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52802 + xattr_pax_flags = pax_parse_xattr_pax(file);
52803 +
52804 + if (pt_pax_flags == ~0UL)
52805 + pt_pax_flags = xattr_pax_flags;
52806 + else if (xattr_pax_flags == ~0UL)
52807 + xattr_pax_flags = pt_pax_flags;
52808 + if (pt_pax_flags != xattr_pax_flags)
52809 + return -EINVAL;
52810 + if (pt_pax_flags != ~0UL)
52811 + pax_flags = pt_pax_flags;
52812 +
52813 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52814 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52815 + if ((__supported_pte_mask & _PAGE_NX))
52816 + pax_flags &= ~MF_PAX_SEGMEXEC;
52817 + else
52818 + pax_flags &= ~MF_PAX_PAGEEXEC;
52819 + }
52820 +#endif
52821 +
52822 + if (0 > pax_check_flags(&pax_flags))
52823 + return -EINVAL;
52824 +
52825 + current->mm->pax_flags = pax_flags;
52826 + return 0;
52827 +}
52828 +#endif
52829 +
52830 /*
52831 * These are the functions used to load ELF style executables and shared
52832 * libraries. There is no binary dependent code anywhere else.
52833 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52834 {
52835 unsigned int random_variable = 0;
52836
52837 +#ifdef CONFIG_PAX_RANDUSTACK
52838 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52839 + return stack_top - current->mm->delta_stack;
52840 +#endif
52841 +
52842 if ((current->flags & PF_RANDOMIZE) &&
52843 !(current->personality & ADDR_NO_RANDOMIZE)) {
52844 random_variable = get_random_int() & STACK_RND_MASK;
52845 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52846 unsigned long load_addr = 0, load_bias = 0;
52847 int load_addr_set = 0;
52848 char * elf_interpreter = NULL;
52849 - unsigned long error;
52850 + unsigned long error = 0;
52851 struct elf_phdr *elf_ppnt, *elf_phdata;
52852 unsigned long elf_bss, elf_brk;
52853 int retval, i;
52854 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52855 unsigned long start_code, end_code, start_data, end_data;
52856 unsigned long reloc_func_desc __maybe_unused = 0;
52857 int executable_stack = EXSTACK_DEFAULT;
52858 - unsigned long def_flags = 0;
52859 struct pt_regs *regs = current_pt_regs();
52860 struct {
52861 struct elfhdr elf_ex;
52862 struct elfhdr interp_elf_ex;
52863 } *loc;
52864 + unsigned long pax_task_size = TASK_SIZE;
52865
52866 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52867 if (!loc) {
52868 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52869 goto out_free_dentry;
52870
52871 /* OK, This is the point of no return */
52872 - current->mm->def_flags = def_flags;
52873 +
52874 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52875 + current->mm->pax_flags = 0UL;
52876 +#endif
52877 +
52878 +#ifdef CONFIG_PAX_DLRESOLVE
52879 + current->mm->call_dl_resolve = 0UL;
52880 +#endif
52881 +
52882 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52883 + current->mm->call_syscall = 0UL;
52884 +#endif
52885 +
52886 +#ifdef CONFIG_PAX_ASLR
52887 + current->mm->delta_mmap = 0UL;
52888 + current->mm->delta_stack = 0UL;
52889 +#endif
52890 +
52891 + current->mm->def_flags = 0;
52892 +
52893 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52894 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52895 + send_sig(SIGKILL, current, 0);
52896 + goto out_free_dentry;
52897 + }
52898 +#endif
52899 +
52900 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52901 + pax_set_initial_flags(bprm);
52902 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52903 + if (pax_set_initial_flags_func)
52904 + (pax_set_initial_flags_func)(bprm);
52905 +#endif
52906 +
52907 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52908 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52909 + current->mm->context.user_cs_limit = PAGE_SIZE;
52910 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52911 + }
52912 +#endif
52913 +
52914 +#ifdef CONFIG_PAX_SEGMEXEC
52915 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52916 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52917 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52918 + pax_task_size = SEGMEXEC_TASK_SIZE;
52919 + current->mm->def_flags |= VM_NOHUGEPAGE;
52920 + }
52921 +#endif
52922 +
52923 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52924 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52925 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52926 + put_cpu();
52927 + }
52928 +#endif
52929
52930 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52931 may depend on the personality. */
52932 SET_PERSONALITY(loc->elf_ex);
52933 +
52934 +#ifdef CONFIG_PAX_ASLR
52935 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52936 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52937 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52938 + }
52939 +#endif
52940 +
52941 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52942 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52943 + executable_stack = EXSTACK_DISABLE_X;
52944 + current->personality &= ~READ_IMPLIES_EXEC;
52945 + } else
52946 +#endif
52947 +
52948 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52949 current->personality |= READ_IMPLIES_EXEC;
52950
52951 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52952 #else
52953 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52954 #endif
52955 +
52956 +#ifdef CONFIG_PAX_RANDMMAP
52957 + /* PaX: randomize base address at the default exe base if requested */
52958 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52959 +#ifdef CONFIG_SPARC64
52960 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52961 +#else
52962 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52963 +#endif
52964 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52965 + elf_flags |= MAP_FIXED;
52966 + }
52967 +#endif
52968 +
52969 }
52970
52971 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52972 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52973 * allowed task size. Note that p_filesz must always be
52974 * <= p_memsz so it is only necessary to check p_memsz.
52975 */
52976 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52977 - elf_ppnt->p_memsz > TASK_SIZE ||
52978 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52979 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52980 + elf_ppnt->p_memsz > pax_task_size ||
52981 + pax_task_size - elf_ppnt->p_memsz < k) {
52982 /* set_brk can never work. Avoid overflows. */
52983 send_sig(SIGKILL, current, 0);
52984 retval = -EINVAL;
52985 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52986 goto out_free_dentry;
52987 }
52988 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52989 - send_sig(SIGSEGV, current, 0);
52990 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52991 - goto out_free_dentry;
52992 + /*
52993 + * This bss-zeroing can fail if the ELF
52994 + * file specifies odd protections. So
52995 + * we don't check the return value
52996 + */
52997 }
52998
52999 +#ifdef CONFIG_PAX_RANDMMAP
53000 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53001 + unsigned long start, size, flags;
53002 + vm_flags_t vm_flags;
53003 +
53004 + start = ELF_PAGEALIGN(elf_brk);
53005 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53006 + flags = MAP_FIXED | MAP_PRIVATE;
53007 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53008 +
53009 + down_write(&current->mm->mmap_sem);
53010 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53011 + retval = -ENOMEM;
53012 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53013 +// if (current->personality & ADDR_NO_RANDOMIZE)
53014 +// vm_flags |= VM_READ | VM_MAYREAD;
53015 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53016 + retval = IS_ERR_VALUE(start) ? start : 0;
53017 + }
53018 + up_write(&current->mm->mmap_sem);
53019 + if (retval == 0)
53020 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53021 + if (retval < 0) {
53022 + send_sig(SIGKILL, current, 0);
53023 + goto out_free_dentry;
53024 + }
53025 + }
53026 +#endif
53027 +
53028 if (elf_interpreter) {
53029 - unsigned long interp_map_addr = 0;
53030 -
53031 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53032 interpreter,
53033 - &interp_map_addr,
53034 load_bias);
53035 if (!IS_ERR((void *)elf_entry)) {
53036 /*
53037 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53038 * Decide what to dump of a segment, part, all or none.
53039 */
53040 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53041 - unsigned long mm_flags)
53042 + unsigned long mm_flags, long signr)
53043 {
53044 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53045
53046 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53047 if (vma->vm_file == NULL)
53048 return 0;
53049
53050 - if (FILTER(MAPPED_PRIVATE))
53051 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53052 goto whole;
53053
53054 /*
53055 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53056 {
53057 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53058 int i = 0;
53059 - do
53060 + do {
53061 i += 2;
53062 - while (auxv[i - 2] != AT_NULL);
53063 + } while (auxv[i - 2] != AT_NULL);
53064 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53065 }
53066
53067 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53068 {
53069 mm_segment_t old_fs = get_fs();
53070 set_fs(KERNEL_DS);
53071 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53072 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53073 set_fs(old_fs);
53074 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53075 }
53076 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53077 }
53078
53079 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53080 - unsigned long mm_flags)
53081 + struct coredump_params *cprm)
53082 {
53083 struct vm_area_struct *vma;
53084 size_t size = 0;
53085
53086 for (vma = first_vma(current, gate_vma); vma != NULL;
53087 vma = next_vma(vma, gate_vma))
53088 - size += vma_dump_size(vma, mm_flags);
53089 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53090 return size;
53091 }
53092
53093 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53094
53095 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53096
53097 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53098 + offset += elf_core_vma_data_size(gate_vma, cprm);
53099 offset += elf_core_extra_data_size();
53100 e_shoff = offset;
53101
53102 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53103 offset = dataoff;
53104
53105 size += sizeof(*elf);
53106 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53107 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53108 goto end_coredump;
53109
53110 size += sizeof(*phdr4note);
53111 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53112 if (size > cprm->limit
53113 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53114 goto end_coredump;
53115 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53116 phdr.p_offset = offset;
53117 phdr.p_vaddr = vma->vm_start;
53118 phdr.p_paddr = 0;
53119 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53120 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53121 phdr.p_memsz = vma->vm_end - vma->vm_start;
53122 offset += phdr.p_filesz;
53123 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53124 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53125 phdr.p_align = ELF_EXEC_PAGESIZE;
53126
53127 size += sizeof(phdr);
53128 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53129 if (size > cprm->limit
53130 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53131 goto end_coredump;
53132 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53133 unsigned long addr;
53134 unsigned long end;
53135
53136 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53137 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53138
53139 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53140 struct page *page;
53141 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53142 page = get_dump_page(addr);
53143 if (page) {
53144 void *kaddr = kmap(page);
53145 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53146 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53147 !dump_write(cprm->file, kaddr,
53148 PAGE_SIZE);
53149 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53150
53151 if (e_phnum == PN_XNUM) {
53152 size += sizeof(*shdr4extnum);
53153 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53154 if (size > cprm->limit
53155 || !dump_write(cprm->file, shdr4extnum,
53156 sizeof(*shdr4extnum)))
53157 @@ -2235,6 +2697,167 @@ out:
53158
53159 #endif /* CONFIG_ELF_CORE */
53160
53161 +#ifdef CONFIG_PAX_MPROTECT
53162 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53163 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53164 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53165 + *
53166 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53167 + * basis because we want to allow the common case and not the special ones.
53168 + */
53169 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53170 +{
53171 + struct elfhdr elf_h;
53172 + struct elf_phdr elf_p;
53173 + unsigned long i;
53174 + unsigned long oldflags;
53175 + bool is_textrel_rw, is_textrel_rx, is_relro;
53176 +
53177 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53178 + return;
53179 +
53180 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53181 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53182 +
53183 +#ifdef CONFIG_PAX_ELFRELOCS
53184 + /* possible TEXTREL */
53185 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53186 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53187 +#else
53188 + is_textrel_rw = false;
53189 + is_textrel_rx = false;
53190 +#endif
53191 +
53192 + /* possible RELRO */
53193 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53194 +
53195 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53196 + return;
53197 +
53198 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53199 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53200 +
53201 +#ifdef CONFIG_PAX_ETEXECRELOCS
53202 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53203 +#else
53204 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53205 +#endif
53206 +
53207 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53208 + !elf_check_arch(&elf_h) ||
53209 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53210 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53211 + return;
53212 +
53213 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53214 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53215 + return;
53216 + switch (elf_p.p_type) {
53217 + case PT_DYNAMIC:
53218 + if (!is_textrel_rw && !is_textrel_rx)
53219 + continue;
53220 + i = 0UL;
53221 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53222 + elf_dyn dyn;
53223 +
53224 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53225 + break;
53226 + if (dyn.d_tag == DT_NULL)
53227 + break;
53228 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53229 + gr_log_textrel(vma);
53230 + if (is_textrel_rw)
53231 + vma->vm_flags |= VM_MAYWRITE;
53232 + else
53233 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53234 + vma->vm_flags &= ~VM_MAYWRITE;
53235 + break;
53236 + }
53237 + i++;
53238 + }
53239 + is_textrel_rw = false;
53240 + is_textrel_rx = false;
53241 + continue;
53242 +
53243 + case PT_GNU_RELRO:
53244 + if (!is_relro)
53245 + continue;
53246 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53247 + vma->vm_flags &= ~VM_MAYWRITE;
53248 + is_relro = false;
53249 + continue;
53250 +
53251 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53252 + case PT_PAX_FLAGS: {
53253 + const char *msg_mprotect = "", *msg_emutramp = "";
53254 + char *buffer_lib, *buffer_exe;
53255 +
53256 + if (elf_p.p_flags & PF_NOMPROTECT)
53257 + msg_mprotect = "MPROTECT disabled";
53258 +
53259 +#ifdef CONFIG_PAX_EMUTRAMP
53260 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53261 + msg_emutramp = "EMUTRAMP enabled";
53262 +#endif
53263 +
53264 + if (!msg_mprotect[0] && !msg_emutramp[0])
53265 + continue;
53266 +
53267 + if (!printk_ratelimit())
53268 + continue;
53269 +
53270 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53271 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53272 + if (buffer_lib && buffer_exe) {
53273 + char *path_lib, *path_exe;
53274 +
53275 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53276 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53277 +
53278 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53279 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53280 +
53281 + }
53282 + free_page((unsigned long)buffer_exe);
53283 + free_page((unsigned long)buffer_lib);
53284 + continue;
53285 + }
53286 +#endif
53287 +
53288 + }
53289 + }
53290 +}
53291 +#endif
53292 +
53293 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53294 +
53295 +extern int grsec_enable_log_rwxmaps;
53296 +
53297 +static void elf_handle_mmap(struct file *file)
53298 +{
53299 + struct elfhdr elf_h;
53300 + struct elf_phdr elf_p;
53301 + unsigned long i;
53302 +
53303 + if (!grsec_enable_log_rwxmaps)
53304 + return;
53305 +
53306 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53307 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53308 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53309 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53310 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53311 + return;
53312 +
53313 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53314 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53315 + return;
53316 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53317 + gr_log_ptgnustack(file);
53318 + }
53319 +}
53320 +#endif
53321 +
53322 static int __init init_elf_binfmt(void)
53323 {
53324 register_binfmt(&elf_format);
53325 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53326 index d50bbe5..af3b649 100644
53327 --- a/fs/binfmt_flat.c
53328 +++ b/fs/binfmt_flat.c
53329 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53330 realdatastart = (unsigned long) -ENOMEM;
53331 printk("Unable to allocate RAM for process data, errno %d\n",
53332 (int)-realdatastart);
53333 + down_write(&current->mm->mmap_sem);
53334 vm_munmap(textpos, text_len);
53335 + up_write(&current->mm->mmap_sem);
53336 ret = realdatastart;
53337 goto err;
53338 }
53339 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53340 }
53341 if (IS_ERR_VALUE(result)) {
53342 printk("Unable to read data+bss, errno %d\n", (int)-result);
53343 + down_write(&current->mm->mmap_sem);
53344 vm_munmap(textpos, text_len);
53345 vm_munmap(realdatastart, len);
53346 + up_write(&current->mm->mmap_sem);
53347 ret = result;
53348 goto err;
53349 }
53350 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53351 }
53352 if (IS_ERR_VALUE(result)) {
53353 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53354 + down_write(&current->mm->mmap_sem);
53355 vm_munmap(textpos, text_len + data_len + extra +
53356 MAX_SHARED_LIBS * sizeof(unsigned long));
53357 + up_write(&current->mm->mmap_sem);
53358 ret = result;
53359 goto err;
53360 }
53361 diff --git a/fs/bio.c b/fs/bio.c
53362 index 5e7507d..418c639 100644
53363 --- a/fs/bio.c
53364 +++ b/fs/bio.c
53365 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53366 /*
53367 * Overflow, abort
53368 */
53369 - if (end < start)
53370 + if (end < start || end - start > INT_MAX - nr_pages)
53371 return ERR_PTR(-EINVAL);
53372
53373 nr_pages += end - start;
53374 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53375 /*
53376 * Overflow, abort
53377 */
53378 - if (end < start)
53379 + if (end < start || end - start > INT_MAX - nr_pages)
53380 return ERR_PTR(-EINVAL);
53381
53382 nr_pages += end - start;
53383 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53384 const int read = bio_data_dir(bio) == READ;
53385 struct bio_map_data *bmd = bio->bi_private;
53386 int i;
53387 - char *p = bmd->sgvecs[0].iov_base;
53388 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53389
53390 bio_for_each_segment_all(bvec, bio, i) {
53391 char *addr = page_address(bvec->bv_page);
53392 diff --git a/fs/block_dev.c b/fs/block_dev.c
53393 index c7bda5c..2121e94 100644
53394 --- a/fs/block_dev.c
53395 +++ b/fs/block_dev.c
53396 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53397 else if (bdev->bd_contains == bdev)
53398 return true; /* is a whole device which isn't held */
53399
53400 - else if (whole->bd_holder == bd_may_claim)
53401 + else if (whole->bd_holder == (void *)bd_may_claim)
53402 return true; /* is a partition of a device that is being partitioned */
53403 else if (whole->bd_holder != NULL)
53404 return false; /* is a partition of a held device */
53405 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53406 index ed50460..fe84385 100644
53407 --- a/fs/btrfs/ctree.c
53408 +++ b/fs/btrfs/ctree.c
53409 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53410 free_extent_buffer(buf);
53411 add_root_to_dirty_list(root);
53412 } else {
53413 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53414 - parent_start = parent->start;
53415 - else
53416 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53417 + if (parent)
53418 + parent_start = parent->start;
53419 + else
53420 + parent_start = 0;
53421 + } else
53422 parent_start = 0;
53423
53424 WARN_ON(trans->transid != btrfs_header_generation(parent));
53425 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53426 index 3755109..e3d457f 100644
53427 --- a/fs/btrfs/delayed-inode.c
53428 +++ b/fs/btrfs/delayed-inode.c
53429 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53430
53431 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53432 {
53433 - int seq = atomic_inc_return(&delayed_root->items_seq);
53434 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53435 if ((atomic_dec_return(&delayed_root->items) <
53436 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53437 waitqueue_active(&delayed_root->wait))
53438 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53439 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53440 int seq, int count)
53441 {
53442 - int val = atomic_read(&delayed_root->items_seq);
53443 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53444
53445 if (val < seq || val >= seq + count)
53446 return 1;
53447 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53448 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53449 return;
53450
53451 - seq = atomic_read(&delayed_root->items_seq);
53452 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53453
53454 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53455 int ret;
53456 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53457 index a4b38f9..f86a509 100644
53458 --- a/fs/btrfs/delayed-inode.h
53459 +++ b/fs/btrfs/delayed-inode.h
53460 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53461 */
53462 struct list_head prepare_list;
53463 atomic_t items; /* for delayed items */
53464 - atomic_t items_seq; /* for delayed items */
53465 + atomic_unchecked_t items_seq; /* for delayed items */
53466 int nodes; /* for delayed nodes */
53467 wait_queue_head_t wait;
53468 };
53469 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53470 struct btrfs_delayed_root *delayed_root)
53471 {
53472 atomic_set(&delayed_root->items, 0);
53473 - atomic_set(&delayed_root->items_seq, 0);
53474 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53475 delayed_root->nodes = 0;
53476 spin_lock_init(&delayed_root->lock);
53477 init_waitqueue_head(&delayed_root->wait);
53478 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53479 index 9877a2a..7ebf9ab 100644
53480 --- a/fs/btrfs/ioctl.c
53481 +++ b/fs/btrfs/ioctl.c
53482 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53483 for (i = 0; i < num_types; i++) {
53484 struct btrfs_space_info *tmp;
53485
53486 + /* Don't copy in more than we allocated */
53487 if (!slot_count)
53488 break;
53489
53490 + slot_count--;
53491 +
53492 info = NULL;
53493 rcu_read_lock();
53494 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53495 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53496 memcpy(dest, &space, sizeof(space));
53497 dest++;
53498 space_args.total_spaces++;
53499 - slot_count--;
53500 }
53501 - if (!slot_count)
53502 - break;
53503 }
53504 up_read(&info->groups_sem);
53505 }
53506 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53507 index 8eb6191..eda91e2 100644
53508 --- a/fs/btrfs/super.c
53509 +++ b/fs/btrfs/super.c
53510 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53511 function, line, errstr);
53512 return;
53513 }
53514 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53515 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53516 /* Wake up anybody who may be waiting on this transaction */
53517 wake_up(&root->fs_info->transaction_wait);
53518 wake_up(&root->fs_info->transaction_blocked_wait);
53519 diff --git a/fs/buffer.c b/fs/buffer.c
53520 index 4d74335..7bd000a 100644
53521 --- a/fs/buffer.c
53522 +++ b/fs/buffer.c
53523 @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
53524 struct buffer_head *bh;
53525 sector_t end_block;
53526 int ret = 0; /* Will call free_more_memory() */
53527 + gfp_t gfp_mask;
53528
53529 - page = find_or_create_page(inode->i_mapping, index,
53530 - (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
53531 + gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
53532 + gfp_mask |= __GFP_MOVABLE;
53533 + /*
53534 + * XXX: __getblk_slow() can not really deal with failure and
53535 + * will endlessly loop on improvised global reclaim. Prefer
53536 + * looping in the allocator rather than here, at least that
53537 + * code knows what it's doing.
53538 + */
53539 + gfp_mask |= __GFP_NOFAIL;
53540 +
53541 + page = find_or_create_page(inode->i_mapping, index, gfp_mask);
53542 if (!page)
53543 return ret;
53544
53545 @@ -3416,7 +3426,7 @@ void __init buffer_init(void)
53546 bh_cachep = kmem_cache_create("buffer_head",
53547 sizeof(struct buffer_head), 0,
53548 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53549 - SLAB_MEM_SPREAD),
53550 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53551 NULL);
53552
53553 /*
53554 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53555 index 622f469..e8d2d55 100644
53556 --- a/fs/cachefiles/bind.c
53557 +++ b/fs/cachefiles/bind.c
53558 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53559 args);
53560
53561 /* start by checking things over */
53562 - ASSERT(cache->fstop_percent >= 0 &&
53563 - cache->fstop_percent < cache->fcull_percent &&
53564 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53565 cache->fcull_percent < cache->frun_percent &&
53566 cache->frun_percent < 100);
53567
53568 - ASSERT(cache->bstop_percent >= 0 &&
53569 - cache->bstop_percent < cache->bcull_percent &&
53570 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53571 cache->bcull_percent < cache->brun_percent &&
53572 cache->brun_percent < 100);
53573
53574 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53575 index 0a1467b..6a53245 100644
53576 --- a/fs/cachefiles/daemon.c
53577 +++ b/fs/cachefiles/daemon.c
53578 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53579 if (n > buflen)
53580 return -EMSGSIZE;
53581
53582 - if (copy_to_user(_buffer, buffer, n) != 0)
53583 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53584 return -EFAULT;
53585
53586 return n;
53587 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53588 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53589 return -EIO;
53590
53591 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53592 + if (datalen > PAGE_SIZE - 1)
53593 return -EOPNOTSUPP;
53594
53595 /* drag the command string into the kernel so we can parse it */
53596 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53597 if (args[0] != '%' || args[1] != '\0')
53598 return -EINVAL;
53599
53600 - if (fstop < 0 || fstop >= cache->fcull_percent)
53601 + if (fstop >= cache->fcull_percent)
53602 return cachefiles_daemon_range_error(cache, args);
53603
53604 cache->fstop_percent = fstop;
53605 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53606 if (args[0] != '%' || args[1] != '\0')
53607 return -EINVAL;
53608
53609 - if (bstop < 0 || bstop >= cache->bcull_percent)
53610 + if (bstop >= cache->bcull_percent)
53611 return cachefiles_daemon_range_error(cache, args);
53612
53613 cache->bstop_percent = bstop;
53614 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53615 index 4938251..7e01445 100644
53616 --- a/fs/cachefiles/internal.h
53617 +++ b/fs/cachefiles/internal.h
53618 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53619 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53620 struct rb_root active_nodes; /* active nodes (can't be culled) */
53621 rwlock_t active_lock; /* lock for active_nodes */
53622 - atomic_t gravecounter; /* graveyard uniquifier */
53623 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53624 unsigned frun_percent; /* when to stop culling (% files) */
53625 unsigned fcull_percent; /* when to start culling (% files) */
53626 unsigned fstop_percent; /* when to stop allocating (% files) */
53627 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53628 * proc.c
53629 */
53630 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53631 -extern atomic_t cachefiles_lookup_histogram[HZ];
53632 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53633 -extern atomic_t cachefiles_create_histogram[HZ];
53634 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53635 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53636 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53637
53638 extern int __init cachefiles_proc_init(void);
53639 extern void cachefiles_proc_cleanup(void);
53640 static inline
53641 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53642 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53643 {
53644 unsigned long jif = jiffies - start_jif;
53645 if (jif >= HZ)
53646 jif = HZ - 1;
53647 - atomic_inc(&histogram[jif]);
53648 + atomic_inc_unchecked(&histogram[jif]);
53649 }
53650
53651 #else
53652 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53653 index 25badd1..d70d918 100644
53654 --- a/fs/cachefiles/namei.c
53655 +++ b/fs/cachefiles/namei.c
53656 @@ -317,7 +317,7 @@ try_again:
53657 /* first step is to make up a grave dentry in the graveyard */
53658 sprintf(nbuffer, "%08x%08x",
53659 (uint32_t) get_seconds(),
53660 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53661 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53662
53663 /* do the multiway lock magic */
53664 trap = lock_rename(cache->graveyard, dir);
53665 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53666 index eccd339..4c1d995 100644
53667 --- a/fs/cachefiles/proc.c
53668 +++ b/fs/cachefiles/proc.c
53669 @@ -14,9 +14,9 @@
53670 #include <linux/seq_file.h>
53671 #include "internal.h"
53672
53673 -atomic_t cachefiles_lookup_histogram[HZ];
53674 -atomic_t cachefiles_mkdir_histogram[HZ];
53675 -atomic_t cachefiles_create_histogram[HZ];
53676 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53677 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53678 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53679
53680 /*
53681 * display the latency histogram
53682 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53683 return 0;
53684 default:
53685 index = (unsigned long) v - 3;
53686 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53687 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53688 - z = atomic_read(&cachefiles_create_histogram[index]);
53689 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53690 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53691 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53692 if (x == 0 && y == 0 && z == 0)
53693 return 0;
53694
53695 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53696 index ebaff36..7e3ea26 100644
53697 --- a/fs/cachefiles/rdwr.c
53698 +++ b/fs/cachefiles/rdwr.c
53699 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53700 old_fs = get_fs();
53701 set_fs(KERNEL_DS);
53702 ret = file->f_op->write(
53703 - file, (const void __user *) data, len, &pos);
53704 + file, (const void __force_user *) data, len, &pos);
53705 set_fs(old_fs);
53706 kunmap(page);
53707 file_end_write(file);
53708 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53709 index a40ceda..f43d17c 100644
53710 --- a/fs/ceph/dir.c
53711 +++ b/fs/ceph/dir.c
53712 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53713 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53714 struct ceph_mds_client *mdsc = fsc->mdsc;
53715 unsigned frag = fpos_frag(ctx->pos);
53716 - int off = fpos_off(ctx->pos);
53717 + unsigned int off = fpos_off(ctx->pos);
53718 int err;
53719 u32 ftype;
53720 struct ceph_mds_reply_info_parsed *rinfo;
53721 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53722 index 6627b26..634ec4b 100644
53723 --- a/fs/ceph/super.c
53724 +++ b/fs/ceph/super.c
53725 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53726 /*
53727 * construct our own bdi so we can control readahead, etc.
53728 */
53729 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53730 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53731
53732 static int ceph_register_bdi(struct super_block *sb,
53733 struct ceph_fs_client *fsc)
53734 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53735 default_backing_dev_info.ra_pages;
53736
53737 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53738 - atomic_long_inc_return(&bdi_seq));
53739 + atomic_long_inc_return_unchecked(&bdi_seq));
53740 if (!err)
53741 sb->s_bdi = &fsc->backing_dev_info;
53742 return err;
53743 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53744 index f3ac415..3d2420c 100644
53745 --- a/fs/cifs/cifs_debug.c
53746 +++ b/fs/cifs/cifs_debug.c
53747 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53748
53749 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53750 #ifdef CONFIG_CIFS_STATS2
53751 - atomic_set(&totBufAllocCount, 0);
53752 - atomic_set(&totSmBufAllocCount, 0);
53753 + atomic_set_unchecked(&totBufAllocCount, 0);
53754 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53755 #endif /* CONFIG_CIFS_STATS2 */
53756 spin_lock(&cifs_tcp_ses_lock);
53757 list_for_each(tmp1, &cifs_tcp_ses_list) {
53758 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53759 tcon = list_entry(tmp3,
53760 struct cifs_tcon,
53761 tcon_list);
53762 - atomic_set(&tcon->num_smbs_sent, 0);
53763 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53764 if (server->ops->clear_stats)
53765 server->ops->clear_stats(tcon);
53766 }
53767 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53768 smBufAllocCount.counter, cifs_min_small);
53769 #ifdef CONFIG_CIFS_STATS2
53770 seq_printf(m, "Total Large %d Small %d Allocations\n",
53771 - atomic_read(&totBufAllocCount),
53772 - atomic_read(&totSmBufAllocCount));
53773 + atomic_read_unchecked(&totBufAllocCount),
53774 + atomic_read_unchecked(&totSmBufAllocCount));
53775 #endif /* CONFIG_CIFS_STATS2 */
53776
53777 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53778 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53779 if (tcon->need_reconnect)
53780 seq_puts(m, "\tDISCONNECTED ");
53781 seq_printf(m, "\nSMBs: %d",
53782 - atomic_read(&tcon->num_smbs_sent));
53783 + atomic_read_unchecked(&tcon->num_smbs_sent));
53784 if (server->ops->print_stats)
53785 server->ops->print_stats(m, tcon);
53786 }
53787 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53788 index 85ea98d..1eee040 100644
53789 --- a/fs/cifs/cifsfs.c
53790 +++ b/fs/cifs/cifsfs.c
53791 @@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb)
53792 {
53793 struct inode *inode;
53794 struct cifs_sb_info *cifs_sb;
53795 + struct cifs_tcon *tcon;
53796 int rc = 0;
53797
53798 cifs_sb = CIFS_SB(sb);
53799 + tcon = cifs_sb_master_tcon(cifs_sb);
53800
53801 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
53802 sb->s_flags |= MS_POSIXACL;
53803
53804 - if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES)
53805 + if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
53806 sb->s_maxbytes = MAX_LFS_FILESIZE;
53807 else
53808 sb->s_maxbytes = MAX_NON_LFS;
53809 @@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb)
53810 goto out_no_root;
53811 }
53812
53813 - if (cifs_sb_master_tcon(cifs_sb)->nocase)
53814 + if (tcon->nocase)
53815 sb->s_d_op = &cifs_ci_dentry_ops;
53816 else
53817 sb->s_d_op = &cifs_dentry_ops;
53818 @@ -1037,7 +1039,7 @@ cifs_init_request_bufs(void)
53819 */
53820 cifs_req_cachep = kmem_cache_create("cifs_request",
53821 CIFSMaxBufSize + max_hdr_size, 0,
53822 - SLAB_HWCACHE_ALIGN, NULL);
53823 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53824 if (cifs_req_cachep == NULL)
53825 return -ENOMEM;
53826
53827 @@ -1064,7 +1066,7 @@ cifs_init_request_bufs(void)
53828 efficient to alloc 1 per page off the slab compared to 17K (5page)
53829 alloc of large cifs buffers even when page debugging is on */
53830 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53831 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53832 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53833 NULL);
53834 if (cifs_sm_req_cachep == NULL) {
53835 mempool_destroy(cifs_req_poolp);
53836 @@ -1149,8 +1151,8 @@ init_cifs(void)
53837 atomic_set(&bufAllocCount, 0);
53838 atomic_set(&smBufAllocCount, 0);
53839 #ifdef CONFIG_CIFS_STATS2
53840 - atomic_set(&totBufAllocCount, 0);
53841 - atomic_set(&totSmBufAllocCount, 0);
53842 + atomic_set_unchecked(&totBufAllocCount, 0);
53843 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53844 #endif /* CONFIG_CIFS_STATS2 */
53845
53846 atomic_set(&midCount, 0);
53847 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53848 index 52ca861..47f309c 100644
53849 --- a/fs/cifs/cifsglob.h
53850 +++ b/fs/cifs/cifsglob.h
53851 @@ -756,35 +756,35 @@ struct cifs_tcon {
53852 __u16 Flags; /* optional support bits */
53853 enum statusEnum tidStatus;
53854 #ifdef CONFIG_CIFS_STATS
53855 - atomic_t num_smbs_sent;
53856 + atomic_unchecked_t num_smbs_sent;
53857 union {
53858 struct {
53859 - atomic_t num_writes;
53860 - atomic_t num_reads;
53861 - atomic_t num_flushes;
53862 - atomic_t num_oplock_brks;
53863 - atomic_t num_opens;
53864 - atomic_t num_closes;
53865 - atomic_t num_deletes;
53866 - atomic_t num_mkdirs;
53867 - atomic_t num_posixopens;
53868 - atomic_t num_posixmkdirs;
53869 - atomic_t num_rmdirs;
53870 - atomic_t num_renames;
53871 - atomic_t num_t2renames;
53872 - atomic_t num_ffirst;
53873 - atomic_t num_fnext;
53874 - atomic_t num_fclose;
53875 - atomic_t num_hardlinks;
53876 - atomic_t num_symlinks;
53877 - atomic_t num_locks;
53878 - atomic_t num_acl_get;
53879 - atomic_t num_acl_set;
53880 + atomic_unchecked_t num_writes;
53881 + atomic_unchecked_t num_reads;
53882 + atomic_unchecked_t num_flushes;
53883 + atomic_unchecked_t num_oplock_brks;
53884 + atomic_unchecked_t num_opens;
53885 + atomic_unchecked_t num_closes;
53886 + atomic_unchecked_t num_deletes;
53887 + atomic_unchecked_t num_mkdirs;
53888 + atomic_unchecked_t num_posixopens;
53889 + atomic_unchecked_t num_posixmkdirs;
53890 + atomic_unchecked_t num_rmdirs;
53891 + atomic_unchecked_t num_renames;
53892 + atomic_unchecked_t num_t2renames;
53893 + atomic_unchecked_t num_ffirst;
53894 + atomic_unchecked_t num_fnext;
53895 + atomic_unchecked_t num_fclose;
53896 + atomic_unchecked_t num_hardlinks;
53897 + atomic_unchecked_t num_symlinks;
53898 + atomic_unchecked_t num_locks;
53899 + atomic_unchecked_t num_acl_get;
53900 + atomic_unchecked_t num_acl_set;
53901 } cifs_stats;
53902 #ifdef CONFIG_CIFS_SMB2
53903 struct {
53904 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53905 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53906 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53907 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53908 } smb2_stats;
53909 #endif /* CONFIG_CIFS_SMB2 */
53910 } stats;
53911 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53912 }
53913
53914 #ifdef CONFIG_CIFS_STATS
53915 -#define cifs_stats_inc atomic_inc
53916 +#define cifs_stats_inc atomic_inc_unchecked
53917
53918 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53919 unsigned int bytes)
53920 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53921 /* Various Debug counters */
53922 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53923 #ifdef CONFIG_CIFS_STATS2
53924 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53925 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53926 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53927 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53928 #endif
53929 GLOBAL_EXTERN atomic_t smBufAllocCount;
53930 GLOBAL_EXTERN atomic_t midCount;
53931 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53932 index 562044f..4af6a17 100644
53933 --- a/fs/cifs/link.c
53934 +++ b/fs/cifs/link.c
53935 @@ -638,7 +638,7 @@ symlink_exit:
53936
53937 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53938 {
53939 - char *p = nd_get_link(nd);
53940 + const char *p = nd_get_link(nd);
53941 if (!IS_ERR(p))
53942 kfree(p);
53943 }
53944 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53945 index f7d4b22..1254377 100644
53946 --- a/fs/cifs/misc.c
53947 +++ b/fs/cifs/misc.c
53948 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53949 memset(ret_buf, 0, buf_size + 3);
53950 atomic_inc(&bufAllocCount);
53951 #ifdef CONFIG_CIFS_STATS2
53952 - atomic_inc(&totBufAllocCount);
53953 + atomic_inc_unchecked(&totBufAllocCount);
53954 #endif /* CONFIG_CIFS_STATS2 */
53955 }
53956
53957 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53958 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53959 atomic_inc(&smBufAllocCount);
53960 #ifdef CONFIG_CIFS_STATS2
53961 - atomic_inc(&totSmBufAllocCount);
53962 + atomic_inc_unchecked(&totSmBufAllocCount);
53963 #endif /* CONFIG_CIFS_STATS2 */
53964
53965 }
53966 diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
53967 index af847e1..651a527 100644
53968 --- a/fs/cifs/netmisc.c
53969 +++ b/fs/cifs/netmisc.c
53970 @@ -780,7 +780,9 @@ static const struct {
53971 ERRDOS, ERRnoaccess, 0xc0000290}, {
53972 ERRDOS, ERRbadfunc, 0xc000029c}, {
53973 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
53974 - ERRDOS, ERRinvlevel, 0x007c0001}, };
53975 + ERRDOS, ERRinvlevel, 0x007c0001}, {
53976 + 0, 0, 0 }
53977 +};
53978
53979 /*****************************************************************************
53980 Print an error message from the status code
53981 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53982 index 6094397..51e576f 100644
53983 --- a/fs/cifs/smb1ops.c
53984 +++ b/fs/cifs/smb1ops.c
53985 @@ -590,27 +590,27 @@ static void
53986 cifs_clear_stats(struct cifs_tcon *tcon)
53987 {
53988 #ifdef CONFIG_CIFS_STATS
53989 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53990 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53991 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53992 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53993 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53994 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53995 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53996 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53997 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53998 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53999 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54000 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54001 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54002 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54003 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54004 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54005 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54006 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54007 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54008 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54009 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54010 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54011 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54012 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54013 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54014 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54015 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54016 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54017 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54018 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54019 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54020 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54021 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54022 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54023 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54024 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54025 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54026 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54027 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54028 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54029 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54030 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54031 #endif
54032 }
54033
54034 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54035 {
54036 #ifdef CONFIG_CIFS_STATS
54037 seq_printf(m, " Oplocks breaks: %d",
54038 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54039 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54040 seq_printf(m, "\nReads: %d Bytes: %llu",
54041 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54042 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54043 (long long)(tcon->bytes_read));
54044 seq_printf(m, "\nWrites: %d Bytes: %llu",
54045 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54046 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54047 (long long)(tcon->bytes_written));
54048 seq_printf(m, "\nFlushes: %d",
54049 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54050 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54051 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54052 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54053 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54054 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54055 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54056 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54057 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54058 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54059 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54060 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54061 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54062 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54063 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54064 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54065 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54066 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54067 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54068 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54069 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54070 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54071 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54072 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54073 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54074 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54075 seq_printf(m, "\nRenames: %d T2 Renames %d",
54076 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54077 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54078 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54079 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54080 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54081 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54082 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54083 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54084 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54085 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54086 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54087 #endif
54088 }
54089
54090 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54091 index f259e6c..ca948ff 100644
54092 --- a/fs/cifs/smb2ops.c
54093 +++ b/fs/cifs/smb2ops.c
54094 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54095 #ifdef CONFIG_CIFS_STATS
54096 int i;
54097 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54098 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54099 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54100 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54101 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54102 }
54103 #endif
54104 }
54105 @@ -310,65 +310,65 @@ static void
54106 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54107 {
54108 #ifdef CONFIG_CIFS_STATS
54109 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54110 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54111 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54112 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54113 seq_printf(m, "\nNegotiates: %d sent %d failed",
54114 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54115 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54116 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54117 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54118 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54119 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54120 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54121 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54122 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54123 seq_printf(m, "\nLogoffs: %d sent %d failed",
54124 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54125 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54126 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54127 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54128 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54129 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54130 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54131 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54132 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54133 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54134 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54135 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54136 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54137 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54138 seq_printf(m, "\nCreates: %d sent %d failed",
54139 - atomic_read(&sent[SMB2_CREATE_HE]),
54140 - atomic_read(&failed[SMB2_CREATE_HE]));
54141 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54142 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54143 seq_printf(m, "\nCloses: %d sent %d failed",
54144 - atomic_read(&sent[SMB2_CLOSE_HE]),
54145 - atomic_read(&failed[SMB2_CLOSE_HE]));
54146 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54147 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54148 seq_printf(m, "\nFlushes: %d sent %d failed",
54149 - atomic_read(&sent[SMB2_FLUSH_HE]),
54150 - atomic_read(&failed[SMB2_FLUSH_HE]));
54151 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54152 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54153 seq_printf(m, "\nReads: %d sent %d failed",
54154 - atomic_read(&sent[SMB2_READ_HE]),
54155 - atomic_read(&failed[SMB2_READ_HE]));
54156 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54157 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54158 seq_printf(m, "\nWrites: %d sent %d failed",
54159 - atomic_read(&sent[SMB2_WRITE_HE]),
54160 - atomic_read(&failed[SMB2_WRITE_HE]));
54161 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54162 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54163 seq_printf(m, "\nLocks: %d sent %d failed",
54164 - atomic_read(&sent[SMB2_LOCK_HE]),
54165 - atomic_read(&failed[SMB2_LOCK_HE]));
54166 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54167 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54168 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54169 - atomic_read(&sent[SMB2_IOCTL_HE]),
54170 - atomic_read(&failed[SMB2_IOCTL_HE]));
54171 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54172 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54173 seq_printf(m, "\nCancels: %d sent %d failed",
54174 - atomic_read(&sent[SMB2_CANCEL_HE]),
54175 - atomic_read(&failed[SMB2_CANCEL_HE]));
54176 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54177 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54178 seq_printf(m, "\nEchos: %d sent %d failed",
54179 - atomic_read(&sent[SMB2_ECHO_HE]),
54180 - atomic_read(&failed[SMB2_ECHO_HE]));
54181 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54182 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54183 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54184 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54185 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54186 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54187 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54188 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54189 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54190 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54191 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54192 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54193 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54194 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54195 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54196 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54197 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54198 seq_printf(m, "\nSetInfos: %d sent %d failed",
54199 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54200 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54201 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54202 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54203 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54204 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54205 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54206 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54207 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54208 #endif
54209 }
54210
54211 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54212 index abc9c28..3fdae28 100644
54213 --- a/fs/cifs/smb2pdu.c
54214 +++ b/fs/cifs/smb2pdu.c
54215 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54216 default:
54217 cifs_dbg(VFS, "info level %u isn't supported\n",
54218 srch_inf->info_level);
54219 - rc = -EINVAL;
54220 - goto qdir_exit;
54221 + return -EINVAL;
54222 }
54223
54224 req->FileIndex = cpu_to_le32(index);
54225 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54226 index 1da168c..8bc7ff6 100644
54227 --- a/fs/coda/cache.c
54228 +++ b/fs/coda/cache.c
54229 @@ -24,7 +24,7 @@
54230 #include "coda_linux.h"
54231 #include "coda_cache.h"
54232
54233 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54234 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54235
54236 /* replace or extend an acl cache hit */
54237 void coda_cache_enter(struct inode *inode, int mask)
54238 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54239 struct coda_inode_info *cii = ITOC(inode);
54240
54241 spin_lock(&cii->c_lock);
54242 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54243 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54244 if (!uid_eq(cii->c_uid, current_fsuid())) {
54245 cii->c_uid = current_fsuid();
54246 cii->c_cached_perm = mask;
54247 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54248 {
54249 struct coda_inode_info *cii = ITOC(inode);
54250 spin_lock(&cii->c_lock);
54251 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54252 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54253 spin_unlock(&cii->c_lock);
54254 }
54255
54256 /* remove all acl caches */
54257 void coda_cache_clear_all(struct super_block *sb)
54258 {
54259 - atomic_inc(&permission_epoch);
54260 + atomic_inc_unchecked(&permission_epoch);
54261 }
54262
54263
54264 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54265 spin_lock(&cii->c_lock);
54266 hit = (mask & cii->c_cached_perm) == mask &&
54267 uid_eq(cii->c_uid, current_fsuid()) &&
54268 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54269 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54270 spin_unlock(&cii->c_lock);
54271
54272 return hit;
54273 diff --git a/fs/compat.c b/fs/compat.c
54274 index 6af20de..fec3fbb 100644
54275 --- a/fs/compat.c
54276 +++ b/fs/compat.c
54277 @@ -54,7 +54,7 @@
54278 #include <asm/ioctls.h>
54279 #include "internal.h"
54280
54281 -int compat_log = 1;
54282 +int compat_log = 0;
54283
54284 int compat_printk(const char *fmt, ...)
54285 {
54286 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54287
54288 set_fs(KERNEL_DS);
54289 /* The __user pointer cast is valid because of the set_fs() */
54290 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54291 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54292 set_fs(oldfs);
54293 /* truncating is ok because it's a user address */
54294 if (!ret)
54295 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54296 goto out;
54297
54298 ret = -EINVAL;
54299 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54300 + if (nr_segs > UIO_MAXIOV)
54301 goto out;
54302 if (nr_segs > fast_segs) {
54303 ret = -ENOMEM;
54304 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54305 struct compat_readdir_callback {
54306 struct dir_context ctx;
54307 struct compat_old_linux_dirent __user *dirent;
54308 + struct file * file;
54309 int result;
54310 };
54311
54312 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54313 buf->result = -EOVERFLOW;
54314 return -EOVERFLOW;
54315 }
54316 +
54317 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54318 + return 0;
54319 +
54320 buf->result++;
54321 dirent = buf->dirent;
54322 if (!access_ok(VERIFY_WRITE, dirent,
54323 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54324 if (!f.file)
54325 return -EBADF;
54326
54327 + buf.file = f.file;
54328 error = iterate_dir(f.file, &buf.ctx);
54329 if (buf.result)
54330 error = buf.result;
54331 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54332 struct dir_context ctx;
54333 struct compat_linux_dirent __user *current_dir;
54334 struct compat_linux_dirent __user *previous;
54335 + struct file * file;
54336 int count;
54337 int error;
54338 };
54339 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54340 buf->error = -EOVERFLOW;
54341 return -EOVERFLOW;
54342 }
54343 +
54344 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54345 + return 0;
54346 +
54347 dirent = buf->previous;
54348 if (dirent) {
54349 if (__put_user(offset, &dirent->d_off))
54350 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54351 if (!f.file)
54352 return -EBADF;
54353
54354 + buf.file = f.file;
54355 error = iterate_dir(f.file, &buf.ctx);
54356 if (error >= 0)
54357 error = buf.error;
54358 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54359 struct dir_context ctx;
54360 struct linux_dirent64 __user *current_dir;
54361 struct linux_dirent64 __user *previous;
54362 + struct file * file;
54363 int count;
54364 int error;
54365 };
54366 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54367 buf->error = -EINVAL; /* only used if we fail.. */
54368 if (reclen > buf->count)
54369 return -EINVAL;
54370 +
54371 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54372 + return 0;
54373 +
54374 dirent = buf->previous;
54375
54376 if (dirent) {
54377 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54378 if (!f.file)
54379 return -EBADF;
54380
54381 + buf.file = f.file;
54382 error = iterate_dir(f.file, &buf.ctx);
54383 if (error >= 0)
54384 error = buf.error;
54385 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54386 index a81147e..20bf2b5 100644
54387 --- a/fs/compat_binfmt_elf.c
54388 +++ b/fs/compat_binfmt_elf.c
54389 @@ -30,11 +30,13 @@
54390 #undef elf_phdr
54391 #undef elf_shdr
54392 #undef elf_note
54393 +#undef elf_dyn
54394 #undef elf_addr_t
54395 #define elfhdr elf32_hdr
54396 #define elf_phdr elf32_phdr
54397 #define elf_shdr elf32_shdr
54398 #define elf_note elf32_note
54399 +#define elf_dyn Elf32_Dyn
54400 #define elf_addr_t Elf32_Addr
54401
54402 /*
54403 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54404 index 5d19acf..9ab093b 100644
54405 --- a/fs/compat_ioctl.c
54406 +++ b/fs/compat_ioctl.c
54407 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54408 return -EFAULT;
54409 if (__get_user(udata, &ss32->iomem_base))
54410 return -EFAULT;
54411 - ss.iomem_base = compat_ptr(udata);
54412 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54413 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54414 __get_user(ss.port_high, &ss32->port_high))
54415 return -EFAULT;
54416 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54417 for (i = 0; i < nmsgs; i++) {
54418 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54419 return -EFAULT;
54420 - if (get_user(datap, &umsgs[i].buf) ||
54421 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54422 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54423 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54424 return -EFAULT;
54425 }
54426 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54427 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54428 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54429 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54430 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54431 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54432 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54433 return -EFAULT;
54434
54435 return ioctl_preallocate(file, p);
54436 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54437 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54438 {
54439 unsigned int a, b;
54440 - a = *(unsigned int *)p;
54441 - b = *(unsigned int *)q;
54442 + a = *(const unsigned int *)p;
54443 + b = *(const unsigned int *)q;
54444 if (a > b)
54445 return 1;
54446 if (a < b)
54447 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54448 index 277bd1b..f312c9e 100644
54449 --- a/fs/configfs/dir.c
54450 +++ b/fs/configfs/dir.c
54451 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54452 }
54453 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54454 struct configfs_dirent *next;
54455 - const char *name;
54456 + const unsigned char * name;
54457 + char d_name[sizeof(next->s_dentry->d_iname)];
54458 int len;
54459 struct inode *inode = NULL;
54460
54461 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54462 continue;
54463
54464 name = configfs_get_name(next);
54465 - len = strlen(name);
54466 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54467 + len = next->s_dentry->d_name.len;
54468 + memcpy(d_name, name, len);
54469 + name = d_name;
54470 + } else
54471 + len = strlen(name);
54472
54473 /*
54474 * We'll have a dentry and an inode for
54475 diff --git a/fs/coredump.c b/fs/coredump.c
54476 index 72f816d..1ba8eff 100644
54477 --- a/fs/coredump.c
54478 +++ b/fs/coredump.c
54479 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54480 struct pipe_inode_info *pipe = file->private_data;
54481
54482 pipe_lock(pipe);
54483 - pipe->readers++;
54484 - pipe->writers--;
54485 + atomic_inc(&pipe->readers);
54486 + atomic_dec(&pipe->writers);
54487 wake_up_interruptible_sync(&pipe->wait);
54488 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54489 pipe_unlock(pipe);
54490 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54491 * We actually want wait_event_freezable() but then we need
54492 * to clear TIF_SIGPENDING and improve dump_interrupted().
54493 */
54494 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54495 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54496
54497 pipe_lock(pipe);
54498 - pipe->readers--;
54499 - pipe->writers++;
54500 + atomic_dec(&pipe->readers);
54501 + atomic_inc(&pipe->writers);
54502 pipe_unlock(pipe);
54503 }
54504
54505 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54506 struct files_struct *displaced;
54507 bool need_nonrelative = false;
54508 bool core_dumped = false;
54509 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54510 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54511 + long signr = siginfo->si_signo;
54512 struct coredump_params cprm = {
54513 .siginfo = siginfo,
54514 .regs = signal_pt_regs(),
54515 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54516 .mm_flags = mm->flags,
54517 };
54518
54519 - audit_core_dumps(siginfo->si_signo);
54520 + audit_core_dumps(signr);
54521 +
54522 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54523 + gr_handle_brute_attach(cprm.mm_flags);
54524
54525 binfmt = mm->binfmt;
54526 if (!binfmt || !binfmt->core_dump)
54527 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54528 need_nonrelative = true;
54529 }
54530
54531 - retval = coredump_wait(siginfo->si_signo, &core_state);
54532 + retval = coredump_wait(signr, &core_state);
54533 if (retval < 0)
54534 goto fail_creds;
54535
54536 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54537 }
54538 cprm.limit = RLIM_INFINITY;
54539
54540 - dump_count = atomic_inc_return(&core_dump_count);
54541 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54542 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54543 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54544 task_tgid_vnr(current), current->comm);
54545 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54546 } else {
54547 struct inode *inode;
54548
54549 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54550 +
54551 if (cprm.limit < binfmt->min_coredump)
54552 goto fail_unlock;
54553
54554 @@ -664,7 +670,7 @@ close_fail:
54555 filp_close(cprm.file, NULL);
54556 fail_dropcount:
54557 if (ispipe)
54558 - atomic_dec(&core_dump_count);
54559 + atomic_dec_unchecked(&core_dump_count);
54560 fail_unlock:
54561 kfree(cn.corename);
54562 coredump_finish(mm, core_dumped);
54563 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54564 {
54565 return !dump_interrupted() &&
54566 access_ok(VERIFY_READ, addr, nr) &&
54567 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54568 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54569 }
54570 EXPORT_SYMBOL(dump_write);
54571
54572 diff --git a/fs/dcache.c b/fs/dcache.c
54573 index b949af8..5978926 100644
54574 --- a/fs/dcache.c
54575 +++ b/fs/dcache.c
54576 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54577 mempages -= reserve;
54578
54579 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54580 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54581 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54582 + SLAB_NO_SANITIZE, NULL);
54583
54584 dcache_init();
54585 inode_init();
54586 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54587 index c7c83ff..bda9461 100644
54588 --- a/fs/debugfs/inode.c
54589 +++ b/fs/debugfs/inode.c
54590 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54591 */
54592 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54593 {
54594 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54595 + return __create_file(name, S_IFDIR | S_IRWXU,
54596 +#else
54597 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54598 +#endif
54599 parent, NULL, NULL);
54600 }
54601 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54602 diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
54603 index d107576..40db688 100644
54604 --- a/fs/ecryptfs/crypto.c
54605 +++ b/fs/ecryptfs/crypto.c
54606 @@ -408,7 +408,7 @@ static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat,
54607 struct page *page)
54608 {
54609 return ecryptfs_lower_header_size(crypt_stat) +
54610 - (page->index << PAGE_CACHE_SHIFT);
54611 + ((loff_t)page->index << PAGE_CACHE_SHIFT);
54612 }
54613
54614 /**
54615 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54616 index 67e9b63..a9adb68 100644
54617 --- a/fs/ecryptfs/inode.c
54618 +++ b/fs/ecryptfs/inode.c
54619 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54620 old_fs = get_fs();
54621 set_fs(get_ds());
54622 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54623 - (char __user *)lower_buf,
54624 + (char __force_user *)lower_buf,
54625 PATH_MAX);
54626 set_fs(old_fs);
54627 if (rc < 0)
54628 @@ -706,7 +706,7 @@ out:
54629 static void
54630 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54631 {
54632 - char *buf = nd_get_link(nd);
54633 + const char *buf = nd_get_link(nd);
54634 if (!IS_ERR(buf)) {
54635 /* Free the char* */
54636 kfree(buf);
54637 diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
54638 index 7d52806..4725a07 100644
54639 --- a/fs/ecryptfs/keystore.c
54640 +++ b/fs/ecryptfs/keystore.c
54641 @@ -1149,7 +1149,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
54642 struct ecryptfs_msg_ctx *msg_ctx;
54643 struct ecryptfs_message *msg = NULL;
54644 char *auth_tok_sig;
54645 - char *payload;
54646 + char *payload = NULL;
54647 size_t payload_len = 0;
54648 int rc;
54649
54650 @@ -1203,6 +1203,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
54651 }
54652 out:
54653 kfree(msg);
54654 + kfree(payload);
54655 return rc;
54656 }
54657
54658 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54659 index e4141f2..d8263e8 100644
54660 --- a/fs/ecryptfs/miscdev.c
54661 +++ b/fs/ecryptfs/miscdev.c
54662 @@ -304,7 +304,7 @@ check_list:
54663 goto out_unlock_msg_ctx;
54664 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54665 if (msg_ctx->msg) {
54666 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54667 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54668 goto out_unlock_msg_ctx;
54669 i += packet_length_size;
54670 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54671 diff --git a/fs/exec.c b/fs/exec.c
54672 index fd774c7..1c6a7bf 100644
54673 --- a/fs/exec.c
54674 +++ b/fs/exec.c
54675 @@ -55,8 +55,20 @@
54676 #include <linux/pipe_fs_i.h>
54677 #include <linux/oom.h>
54678 #include <linux/compat.h>
54679 +#include <linux/random.h>
54680 +#include <linux/seq_file.h>
54681 +#include <linux/coredump.h>
54682 +#include <linux/mman.h>
54683 +
54684 +#ifdef CONFIG_PAX_REFCOUNT
54685 +#include <linux/kallsyms.h>
54686 +#include <linux/kdebug.h>
54687 +#endif
54688 +
54689 +#include <trace/events/fs.h>
54690
54691 #include <asm/uaccess.h>
54692 +#include <asm/sections.h>
54693 #include <asm/mmu_context.h>
54694 #include <asm/tlb.h>
54695
54696 @@ -66,17 +78,32 @@
54697
54698 #include <trace/events/sched.h>
54699
54700 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54701 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54702 +{
54703 + 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");
54704 +}
54705 +#endif
54706 +
54707 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54708 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54709 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54710 +#endif
54711 +
54712 int suid_dumpable = 0;
54713
54714 static LIST_HEAD(formats);
54715 static DEFINE_RWLOCK(binfmt_lock);
54716
54717 +extern int gr_process_kernel_exec_ban(void);
54718 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54719 +
54720 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54721 {
54722 BUG_ON(!fmt);
54723 write_lock(&binfmt_lock);
54724 - insert ? list_add(&fmt->lh, &formats) :
54725 - list_add_tail(&fmt->lh, &formats);
54726 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54727 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54728 write_unlock(&binfmt_lock);
54729 }
54730
54731 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54732 void unregister_binfmt(struct linux_binfmt * fmt)
54733 {
54734 write_lock(&binfmt_lock);
54735 - list_del(&fmt->lh);
54736 + pax_list_del((struct list_head *)&fmt->lh);
54737 write_unlock(&binfmt_lock);
54738 }
54739
54740 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54741 int write)
54742 {
54743 struct page *page;
54744 - int ret;
54745
54746 -#ifdef CONFIG_STACK_GROWSUP
54747 - if (write) {
54748 - ret = expand_downwards(bprm->vma, pos);
54749 - if (ret < 0)
54750 - return NULL;
54751 - }
54752 -#endif
54753 - ret = get_user_pages(current, bprm->mm, pos,
54754 - 1, write, 1, &page, NULL);
54755 - if (ret <= 0)
54756 + if (0 > expand_downwards(bprm->vma, pos))
54757 + return NULL;
54758 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54759 return NULL;
54760
54761 if (write) {
54762 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54763 if (size <= ARG_MAX)
54764 return page;
54765
54766 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54767 + // only allow 512KB for argv+env on suid/sgid binaries
54768 + // to prevent easy ASLR exhaustion
54769 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54770 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54771 + (size > (512 * 1024))) {
54772 + put_page(page);
54773 + return NULL;
54774 + }
54775 +#endif
54776 +
54777 /*
54778 * Limit to 1/4-th the stack size for the argv+env strings.
54779 * This ensures that:
54780 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54781 vma->vm_end = STACK_TOP_MAX;
54782 vma->vm_start = vma->vm_end - PAGE_SIZE;
54783 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54784 +
54785 +#ifdef CONFIG_PAX_SEGMEXEC
54786 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54787 +#endif
54788 +
54789 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54790 INIT_LIST_HEAD(&vma->anon_vma_chain);
54791
54792 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54793 mm->stack_vm = mm->total_vm = 1;
54794 up_write(&mm->mmap_sem);
54795 bprm->p = vma->vm_end - sizeof(void *);
54796 +
54797 +#ifdef CONFIG_PAX_RANDUSTACK
54798 + if (randomize_va_space)
54799 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54800 +#endif
54801 +
54802 return 0;
54803 err:
54804 up_write(&mm->mmap_sem);
54805 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54806 } ptr;
54807 };
54808
54809 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54810 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54811 {
54812 const char __user *native;
54813
54814 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54815 compat_uptr_t compat;
54816
54817 if (get_user(compat, argv.ptr.compat + nr))
54818 - return ERR_PTR(-EFAULT);
54819 + return (const char __force_user *)ERR_PTR(-EFAULT);
54820
54821 return compat_ptr(compat);
54822 }
54823 #endif
54824
54825 if (get_user(native, argv.ptr.native + nr))
54826 - return ERR_PTR(-EFAULT);
54827 + return (const char __force_user *)ERR_PTR(-EFAULT);
54828
54829 return native;
54830 }
54831 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54832 if (!p)
54833 break;
54834
54835 - if (IS_ERR(p))
54836 + if (IS_ERR((const char __force_kernel *)p))
54837 return -EFAULT;
54838
54839 if (i >= max)
54840 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54841
54842 ret = -EFAULT;
54843 str = get_user_arg_ptr(argv, argc);
54844 - if (IS_ERR(str))
54845 + if (IS_ERR((const char __force_kernel *)str))
54846 goto out;
54847
54848 len = strnlen_user(str, MAX_ARG_STRLEN);
54849 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54850 int r;
54851 mm_segment_t oldfs = get_fs();
54852 struct user_arg_ptr argv = {
54853 - .ptr.native = (const char __user *const __user *)__argv,
54854 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54855 };
54856
54857 set_fs(KERNEL_DS);
54858 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54859 unsigned long new_end = old_end - shift;
54860 struct mmu_gather tlb;
54861
54862 - BUG_ON(new_start > new_end);
54863 + if (new_start >= new_end || new_start < mmap_min_addr)
54864 + return -ENOMEM;
54865
54866 /*
54867 * ensure there are no vmas between where we want to go
54868 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54869 if (vma != find_vma(mm, new_start))
54870 return -EFAULT;
54871
54872 +#ifdef CONFIG_PAX_SEGMEXEC
54873 + BUG_ON(pax_find_mirror_vma(vma));
54874 +#endif
54875 +
54876 /*
54877 * cover the whole range: [new_start, old_end)
54878 */
54879 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54880 stack_top = arch_align_stack(stack_top);
54881 stack_top = PAGE_ALIGN(stack_top);
54882
54883 - if (unlikely(stack_top < mmap_min_addr) ||
54884 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54885 - return -ENOMEM;
54886 -
54887 stack_shift = vma->vm_end - stack_top;
54888
54889 bprm->p -= stack_shift;
54890 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54891 bprm->exec -= stack_shift;
54892
54893 down_write(&mm->mmap_sem);
54894 +
54895 + /* Move stack pages down in memory. */
54896 + if (stack_shift) {
54897 + ret = shift_arg_pages(vma, stack_shift);
54898 + if (ret)
54899 + goto out_unlock;
54900 + }
54901 +
54902 vm_flags = VM_STACK_FLAGS;
54903
54904 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54905 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54906 + vm_flags &= ~VM_EXEC;
54907 +
54908 +#ifdef CONFIG_PAX_MPROTECT
54909 + if (mm->pax_flags & MF_PAX_MPROTECT)
54910 + vm_flags &= ~VM_MAYEXEC;
54911 +#endif
54912 +
54913 + }
54914 +#endif
54915 +
54916 /*
54917 * Adjust stack execute permissions; explicitly enable for
54918 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54919 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54920 goto out_unlock;
54921 BUG_ON(prev != vma);
54922
54923 - /* Move stack pages down in memory. */
54924 - if (stack_shift) {
54925 - ret = shift_arg_pages(vma, stack_shift);
54926 - if (ret)
54927 - goto out_unlock;
54928 - }
54929 -
54930 /* mprotect_fixup is overkill to remove the temporary stack flags */
54931 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54932
54933 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54934 #endif
54935 current->mm->start_stack = bprm->p;
54936 ret = expand_stack(vma, stack_base);
54937 +
54938 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54939 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54940 + unsigned long size;
54941 + vm_flags_t vm_flags;
54942 +
54943 + size = STACK_TOP - vma->vm_end;
54944 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54945 +
54946 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54947 +
54948 +#ifdef CONFIG_X86
54949 + if (!ret) {
54950 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54951 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54952 + }
54953 +#endif
54954 +
54955 + }
54956 +#endif
54957 +
54958 if (ret)
54959 ret = -EFAULT;
54960
54961 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54962
54963 fsnotify_open(file);
54964
54965 + trace_open_exec(name);
54966 +
54967 err = deny_write_access(file);
54968 if (err)
54969 goto exit;
54970 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54971 old_fs = get_fs();
54972 set_fs(get_ds());
54973 /* The cast to a user pointer is valid due to the set_fs() */
54974 - result = vfs_read(file, (void __user *)addr, count, &pos);
54975 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54976 set_fs(old_fs);
54977 return result;
54978 }
54979 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54980 }
54981 rcu_read_unlock();
54982
54983 - if (p->fs->users > n_fs) {
54984 + if (atomic_read(&p->fs->users) > n_fs) {
54985 bprm->unsafe |= LSM_UNSAFE_SHARE;
54986 } else {
54987 res = -EAGAIN;
54988 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54989
54990 EXPORT_SYMBOL(search_binary_handler);
54991
54992 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54993 +static DEFINE_PER_CPU(u64, exec_counter);
54994 +static int __init init_exec_counters(void)
54995 +{
54996 + unsigned int cpu;
54997 +
54998 + for_each_possible_cpu(cpu) {
54999 + per_cpu(exec_counter, cpu) = (u64)cpu;
55000 + }
55001 +
55002 + return 0;
55003 +}
55004 +early_initcall(init_exec_counters);
55005 +static inline void increment_exec_counter(void)
55006 +{
55007 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55008 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55009 +}
55010 +#else
55011 +static inline void increment_exec_counter(void) {}
55012 +#endif
55013 +
55014 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55015 + struct user_arg_ptr argv);
55016 +
55017 /*
55018 * sys_execve() executes a new program.
55019 */
55020 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
55021 struct user_arg_ptr argv,
55022 struct user_arg_ptr envp)
55023 {
55024 +#ifdef CONFIG_GRKERNSEC
55025 + struct file *old_exec_file;
55026 + struct acl_subject_label *old_acl;
55027 + struct rlimit old_rlim[RLIM_NLIMITS];
55028 +#endif
55029 struct linux_binprm *bprm;
55030 struct file *file;
55031 struct files_struct *displaced;
55032 bool clear_in_exec;
55033 int retval;
55034
55035 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55036 +
55037 /*
55038 * We move the actual failure in case of RLIMIT_NPROC excess from
55039 * set*uid() to execve() because too many poorly written programs
55040 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
55041 if (IS_ERR(file))
55042 goto out_unmark;
55043
55044 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55045 + retval = -EPERM;
55046 + goto out_file;
55047 + }
55048 +
55049 sched_exec();
55050
55051 bprm->file = file;
55052 bprm->filename = filename;
55053 bprm->interp = filename;
55054
55055 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55056 + retval = -EACCES;
55057 + goto out_file;
55058 + }
55059 +
55060 retval = bprm_mm_init(bprm);
55061 if (retval)
55062 goto out_file;
55063 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
55064 if (retval < 0)
55065 goto out;
55066
55067 +#ifdef CONFIG_GRKERNSEC
55068 + old_acl = current->acl;
55069 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55070 + old_exec_file = current->exec_file;
55071 + get_file(file);
55072 + current->exec_file = file;
55073 +#endif
55074 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55075 + /* limit suid stack to 8MB
55076 + * we saved the old limits above and will restore them if this exec fails
55077 + */
55078 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55079 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55080 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55081 +#endif
55082 +
55083 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55084 + retval = -EPERM;
55085 + goto out_fail;
55086 + }
55087 +
55088 + if (!gr_tpe_allow(file)) {
55089 + retval = -EACCES;
55090 + goto out_fail;
55091 + }
55092 +
55093 + if (gr_check_crash_exec(file)) {
55094 + retval = -EACCES;
55095 + goto out_fail;
55096 + }
55097 +
55098 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55099 + bprm->unsafe);
55100 + if (retval < 0)
55101 + goto out_fail;
55102 +
55103 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55104 if (retval < 0)
55105 - goto out;
55106 + goto out_fail;
55107
55108 bprm->exec = bprm->p;
55109 retval = copy_strings(bprm->envc, envp, bprm);
55110 if (retval < 0)
55111 - goto out;
55112 + goto out_fail;
55113
55114 retval = copy_strings(bprm->argc, argv, bprm);
55115 if (retval < 0)
55116 - goto out;
55117 + goto out_fail;
55118 +
55119 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55120 +
55121 + gr_handle_exec_args(bprm, argv);
55122
55123 retval = search_binary_handler(bprm);
55124 if (retval < 0)
55125 - goto out;
55126 + goto out_fail;
55127 +#ifdef CONFIG_GRKERNSEC
55128 + if (old_exec_file)
55129 + fput(old_exec_file);
55130 +#endif
55131
55132 /* execve succeeded */
55133 +
55134 + increment_exec_counter();
55135 current->fs->in_exec = 0;
55136 current->in_execve = 0;
55137 acct_update_integrals(current);
55138 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55139 put_files_struct(displaced);
55140 return retval;
55141
55142 +out_fail:
55143 +#ifdef CONFIG_GRKERNSEC
55144 + current->acl = old_acl;
55145 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55146 + fput(current->exec_file);
55147 + current->exec_file = old_exec_file;
55148 +#endif
55149 +
55150 out:
55151 if (bprm->mm) {
55152 acct_arg_size(bprm, 0);
55153 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55154 return error;
55155 }
55156 #endif
55157 +
55158 +int pax_check_flags(unsigned long *flags)
55159 +{
55160 + int retval = 0;
55161 +
55162 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55163 + if (*flags & MF_PAX_SEGMEXEC)
55164 + {
55165 + *flags &= ~MF_PAX_SEGMEXEC;
55166 + retval = -EINVAL;
55167 + }
55168 +#endif
55169 +
55170 + if ((*flags & MF_PAX_PAGEEXEC)
55171 +
55172 +#ifdef CONFIG_PAX_PAGEEXEC
55173 + && (*flags & MF_PAX_SEGMEXEC)
55174 +#endif
55175 +
55176 + )
55177 + {
55178 + *flags &= ~MF_PAX_PAGEEXEC;
55179 + retval = -EINVAL;
55180 + }
55181 +
55182 + if ((*flags & MF_PAX_MPROTECT)
55183 +
55184 +#ifdef CONFIG_PAX_MPROTECT
55185 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55186 +#endif
55187 +
55188 + )
55189 + {
55190 + *flags &= ~MF_PAX_MPROTECT;
55191 + retval = -EINVAL;
55192 + }
55193 +
55194 + if ((*flags & MF_PAX_EMUTRAMP)
55195 +
55196 +#ifdef CONFIG_PAX_EMUTRAMP
55197 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55198 +#endif
55199 +
55200 + )
55201 + {
55202 + *flags &= ~MF_PAX_EMUTRAMP;
55203 + retval = -EINVAL;
55204 + }
55205 +
55206 + return retval;
55207 +}
55208 +
55209 +EXPORT_SYMBOL(pax_check_flags);
55210 +
55211 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55212 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55213 +{
55214 + char *pathname = d_path(path, buf, buflen);
55215 +
55216 + if (IS_ERR(pathname))
55217 + goto toolong;
55218 +
55219 + pathname = mangle_path(buf, pathname, "\t\n\\");
55220 + if (!pathname)
55221 + goto toolong;
55222 +
55223 + *pathname = 0;
55224 + return buf;
55225 +
55226 +toolong:
55227 + return "<path too long>";
55228 +}
55229 +EXPORT_SYMBOL(pax_get_path);
55230 +
55231 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55232 +{
55233 + struct task_struct *tsk = current;
55234 + struct mm_struct *mm = current->mm;
55235 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55236 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55237 + char *path_exec = NULL;
55238 + char *path_fault = NULL;
55239 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55240 + siginfo_t info = { };
55241 +
55242 + if (buffer_exec && buffer_fault) {
55243 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55244 +
55245 + down_read(&mm->mmap_sem);
55246 + vma = mm->mmap;
55247 + while (vma && (!vma_exec || !vma_fault)) {
55248 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55249 + vma_exec = vma;
55250 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55251 + vma_fault = vma;
55252 + vma = vma->vm_next;
55253 + }
55254 + if (vma_exec)
55255 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55256 + if (vma_fault) {
55257 + start = vma_fault->vm_start;
55258 + end = vma_fault->vm_end;
55259 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55260 + if (vma_fault->vm_file)
55261 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55262 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55263 + path_fault = "<heap>";
55264 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55265 + path_fault = "<stack>";
55266 + else
55267 + path_fault = "<anonymous mapping>";
55268 + }
55269 + up_read(&mm->mmap_sem);
55270 + }
55271 + if (tsk->signal->curr_ip)
55272 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55273 + else
55274 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55275 + 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),
55276 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55277 + free_page((unsigned long)buffer_exec);
55278 + free_page((unsigned long)buffer_fault);
55279 + pax_report_insns(regs, pc, sp);
55280 + info.si_signo = SIGKILL;
55281 + info.si_errno = 0;
55282 + info.si_code = SI_KERNEL;
55283 + info.si_pid = 0;
55284 + info.si_uid = 0;
55285 + do_coredump(&info);
55286 +}
55287 +#endif
55288 +
55289 +#ifdef CONFIG_PAX_REFCOUNT
55290 +void pax_report_refcount_overflow(struct pt_regs *regs)
55291 +{
55292 + if (current->signal->curr_ip)
55293 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55294 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55295 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55296 + else
55297 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55298 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55299 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55300 + preempt_disable();
55301 + show_regs(regs);
55302 + preempt_enable();
55303 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55304 +}
55305 +#endif
55306 +
55307 +#ifdef CONFIG_PAX_USERCOPY
55308 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55309 +static noinline int check_stack_object(const void *obj, unsigned long len)
55310 +{
55311 + const void * const stack = task_stack_page(current);
55312 + const void * const stackend = stack + THREAD_SIZE;
55313 +
55314 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55315 + const void *frame = NULL;
55316 + const void *oldframe;
55317 +#endif
55318 +
55319 + if (obj + len < obj)
55320 + return -1;
55321 +
55322 + if (obj + len <= stack || stackend <= obj)
55323 + return 0;
55324 +
55325 + if (obj < stack || stackend < obj + len)
55326 + return -1;
55327 +
55328 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55329 + oldframe = __builtin_frame_address(1);
55330 + if (oldframe)
55331 + frame = __builtin_frame_address(2);
55332 + /*
55333 + low ----------------------------------------------> high
55334 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55335 + ^----------------^
55336 + allow copies only within here
55337 + */
55338 + while (stack <= frame && frame < stackend) {
55339 + /* if obj + len extends past the last frame, this
55340 + check won't pass and the next frame will be 0,
55341 + causing us to bail out and correctly report
55342 + the copy as invalid
55343 + */
55344 + if (obj + len <= frame)
55345 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55346 + oldframe = frame;
55347 + frame = *(const void * const *)frame;
55348 + }
55349 + return -1;
55350 +#else
55351 + return 1;
55352 +#endif
55353 +}
55354 +
55355 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55356 +{
55357 + if (current->signal->curr_ip)
55358 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55359 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55360 + else
55361 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55362 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55363 + dump_stack();
55364 + gr_handle_kernel_exploit();
55365 + do_group_exit(SIGKILL);
55366 +}
55367 +#endif
55368 +
55369 +#ifdef CONFIG_PAX_USERCOPY
55370 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55371 +{
55372 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55373 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55374 +#ifdef CONFIG_MODULES
55375 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55376 +#else
55377 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55378 +#endif
55379 +
55380 +#else
55381 + unsigned long textlow = (unsigned long)_stext;
55382 + unsigned long texthigh = (unsigned long)_etext;
55383 +#endif
55384 +
55385 + if (high <= textlow || low > texthigh)
55386 + return false;
55387 + else
55388 + return true;
55389 +}
55390 +#endif
55391 +
55392 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55393 +{
55394 +
55395 +#ifdef CONFIG_PAX_USERCOPY
55396 + const char *type;
55397 +
55398 + if (!n)
55399 + return;
55400 +
55401 + type = check_heap_object(ptr, n);
55402 + if (!type) {
55403 + int ret = check_stack_object(ptr, n);
55404 + if (ret == 1 || ret == 2)
55405 + return;
55406 + if (ret == 0) {
55407 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55408 + type = "<kernel text>";
55409 + else
55410 + return;
55411 + } else
55412 + type = "<process stack>";
55413 + }
55414 +
55415 + pax_report_usercopy(ptr, n, to_user, type);
55416 +#endif
55417 +
55418 +}
55419 +EXPORT_SYMBOL(__check_object_size);
55420 +
55421 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55422 +void pax_track_stack(void)
55423 +{
55424 + unsigned long sp = (unsigned long)&sp;
55425 + if (sp < current_thread_info()->lowest_stack &&
55426 + sp > (unsigned long)task_stack_page(current))
55427 + current_thread_info()->lowest_stack = sp;
55428 +}
55429 +EXPORT_SYMBOL(pax_track_stack);
55430 +#endif
55431 +
55432 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55433 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55434 +{
55435 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55436 + dump_stack();
55437 + do_group_exit(SIGKILL);
55438 +}
55439 +EXPORT_SYMBOL(report_size_overflow);
55440 +#endif
55441 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55442 index 9f9992b..8b59411 100644
55443 --- a/fs/ext2/balloc.c
55444 +++ b/fs/ext2/balloc.c
55445 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55446
55447 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55448 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55449 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55450 + if (free_blocks < root_blocks + 1 &&
55451 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55452 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55453 - !in_group_p (sbi->s_resgid))) {
55454 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55455 return 0;
55456 }
55457 return 1;
55458 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55459 index 22548f5..41521d8 100644
55460 --- a/fs/ext3/balloc.c
55461 +++ b/fs/ext3/balloc.c
55462 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55463
55464 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55465 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55466 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55467 + if (free_blocks < root_blocks + 1 &&
55468 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55469 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55470 - !in_group_p (sbi->s_resgid))) {
55471 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55472 return 0;
55473 }
55474 return 1;
55475 diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
55476 index 1194b1f..f8cde46 100644
55477 --- a/fs/ext3/namei.c
55478 +++ b/fs/ext3/namei.c
55479 @@ -1783,7 +1783,7 @@ retry:
55480 d_tmpfile(dentry, inode);
55481 err = ext3_orphan_add(handle, inode);
55482 if (err)
55483 - goto err_drop_inode;
55484 + goto err_unlock_inode;
55485 mark_inode_dirty(inode);
55486 unlock_new_inode(inode);
55487 }
55488 @@ -1791,10 +1791,9 @@ retry:
55489 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
55490 goto retry;
55491 return err;
55492 -err_drop_inode:
55493 +err_unlock_inode:
55494 ext3_journal_stop(handle);
55495 unlock_new_inode(inode);
55496 - iput(inode);
55497 return err;
55498 }
55499
55500 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55501 index ddd715e..c772f88 100644
55502 --- a/fs/ext4/balloc.c
55503 +++ b/fs/ext4/balloc.c
55504 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55505 /* Hm, nope. Are (enough) root reserved clusters available? */
55506 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55507 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55508 - capable(CAP_SYS_RESOURCE) ||
55509 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55510 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55511 + capable_nolog(CAP_SYS_RESOURCE)) {
55512
55513 if (free_clusters >= (nclusters + dirty_clusters +
55514 resv_clusters))
55515 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55516 index 0ab26fb..b6ecb39 100644
55517 --- a/fs/ext4/ext4.h
55518 +++ b/fs/ext4/ext4.h
55519 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55520 unsigned long s_mb_last_start;
55521
55522 /* stats for buddy allocator */
55523 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55524 - atomic_t s_bal_success; /* we found long enough chunks */
55525 - atomic_t s_bal_allocated; /* in blocks */
55526 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55527 - atomic_t s_bal_goals; /* goal hits */
55528 - atomic_t s_bal_breaks; /* too long searches */
55529 - atomic_t s_bal_2orders; /* 2^order hits */
55530 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55531 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55532 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55533 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55534 + atomic_unchecked_t s_bal_goals; /* goal hits */
55535 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55536 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55537 spinlock_t s_bal_lock;
55538 unsigned long s_mb_buddies_generated;
55539 unsigned long long s_mb_generation_time;
55540 - atomic_t s_mb_lost_chunks;
55541 - atomic_t s_mb_preallocated;
55542 - atomic_t s_mb_discarded;
55543 + atomic_unchecked_t s_mb_lost_chunks;
55544 + atomic_unchecked_t s_mb_preallocated;
55545 + atomic_unchecked_t s_mb_discarded;
55546 atomic_t s_lock_busy;
55547
55548 /* locality groups */
55549 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55550 index 4bbbf13b..dcceaeb 100644
55551 --- a/fs/ext4/mballoc.c
55552 +++ b/fs/ext4/mballoc.c
55553 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55554 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55555
55556 if (EXT4_SB(sb)->s_mb_stats)
55557 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55558 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55559
55560 break;
55561 }
55562 @@ -2171,7 +2171,7 @@ repeat:
55563 ac->ac_status = AC_STATUS_CONTINUE;
55564 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55565 cr = 3;
55566 - atomic_inc(&sbi->s_mb_lost_chunks);
55567 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55568 goto repeat;
55569 }
55570 }
55571 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55572 if (sbi->s_mb_stats) {
55573 ext4_msg(sb, KERN_INFO,
55574 "mballoc: %u blocks %u reqs (%u success)",
55575 - atomic_read(&sbi->s_bal_allocated),
55576 - atomic_read(&sbi->s_bal_reqs),
55577 - atomic_read(&sbi->s_bal_success));
55578 + atomic_read_unchecked(&sbi->s_bal_allocated),
55579 + atomic_read_unchecked(&sbi->s_bal_reqs),
55580 + atomic_read_unchecked(&sbi->s_bal_success));
55581 ext4_msg(sb, KERN_INFO,
55582 "mballoc: %u extents scanned, %u goal hits, "
55583 "%u 2^N hits, %u breaks, %u lost",
55584 - atomic_read(&sbi->s_bal_ex_scanned),
55585 - atomic_read(&sbi->s_bal_goals),
55586 - atomic_read(&sbi->s_bal_2orders),
55587 - atomic_read(&sbi->s_bal_breaks),
55588 - atomic_read(&sbi->s_mb_lost_chunks));
55589 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55590 + atomic_read_unchecked(&sbi->s_bal_goals),
55591 + atomic_read_unchecked(&sbi->s_bal_2orders),
55592 + atomic_read_unchecked(&sbi->s_bal_breaks),
55593 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55594 ext4_msg(sb, KERN_INFO,
55595 "mballoc: %lu generated and it took %Lu",
55596 sbi->s_mb_buddies_generated,
55597 sbi->s_mb_generation_time);
55598 ext4_msg(sb, KERN_INFO,
55599 "mballoc: %u preallocated, %u discarded",
55600 - atomic_read(&sbi->s_mb_preallocated),
55601 - atomic_read(&sbi->s_mb_discarded));
55602 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55603 + atomic_read_unchecked(&sbi->s_mb_discarded));
55604 }
55605
55606 free_percpu(sbi->s_locality_groups);
55607 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55608 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55609
55610 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55611 - atomic_inc(&sbi->s_bal_reqs);
55612 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55613 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55614 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55615 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55616 - atomic_inc(&sbi->s_bal_success);
55617 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55618 + atomic_inc_unchecked(&sbi->s_bal_success);
55619 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55620 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55621 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55622 - atomic_inc(&sbi->s_bal_goals);
55623 + atomic_inc_unchecked(&sbi->s_bal_goals);
55624 if (ac->ac_found > sbi->s_mb_max_to_scan)
55625 - atomic_inc(&sbi->s_bal_breaks);
55626 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55627 }
55628
55629 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55630 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55631 trace_ext4_mb_new_inode_pa(ac, pa);
55632
55633 ext4_mb_use_inode_pa(ac, pa);
55634 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55635 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55636
55637 ei = EXT4_I(ac->ac_inode);
55638 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55639 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55640 trace_ext4_mb_new_group_pa(ac, pa);
55641
55642 ext4_mb_use_group_pa(ac, pa);
55643 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55644 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55645
55646 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55647 lg = ac->ac_lg;
55648 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55649 * from the bitmap and continue.
55650 */
55651 }
55652 - atomic_add(free, &sbi->s_mb_discarded);
55653 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55654
55655 return err;
55656 }
55657 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55658 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55659 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55660 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55661 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55662 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55663 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55664
55665 return 0;
55666 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55667 index 214461e..3614c89 100644
55668 --- a/fs/ext4/mmp.c
55669 +++ b/fs/ext4/mmp.c
55670 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55671 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55672 const char *function, unsigned int line, const char *msg)
55673 {
55674 - __ext4_warning(sb, function, line, msg);
55675 + __ext4_warning(sb, function, line, "%s", msg);
55676 __ext4_warning(sb, function, line,
55677 "MMP failure info: last update time: %llu, last update "
55678 "node: %s, last update device: %s\n",
55679 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
55680 index 35f55a0..b53cbc6 100644
55681 --- a/fs/ext4/namei.c
55682 +++ b/fs/ext4/namei.c
55683 @@ -2319,7 +2319,7 @@ retry:
55684 d_tmpfile(dentry, inode);
55685 err = ext4_orphan_add(handle, inode);
55686 if (err)
55687 - goto err_drop_inode;
55688 + goto err_unlock_inode;
55689 mark_inode_dirty(inode);
55690 unlock_new_inode(inode);
55691 }
55692 @@ -2328,10 +2328,9 @@ retry:
55693 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
55694 goto retry;
55695 return err;
55696 -err_drop_inode:
55697 +err_unlock_inode:
55698 ext4_journal_stop(handle);
55699 unlock_new_inode(inode);
55700 - iput(inode);
55701 return err;
55702 }
55703
55704 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55705 index b59373b..f41c2b5 100644
55706 --- a/fs/ext4/super.c
55707 +++ b/fs/ext4/super.c
55708 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55709 }
55710
55711 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55712 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55713 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55714 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55715
55716 #ifdef CONFIG_QUOTA
55717 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55718 int offset;
55719 int deprecated_val;
55720 } u;
55721 -};
55722 +} __do_const;
55723
55724 static int parse_strtoull(const char *buf,
55725 unsigned long long max, unsigned long long *value)
55726 diff --git a/fs/fcntl.c b/fs/fcntl.c
55727 index 65343c3..9969dcf 100644
55728 --- a/fs/fcntl.c
55729 +++ b/fs/fcntl.c
55730 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55731 if (err)
55732 return err;
55733
55734 + if (gr_handle_chroot_fowner(pid, type))
55735 + return -ENOENT;
55736 + if (gr_check_protected_task_fowner(pid, type))
55737 + return -EACCES;
55738 +
55739 f_modown(filp, pid, type, force);
55740 return 0;
55741 }
55742 diff --git a/fs/fhandle.c b/fs/fhandle.c
55743 index 999ff5c..41f4109 100644
55744 --- a/fs/fhandle.c
55745 +++ b/fs/fhandle.c
55746 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55747 } else
55748 retval = 0;
55749 /* copy the mount id */
55750 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55751 - sizeof(*mnt_id)) ||
55752 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55753 copy_to_user(ufh, handle,
55754 sizeof(struct file_handle) + handle_bytes))
55755 retval = -EFAULT;
55756 diff --git a/fs/file.c b/fs/file.c
55757 index 4a78f98..9447397 100644
55758 --- a/fs/file.c
55759 +++ b/fs/file.c
55760 @@ -16,6 +16,7 @@
55761 #include <linux/slab.h>
55762 #include <linux/vmalloc.h>
55763 #include <linux/file.h>
55764 +#include <linux/security.h>
55765 #include <linux/fdtable.h>
55766 #include <linux/bitops.h>
55767 #include <linux/interrupt.h>
55768 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55769 if (!file)
55770 return __close_fd(files, fd);
55771
55772 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55773 if (fd >= rlimit(RLIMIT_NOFILE))
55774 return -EBADF;
55775
55776 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55777 if (unlikely(oldfd == newfd))
55778 return -EINVAL;
55779
55780 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55781 if (newfd >= rlimit(RLIMIT_NOFILE))
55782 return -EBADF;
55783
55784 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55785 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55786 {
55787 int err;
55788 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55789 if (from >= rlimit(RLIMIT_NOFILE))
55790 return -EINVAL;
55791 err = alloc_fd(from, flags);
55792 diff --git a/fs/filesystems.c b/fs/filesystems.c
55793 index 92567d9..fcd8cbf 100644
55794 --- a/fs/filesystems.c
55795 +++ b/fs/filesystems.c
55796 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55797 int len = dot ? dot - name : strlen(name);
55798
55799 fs = __get_fs_type(name, len);
55800 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55801 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55802 +#else
55803 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55804 +#endif
55805 fs = __get_fs_type(name, len);
55806
55807 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55808 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55809 index d8ac61d..79a36f0 100644
55810 --- a/fs/fs_struct.c
55811 +++ b/fs/fs_struct.c
55812 @@ -4,6 +4,7 @@
55813 #include <linux/path.h>
55814 #include <linux/slab.h>
55815 #include <linux/fs_struct.h>
55816 +#include <linux/grsecurity.h>
55817 #include "internal.h"
55818
55819 /*
55820 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55821 write_seqcount_begin(&fs->seq);
55822 old_root = fs->root;
55823 fs->root = *path;
55824 + gr_set_chroot_entries(current, path);
55825 write_seqcount_end(&fs->seq);
55826 spin_unlock(&fs->lock);
55827 if (old_root.dentry)
55828 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55829 int hits = 0;
55830 spin_lock(&fs->lock);
55831 write_seqcount_begin(&fs->seq);
55832 + /* this root replacement is only done by pivot_root,
55833 + leave grsec's chroot tagging alone for this task
55834 + so that a pivoted root isn't treated as a chroot
55835 + */
55836 hits += replace_path(&fs->root, old_root, new_root);
55837 hits += replace_path(&fs->pwd, old_root, new_root);
55838 write_seqcount_end(&fs->seq);
55839 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55840 task_lock(tsk);
55841 spin_lock(&fs->lock);
55842 tsk->fs = NULL;
55843 - kill = !--fs->users;
55844 + gr_clear_chroot_entries(tsk);
55845 + kill = !atomic_dec_return(&fs->users);
55846 spin_unlock(&fs->lock);
55847 task_unlock(tsk);
55848 if (kill)
55849 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55850 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55851 /* We don't need to lock fs - think why ;-) */
55852 if (fs) {
55853 - fs->users = 1;
55854 + atomic_set(&fs->users, 1);
55855 fs->in_exec = 0;
55856 spin_lock_init(&fs->lock);
55857 seqcount_init(&fs->seq);
55858 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55859 spin_lock(&old->lock);
55860 fs->root = old->root;
55861 path_get(&fs->root);
55862 + /* instead of calling gr_set_chroot_entries here,
55863 + we call it from every caller of this function
55864 + */
55865 fs->pwd = old->pwd;
55866 path_get(&fs->pwd);
55867 spin_unlock(&old->lock);
55868 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55869
55870 task_lock(current);
55871 spin_lock(&fs->lock);
55872 - kill = !--fs->users;
55873 + kill = !atomic_dec_return(&fs->users);
55874 current->fs = new_fs;
55875 + gr_set_chroot_entries(current, &new_fs->root);
55876 spin_unlock(&fs->lock);
55877 task_unlock(current);
55878
55879 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55880
55881 int current_umask(void)
55882 {
55883 - return current->fs->umask;
55884 + return current->fs->umask | gr_acl_umask();
55885 }
55886 EXPORT_SYMBOL(current_umask);
55887
55888 /* to be mentioned only in INIT_TASK */
55889 struct fs_struct init_fs = {
55890 - .users = 1,
55891 + .users = ATOMIC_INIT(1),
55892 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55893 .seq = SEQCNT_ZERO,
55894 .umask = 0022,
55895 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55896 index 0e91a3c..6c6d2e0 100644
55897 --- a/fs/fscache/cookie.c
55898 +++ b/fs/fscache/cookie.c
55899 @@ -19,7 +19,7 @@
55900
55901 struct kmem_cache *fscache_cookie_jar;
55902
55903 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55904 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55905
55906 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55907 static int fscache_alloc_object(struct fscache_cache *cache,
55908 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55909 parent ? (char *) parent->def->name : "<no-parent>",
55910 def->name, netfs_data);
55911
55912 - fscache_stat(&fscache_n_acquires);
55913 + fscache_stat_unchecked(&fscache_n_acquires);
55914
55915 /* if there's no parent cookie, then we don't create one here either */
55916 if (!parent) {
55917 - fscache_stat(&fscache_n_acquires_null);
55918 + fscache_stat_unchecked(&fscache_n_acquires_null);
55919 _leave(" [no parent]");
55920 return NULL;
55921 }
55922 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55923 /* allocate and initialise a cookie */
55924 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55925 if (!cookie) {
55926 - fscache_stat(&fscache_n_acquires_oom);
55927 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55928 _leave(" [ENOMEM]");
55929 return NULL;
55930 }
55931 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55932
55933 switch (cookie->def->type) {
55934 case FSCACHE_COOKIE_TYPE_INDEX:
55935 - fscache_stat(&fscache_n_cookie_index);
55936 + fscache_stat_unchecked(&fscache_n_cookie_index);
55937 break;
55938 case FSCACHE_COOKIE_TYPE_DATAFILE:
55939 - fscache_stat(&fscache_n_cookie_data);
55940 + fscache_stat_unchecked(&fscache_n_cookie_data);
55941 break;
55942 default:
55943 - fscache_stat(&fscache_n_cookie_special);
55944 + fscache_stat_unchecked(&fscache_n_cookie_special);
55945 break;
55946 }
55947
55948 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55949 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55950 atomic_dec(&parent->n_children);
55951 __fscache_cookie_put(cookie);
55952 - fscache_stat(&fscache_n_acquires_nobufs);
55953 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55954 _leave(" = NULL");
55955 return NULL;
55956 }
55957 }
55958
55959 - fscache_stat(&fscache_n_acquires_ok);
55960 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55961 _leave(" = %p", cookie);
55962 return cookie;
55963 }
55964 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55965 cache = fscache_select_cache_for_object(cookie->parent);
55966 if (!cache) {
55967 up_read(&fscache_addremove_sem);
55968 - fscache_stat(&fscache_n_acquires_no_cache);
55969 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55970 _leave(" = -ENOMEDIUM [no cache]");
55971 return -ENOMEDIUM;
55972 }
55973 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55974 object = cache->ops->alloc_object(cache, cookie);
55975 fscache_stat_d(&fscache_n_cop_alloc_object);
55976 if (IS_ERR(object)) {
55977 - fscache_stat(&fscache_n_object_no_alloc);
55978 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55979 ret = PTR_ERR(object);
55980 goto error;
55981 }
55982
55983 - fscache_stat(&fscache_n_object_alloc);
55984 + fscache_stat_unchecked(&fscache_n_object_alloc);
55985
55986 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55987 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55988
55989 _debug("ALLOC OBJ%x: %s {%lx}",
55990 object->debug_id, cookie->def->name, object->events);
55991 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55992
55993 _enter("{%s}", cookie->def->name);
55994
55995 - fscache_stat(&fscache_n_invalidates);
55996 + fscache_stat_unchecked(&fscache_n_invalidates);
55997
55998 /* Only permit invalidation of data files. Invalidating an index will
55999 * require the caller to release all its attachments to the tree rooted
56000 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56001 {
56002 struct fscache_object *object;
56003
56004 - fscache_stat(&fscache_n_updates);
56005 + fscache_stat_unchecked(&fscache_n_updates);
56006
56007 if (!cookie) {
56008 - fscache_stat(&fscache_n_updates_null);
56009 + fscache_stat_unchecked(&fscache_n_updates_null);
56010 _leave(" [no cookie]");
56011 return;
56012 }
56013 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56014 {
56015 struct fscache_object *object;
56016
56017 - fscache_stat(&fscache_n_relinquishes);
56018 + fscache_stat_unchecked(&fscache_n_relinquishes);
56019 if (retire)
56020 - fscache_stat(&fscache_n_relinquishes_retire);
56021 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56022
56023 if (!cookie) {
56024 - fscache_stat(&fscache_n_relinquishes_null);
56025 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56026 _leave(" [no cookie]");
56027 return;
56028 }
56029 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56030 index 12d505b..86473a3 100644
56031 --- a/fs/fscache/internal.h
56032 +++ b/fs/fscache/internal.h
56033 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
56034 * stats.c
56035 */
56036 #ifdef CONFIG_FSCACHE_STATS
56037 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56038 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56039 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56040 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56041
56042 -extern atomic_t fscache_n_op_pend;
56043 -extern atomic_t fscache_n_op_run;
56044 -extern atomic_t fscache_n_op_enqueue;
56045 -extern atomic_t fscache_n_op_deferred_release;
56046 -extern atomic_t fscache_n_op_release;
56047 -extern atomic_t fscache_n_op_gc;
56048 -extern atomic_t fscache_n_op_cancelled;
56049 -extern atomic_t fscache_n_op_rejected;
56050 +extern atomic_unchecked_t fscache_n_op_pend;
56051 +extern atomic_unchecked_t fscache_n_op_run;
56052 +extern atomic_unchecked_t fscache_n_op_enqueue;
56053 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56054 +extern atomic_unchecked_t fscache_n_op_release;
56055 +extern atomic_unchecked_t fscache_n_op_gc;
56056 +extern atomic_unchecked_t fscache_n_op_cancelled;
56057 +extern atomic_unchecked_t fscache_n_op_rejected;
56058
56059 -extern atomic_t fscache_n_attr_changed;
56060 -extern atomic_t fscache_n_attr_changed_ok;
56061 -extern atomic_t fscache_n_attr_changed_nobufs;
56062 -extern atomic_t fscache_n_attr_changed_nomem;
56063 -extern atomic_t fscache_n_attr_changed_calls;
56064 +extern atomic_unchecked_t fscache_n_attr_changed;
56065 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56066 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56067 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56068 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56069
56070 -extern atomic_t fscache_n_allocs;
56071 -extern atomic_t fscache_n_allocs_ok;
56072 -extern atomic_t fscache_n_allocs_wait;
56073 -extern atomic_t fscache_n_allocs_nobufs;
56074 -extern atomic_t fscache_n_allocs_intr;
56075 -extern atomic_t fscache_n_allocs_object_dead;
56076 -extern atomic_t fscache_n_alloc_ops;
56077 -extern atomic_t fscache_n_alloc_op_waits;
56078 +extern atomic_unchecked_t fscache_n_allocs;
56079 +extern atomic_unchecked_t fscache_n_allocs_ok;
56080 +extern atomic_unchecked_t fscache_n_allocs_wait;
56081 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56082 +extern atomic_unchecked_t fscache_n_allocs_intr;
56083 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56084 +extern atomic_unchecked_t fscache_n_alloc_ops;
56085 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56086
56087 -extern atomic_t fscache_n_retrievals;
56088 -extern atomic_t fscache_n_retrievals_ok;
56089 -extern atomic_t fscache_n_retrievals_wait;
56090 -extern atomic_t fscache_n_retrievals_nodata;
56091 -extern atomic_t fscache_n_retrievals_nobufs;
56092 -extern atomic_t fscache_n_retrievals_intr;
56093 -extern atomic_t fscache_n_retrievals_nomem;
56094 -extern atomic_t fscache_n_retrievals_object_dead;
56095 -extern atomic_t fscache_n_retrieval_ops;
56096 -extern atomic_t fscache_n_retrieval_op_waits;
56097 +extern atomic_unchecked_t fscache_n_retrievals;
56098 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56099 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56100 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56101 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56102 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56103 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56104 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56105 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56106 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56107
56108 -extern atomic_t fscache_n_stores;
56109 -extern atomic_t fscache_n_stores_ok;
56110 -extern atomic_t fscache_n_stores_again;
56111 -extern atomic_t fscache_n_stores_nobufs;
56112 -extern atomic_t fscache_n_stores_oom;
56113 -extern atomic_t fscache_n_store_ops;
56114 -extern atomic_t fscache_n_store_calls;
56115 -extern atomic_t fscache_n_store_pages;
56116 -extern atomic_t fscache_n_store_radix_deletes;
56117 -extern atomic_t fscache_n_store_pages_over_limit;
56118 +extern atomic_unchecked_t fscache_n_stores;
56119 +extern atomic_unchecked_t fscache_n_stores_ok;
56120 +extern atomic_unchecked_t fscache_n_stores_again;
56121 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56122 +extern atomic_unchecked_t fscache_n_stores_oom;
56123 +extern atomic_unchecked_t fscache_n_store_ops;
56124 +extern atomic_unchecked_t fscache_n_store_calls;
56125 +extern atomic_unchecked_t fscache_n_store_pages;
56126 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56127 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56128
56129 -extern atomic_t fscache_n_store_vmscan_not_storing;
56130 -extern atomic_t fscache_n_store_vmscan_gone;
56131 -extern atomic_t fscache_n_store_vmscan_busy;
56132 -extern atomic_t fscache_n_store_vmscan_cancelled;
56133 -extern atomic_t fscache_n_store_vmscan_wait;
56134 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56135 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56136 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56137 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56138 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56139
56140 -extern atomic_t fscache_n_marks;
56141 -extern atomic_t fscache_n_uncaches;
56142 +extern atomic_unchecked_t fscache_n_marks;
56143 +extern atomic_unchecked_t fscache_n_uncaches;
56144
56145 -extern atomic_t fscache_n_acquires;
56146 -extern atomic_t fscache_n_acquires_null;
56147 -extern atomic_t fscache_n_acquires_no_cache;
56148 -extern atomic_t fscache_n_acquires_ok;
56149 -extern atomic_t fscache_n_acquires_nobufs;
56150 -extern atomic_t fscache_n_acquires_oom;
56151 +extern atomic_unchecked_t fscache_n_acquires;
56152 +extern atomic_unchecked_t fscache_n_acquires_null;
56153 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56154 +extern atomic_unchecked_t fscache_n_acquires_ok;
56155 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56156 +extern atomic_unchecked_t fscache_n_acquires_oom;
56157
56158 -extern atomic_t fscache_n_invalidates;
56159 -extern atomic_t fscache_n_invalidates_run;
56160 +extern atomic_unchecked_t fscache_n_invalidates;
56161 +extern atomic_unchecked_t fscache_n_invalidates_run;
56162
56163 -extern atomic_t fscache_n_updates;
56164 -extern atomic_t fscache_n_updates_null;
56165 -extern atomic_t fscache_n_updates_run;
56166 +extern atomic_unchecked_t fscache_n_updates;
56167 +extern atomic_unchecked_t fscache_n_updates_null;
56168 +extern atomic_unchecked_t fscache_n_updates_run;
56169
56170 -extern atomic_t fscache_n_relinquishes;
56171 -extern atomic_t fscache_n_relinquishes_null;
56172 -extern atomic_t fscache_n_relinquishes_waitcrt;
56173 -extern atomic_t fscache_n_relinquishes_retire;
56174 +extern atomic_unchecked_t fscache_n_relinquishes;
56175 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56176 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56177 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56178
56179 -extern atomic_t fscache_n_cookie_index;
56180 -extern atomic_t fscache_n_cookie_data;
56181 -extern atomic_t fscache_n_cookie_special;
56182 +extern atomic_unchecked_t fscache_n_cookie_index;
56183 +extern atomic_unchecked_t fscache_n_cookie_data;
56184 +extern atomic_unchecked_t fscache_n_cookie_special;
56185
56186 -extern atomic_t fscache_n_object_alloc;
56187 -extern atomic_t fscache_n_object_no_alloc;
56188 -extern atomic_t fscache_n_object_lookups;
56189 -extern atomic_t fscache_n_object_lookups_negative;
56190 -extern atomic_t fscache_n_object_lookups_positive;
56191 -extern atomic_t fscache_n_object_lookups_timed_out;
56192 -extern atomic_t fscache_n_object_created;
56193 -extern atomic_t fscache_n_object_avail;
56194 -extern atomic_t fscache_n_object_dead;
56195 +extern atomic_unchecked_t fscache_n_object_alloc;
56196 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56197 +extern atomic_unchecked_t fscache_n_object_lookups;
56198 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56199 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56200 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56201 +extern atomic_unchecked_t fscache_n_object_created;
56202 +extern atomic_unchecked_t fscache_n_object_avail;
56203 +extern atomic_unchecked_t fscache_n_object_dead;
56204
56205 -extern atomic_t fscache_n_checkaux_none;
56206 -extern atomic_t fscache_n_checkaux_okay;
56207 -extern atomic_t fscache_n_checkaux_update;
56208 -extern atomic_t fscache_n_checkaux_obsolete;
56209 +extern atomic_unchecked_t fscache_n_checkaux_none;
56210 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56211 +extern atomic_unchecked_t fscache_n_checkaux_update;
56212 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56213
56214 extern atomic_t fscache_n_cop_alloc_object;
56215 extern atomic_t fscache_n_cop_lookup_object;
56216 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56217 atomic_inc(stat);
56218 }
56219
56220 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56221 +{
56222 + atomic_inc_unchecked(stat);
56223 +}
56224 +
56225 static inline void fscache_stat_d(atomic_t *stat)
56226 {
56227 atomic_dec(stat);
56228 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56229
56230 #define __fscache_stat(stat) (NULL)
56231 #define fscache_stat(stat) do {} while (0)
56232 +#define fscache_stat_unchecked(stat) do {} while (0)
56233 #define fscache_stat_d(stat) do {} while (0)
56234 #endif
56235
56236 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56237 index 86d75a6..5f3d7a0 100644
56238 --- a/fs/fscache/object.c
56239 +++ b/fs/fscache/object.c
56240 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56241 _debug("LOOKUP \"%s\" in \"%s\"",
56242 cookie->def->name, object->cache->tag->name);
56243
56244 - fscache_stat(&fscache_n_object_lookups);
56245 + fscache_stat_unchecked(&fscache_n_object_lookups);
56246 fscache_stat(&fscache_n_cop_lookup_object);
56247 ret = object->cache->ops->lookup_object(object);
56248 fscache_stat_d(&fscache_n_cop_lookup_object);
56249 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56250 if (ret == -ETIMEDOUT) {
56251 /* probably stuck behind another object, so move this one to
56252 * the back of the queue */
56253 - fscache_stat(&fscache_n_object_lookups_timed_out);
56254 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56255 _leave(" [timeout]");
56256 return NO_TRANSIT;
56257 }
56258 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56259 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56260
56261 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56262 - fscache_stat(&fscache_n_object_lookups_negative);
56263 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56264
56265 /* Allow write requests to begin stacking up and read requests to begin
56266 * returning ENODATA.
56267 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56268 /* if we were still looking up, then we must have a positive lookup
56269 * result, in which case there may be data available */
56270 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56271 - fscache_stat(&fscache_n_object_lookups_positive);
56272 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56273
56274 /* We do (presumably) have data */
56275 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56276 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56277 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56278 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56279 } else {
56280 - fscache_stat(&fscache_n_object_created);
56281 + fscache_stat_unchecked(&fscache_n_object_created);
56282 }
56283
56284 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56285 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56286 fscache_stat_d(&fscache_n_cop_lookup_complete);
56287
56288 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56289 - fscache_stat(&fscache_n_object_avail);
56290 + fscache_stat_unchecked(&fscache_n_object_avail);
56291
56292 _leave("");
56293 return transit_to(JUMPSTART_DEPS);
56294 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56295
56296 /* this just shifts the object release to the work processor */
56297 fscache_put_object(object);
56298 - fscache_stat(&fscache_n_object_dead);
56299 + fscache_stat_unchecked(&fscache_n_object_dead);
56300
56301 _leave("");
56302 return transit_to(OBJECT_DEAD);
56303 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56304 enum fscache_checkaux result;
56305
56306 if (!object->cookie->def->check_aux) {
56307 - fscache_stat(&fscache_n_checkaux_none);
56308 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56309 return FSCACHE_CHECKAUX_OKAY;
56310 }
56311
56312 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56313 switch (result) {
56314 /* entry okay as is */
56315 case FSCACHE_CHECKAUX_OKAY:
56316 - fscache_stat(&fscache_n_checkaux_okay);
56317 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56318 break;
56319
56320 /* entry requires update */
56321 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56322 - fscache_stat(&fscache_n_checkaux_update);
56323 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56324 break;
56325
56326 /* entry requires deletion */
56327 case FSCACHE_CHECKAUX_OBSOLETE:
56328 - fscache_stat(&fscache_n_checkaux_obsolete);
56329 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56330 break;
56331
56332 default:
56333 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56334 {
56335 const struct fscache_state *s;
56336
56337 - fscache_stat(&fscache_n_invalidates_run);
56338 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56339 fscache_stat(&fscache_n_cop_invalidate_object);
56340 s = _fscache_invalidate_object(object, event);
56341 fscache_stat_d(&fscache_n_cop_invalidate_object);
56342 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56343 {
56344 _enter("{OBJ%x},%d", object->debug_id, event);
56345
56346 - fscache_stat(&fscache_n_updates_run);
56347 + fscache_stat_unchecked(&fscache_n_updates_run);
56348 fscache_stat(&fscache_n_cop_update_object);
56349 object->cache->ops->update_object(object);
56350 fscache_stat_d(&fscache_n_cop_update_object);
56351 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56352 index 318071a..379938b 100644
56353 --- a/fs/fscache/operation.c
56354 +++ b/fs/fscache/operation.c
56355 @@ -17,7 +17,7 @@
56356 #include <linux/slab.h>
56357 #include "internal.h"
56358
56359 -atomic_t fscache_op_debug_id;
56360 +atomic_unchecked_t fscache_op_debug_id;
56361 EXPORT_SYMBOL(fscache_op_debug_id);
56362
56363 /**
56364 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56365 ASSERTCMP(atomic_read(&op->usage), >, 0);
56366 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56367
56368 - fscache_stat(&fscache_n_op_enqueue);
56369 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56370 switch (op->flags & FSCACHE_OP_TYPE) {
56371 case FSCACHE_OP_ASYNC:
56372 _debug("queue async");
56373 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56374 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56375 if (op->processor)
56376 fscache_enqueue_operation(op);
56377 - fscache_stat(&fscache_n_op_run);
56378 + fscache_stat_unchecked(&fscache_n_op_run);
56379 }
56380
56381 /*
56382 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56383 if (object->n_in_progress > 0) {
56384 atomic_inc(&op->usage);
56385 list_add_tail(&op->pend_link, &object->pending_ops);
56386 - fscache_stat(&fscache_n_op_pend);
56387 + fscache_stat_unchecked(&fscache_n_op_pend);
56388 } else if (!list_empty(&object->pending_ops)) {
56389 atomic_inc(&op->usage);
56390 list_add_tail(&op->pend_link, &object->pending_ops);
56391 - fscache_stat(&fscache_n_op_pend);
56392 + fscache_stat_unchecked(&fscache_n_op_pend);
56393 fscache_start_operations(object);
56394 } else {
56395 ASSERTCMP(object->n_in_progress, ==, 0);
56396 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56397 object->n_exclusive++; /* reads and writes must wait */
56398 atomic_inc(&op->usage);
56399 list_add_tail(&op->pend_link, &object->pending_ops);
56400 - fscache_stat(&fscache_n_op_pend);
56401 + fscache_stat_unchecked(&fscache_n_op_pend);
56402 ret = 0;
56403 } else {
56404 /* If we're in any other state, there must have been an I/O
56405 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56406 if (object->n_exclusive > 0) {
56407 atomic_inc(&op->usage);
56408 list_add_tail(&op->pend_link, &object->pending_ops);
56409 - fscache_stat(&fscache_n_op_pend);
56410 + fscache_stat_unchecked(&fscache_n_op_pend);
56411 } else if (!list_empty(&object->pending_ops)) {
56412 atomic_inc(&op->usage);
56413 list_add_tail(&op->pend_link, &object->pending_ops);
56414 - fscache_stat(&fscache_n_op_pend);
56415 + fscache_stat_unchecked(&fscache_n_op_pend);
56416 fscache_start_operations(object);
56417 } else {
56418 ASSERTCMP(object->n_exclusive, ==, 0);
56419 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56420 object->n_ops++;
56421 atomic_inc(&op->usage);
56422 list_add_tail(&op->pend_link, &object->pending_ops);
56423 - fscache_stat(&fscache_n_op_pend);
56424 + fscache_stat_unchecked(&fscache_n_op_pend);
56425 ret = 0;
56426 } else if (fscache_object_is_dying(object)) {
56427 - fscache_stat(&fscache_n_op_rejected);
56428 + fscache_stat_unchecked(&fscache_n_op_rejected);
56429 op->state = FSCACHE_OP_ST_CANCELLED;
56430 ret = -ENOBUFS;
56431 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56432 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56433 ret = -EBUSY;
56434 if (op->state == FSCACHE_OP_ST_PENDING) {
56435 ASSERT(!list_empty(&op->pend_link));
56436 - fscache_stat(&fscache_n_op_cancelled);
56437 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56438 list_del_init(&op->pend_link);
56439 if (do_cancel)
56440 do_cancel(op);
56441 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56442 while (!list_empty(&object->pending_ops)) {
56443 op = list_entry(object->pending_ops.next,
56444 struct fscache_operation, pend_link);
56445 - fscache_stat(&fscache_n_op_cancelled);
56446 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56447 list_del_init(&op->pend_link);
56448
56449 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56450 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56451 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56452 op->state = FSCACHE_OP_ST_DEAD;
56453
56454 - fscache_stat(&fscache_n_op_release);
56455 + fscache_stat_unchecked(&fscache_n_op_release);
56456
56457 if (op->release) {
56458 op->release(op);
56459 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56460 * lock, and defer it otherwise */
56461 if (!spin_trylock(&object->lock)) {
56462 _debug("defer put");
56463 - fscache_stat(&fscache_n_op_deferred_release);
56464 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56465
56466 cache = object->cache;
56467 spin_lock(&cache->op_gc_list_lock);
56468 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56469
56470 _debug("GC DEFERRED REL OBJ%x OP%x",
56471 object->debug_id, op->debug_id);
56472 - fscache_stat(&fscache_n_op_gc);
56473 + fscache_stat_unchecked(&fscache_n_op_gc);
56474
56475 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56476 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56477 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56478 index d479ab3..727a7f2 100644
56479 --- a/fs/fscache/page.c
56480 +++ b/fs/fscache/page.c
56481 @@ -61,7 +61,7 @@ try_again:
56482 val = radix_tree_lookup(&cookie->stores, page->index);
56483 if (!val) {
56484 rcu_read_unlock();
56485 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56486 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56487 __fscache_uncache_page(cookie, page);
56488 return true;
56489 }
56490 @@ -91,11 +91,11 @@ try_again:
56491 spin_unlock(&cookie->stores_lock);
56492
56493 if (xpage) {
56494 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56495 - fscache_stat(&fscache_n_store_radix_deletes);
56496 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56497 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56498 ASSERTCMP(xpage, ==, page);
56499 } else {
56500 - fscache_stat(&fscache_n_store_vmscan_gone);
56501 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56502 }
56503
56504 wake_up_bit(&cookie->flags, 0);
56505 @@ -110,11 +110,11 @@ page_busy:
56506 * sleeping on memory allocation, so we may need to impose a timeout
56507 * too. */
56508 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56509 - fscache_stat(&fscache_n_store_vmscan_busy);
56510 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56511 return false;
56512 }
56513
56514 - fscache_stat(&fscache_n_store_vmscan_wait);
56515 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56516 __fscache_wait_on_page_write(cookie, page);
56517 gfp &= ~__GFP_WAIT;
56518 goto try_again;
56519 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56520 FSCACHE_COOKIE_STORING_TAG);
56521 if (!radix_tree_tag_get(&cookie->stores, page->index,
56522 FSCACHE_COOKIE_PENDING_TAG)) {
56523 - fscache_stat(&fscache_n_store_radix_deletes);
56524 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56525 xpage = radix_tree_delete(&cookie->stores, page->index);
56526 }
56527 spin_unlock(&cookie->stores_lock);
56528 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56529
56530 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56531
56532 - fscache_stat(&fscache_n_attr_changed_calls);
56533 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56534
56535 if (fscache_object_is_active(object) &&
56536 fscache_use_cookie(object)) {
56537 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56538
56539 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56540
56541 - fscache_stat(&fscache_n_attr_changed);
56542 + fscache_stat_unchecked(&fscache_n_attr_changed);
56543
56544 op = kzalloc(sizeof(*op), GFP_KERNEL);
56545 if (!op) {
56546 - fscache_stat(&fscache_n_attr_changed_nomem);
56547 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56548 _leave(" = -ENOMEM");
56549 return -ENOMEM;
56550 }
56551 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56552 if (fscache_submit_exclusive_op(object, op) < 0)
56553 goto nobufs;
56554 spin_unlock(&cookie->lock);
56555 - fscache_stat(&fscache_n_attr_changed_ok);
56556 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56557 fscache_put_operation(op);
56558 _leave(" = 0");
56559 return 0;
56560 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56561 nobufs:
56562 spin_unlock(&cookie->lock);
56563 kfree(op);
56564 - fscache_stat(&fscache_n_attr_changed_nobufs);
56565 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56566 _leave(" = %d", -ENOBUFS);
56567 return -ENOBUFS;
56568 }
56569 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56570 /* allocate a retrieval operation and attempt to submit it */
56571 op = kzalloc(sizeof(*op), GFP_NOIO);
56572 if (!op) {
56573 - fscache_stat(&fscache_n_retrievals_nomem);
56574 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56575 return NULL;
56576 }
56577
56578 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56579 return 0;
56580 }
56581
56582 - fscache_stat(&fscache_n_retrievals_wait);
56583 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56584
56585 jif = jiffies;
56586 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56587 fscache_wait_bit_interruptible,
56588 TASK_INTERRUPTIBLE) != 0) {
56589 - fscache_stat(&fscache_n_retrievals_intr);
56590 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56591 _leave(" = -ERESTARTSYS");
56592 return -ERESTARTSYS;
56593 }
56594 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56595 */
56596 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56597 struct fscache_retrieval *op,
56598 - atomic_t *stat_op_waits,
56599 - atomic_t *stat_object_dead)
56600 + atomic_unchecked_t *stat_op_waits,
56601 + atomic_unchecked_t *stat_object_dead)
56602 {
56603 int ret;
56604
56605 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56606 goto check_if_dead;
56607
56608 _debug(">>> WT");
56609 - fscache_stat(stat_op_waits);
56610 + fscache_stat_unchecked(stat_op_waits);
56611 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56612 fscache_wait_bit_interruptible,
56613 TASK_INTERRUPTIBLE) != 0) {
56614 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56615
56616 check_if_dead:
56617 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56618 - fscache_stat(stat_object_dead);
56619 + fscache_stat_unchecked(stat_object_dead);
56620 _leave(" = -ENOBUFS [cancelled]");
56621 return -ENOBUFS;
56622 }
56623 if (unlikely(fscache_object_is_dead(object))) {
56624 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56625 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56626 - fscache_stat(stat_object_dead);
56627 + fscache_stat_unchecked(stat_object_dead);
56628 return -ENOBUFS;
56629 }
56630 return 0;
56631 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56632
56633 _enter("%p,%p,,,", cookie, page);
56634
56635 - fscache_stat(&fscache_n_retrievals);
56636 + fscache_stat_unchecked(&fscache_n_retrievals);
56637
56638 if (hlist_empty(&cookie->backing_objects))
56639 goto nobufs;
56640 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56641 goto nobufs_unlock_dec;
56642 spin_unlock(&cookie->lock);
56643
56644 - fscache_stat(&fscache_n_retrieval_ops);
56645 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56646
56647 /* pin the netfs read context in case we need to do the actual netfs
56648 * read because we've encountered a cache read failure */
56649 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56650
56651 error:
56652 if (ret == -ENOMEM)
56653 - fscache_stat(&fscache_n_retrievals_nomem);
56654 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56655 else if (ret == -ERESTARTSYS)
56656 - fscache_stat(&fscache_n_retrievals_intr);
56657 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56658 else if (ret == -ENODATA)
56659 - fscache_stat(&fscache_n_retrievals_nodata);
56660 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56661 else if (ret < 0)
56662 - fscache_stat(&fscache_n_retrievals_nobufs);
56663 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56664 else
56665 - fscache_stat(&fscache_n_retrievals_ok);
56666 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56667
56668 fscache_put_retrieval(op);
56669 _leave(" = %d", ret);
56670 @@ -475,7 +475,7 @@ nobufs_unlock:
56671 atomic_dec(&cookie->n_active);
56672 kfree(op);
56673 nobufs:
56674 - fscache_stat(&fscache_n_retrievals_nobufs);
56675 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56676 _leave(" = -ENOBUFS");
56677 return -ENOBUFS;
56678 }
56679 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56680
56681 _enter("%p,,%d,,,", cookie, *nr_pages);
56682
56683 - fscache_stat(&fscache_n_retrievals);
56684 + fscache_stat_unchecked(&fscache_n_retrievals);
56685
56686 if (hlist_empty(&cookie->backing_objects))
56687 goto nobufs;
56688 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56689 goto nobufs_unlock_dec;
56690 spin_unlock(&cookie->lock);
56691
56692 - fscache_stat(&fscache_n_retrieval_ops);
56693 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56694
56695 /* pin the netfs read context in case we need to do the actual netfs
56696 * read because we've encountered a cache read failure */
56697 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56698
56699 error:
56700 if (ret == -ENOMEM)
56701 - fscache_stat(&fscache_n_retrievals_nomem);
56702 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56703 else if (ret == -ERESTARTSYS)
56704 - fscache_stat(&fscache_n_retrievals_intr);
56705 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56706 else if (ret == -ENODATA)
56707 - fscache_stat(&fscache_n_retrievals_nodata);
56708 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56709 else if (ret < 0)
56710 - fscache_stat(&fscache_n_retrievals_nobufs);
56711 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56712 else
56713 - fscache_stat(&fscache_n_retrievals_ok);
56714 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56715
56716 fscache_put_retrieval(op);
56717 _leave(" = %d", ret);
56718 @@ -600,7 +600,7 @@ nobufs_unlock:
56719 atomic_dec(&cookie->n_active);
56720 kfree(op);
56721 nobufs:
56722 - fscache_stat(&fscache_n_retrievals_nobufs);
56723 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56724 _leave(" = -ENOBUFS");
56725 return -ENOBUFS;
56726 }
56727 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56728
56729 _enter("%p,%p,,,", cookie, page);
56730
56731 - fscache_stat(&fscache_n_allocs);
56732 + fscache_stat_unchecked(&fscache_n_allocs);
56733
56734 if (hlist_empty(&cookie->backing_objects))
56735 goto nobufs;
56736 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56737 goto nobufs_unlock;
56738 spin_unlock(&cookie->lock);
56739
56740 - fscache_stat(&fscache_n_alloc_ops);
56741 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56742
56743 ret = fscache_wait_for_retrieval_activation(
56744 object, op,
56745 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56746
56747 error:
56748 if (ret == -ERESTARTSYS)
56749 - fscache_stat(&fscache_n_allocs_intr);
56750 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56751 else if (ret < 0)
56752 - fscache_stat(&fscache_n_allocs_nobufs);
56753 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56754 else
56755 - fscache_stat(&fscache_n_allocs_ok);
56756 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56757
56758 fscache_put_retrieval(op);
56759 _leave(" = %d", ret);
56760 @@ -687,7 +687,7 @@ nobufs_unlock:
56761 atomic_dec(&cookie->n_active);
56762 kfree(op);
56763 nobufs:
56764 - fscache_stat(&fscache_n_allocs_nobufs);
56765 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56766 _leave(" = -ENOBUFS");
56767 return -ENOBUFS;
56768 }
56769 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56770
56771 spin_lock(&cookie->stores_lock);
56772
56773 - fscache_stat(&fscache_n_store_calls);
56774 + fscache_stat_unchecked(&fscache_n_store_calls);
56775
56776 /* find a page to store */
56777 page = NULL;
56778 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56779 page = results[0];
56780 _debug("gang %d [%lx]", n, page->index);
56781 if (page->index > op->store_limit) {
56782 - fscache_stat(&fscache_n_store_pages_over_limit);
56783 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56784 goto superseded;
56785 }
56786
56787 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56788 spin_unlock(&cookie->stores_lock);
56789 spin_unlock(&object->lock);
56790
56791 - fscache_stat(&fscache_n_store_pages);
56792 + fscache_stat_unchecked(&fscache_n_store_pages);
56793 fscache_stat(&fscache_n_cop_write_page);
56794 ret = object->cache->ops->write_page(op, page);
56795 fscache_stat_d(&fscache_n_cop_write_page);
56796 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56797 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56798 ASSERT(PageFsCache(page));
56799
56800 - fscache_stat(&fscache_n_stores);
56801 + fscache_stat_unchecked(&fscache_n_stores);
56802
56803 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56804 _leave(" = -ENOBUFS [invalidating]");
56805 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56806 spin_unlock(&cookie->stores_lock);
56807 spin_unlock(&object->lock);
56808
56809 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56810 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56811 op->store_limit = object->store_limit;
56812
56813 atomic_inc(&cookie->n_active);
56814 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56815
56816 spin_unlock(&cookie->lock);
56817 radix_tree_preload_end();
56818 - fscache_stat(&fscache_n_store_ops);
56819 - fscache_stat(&fscache_n_stores_ok);
56820 + fscache_stat_unchecked(&fscache_n_store_ops);
56821 + fscache_stat_unchecked(&fscache_n_stores_ok);
56822
56823 /* the work queue now carries its own ref on the object */
56824 fscache_put_operation(&op->op);
56825 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56826 return 0;
56827
56828 already_queued:
56829 - fscache_stat(&fscache_n_stores_again);
56830 + fscache_stat_unchecked(&fscache_n_stores_again);
56831 already_pending:
56832 spin_unlock(&cookie->stores_lock);
56833 spin_unlock(&object->lock);
56834 spin_unlock(&cookie->lock);
56835 radix_tree_preload_end();
56836 kfree(op);
56837 - fscache_stat(&fscache_n_stores_ok);
56838 + fscache_stat_unchecked(&fscache_n_stores_ok);
56839 _leave(" = 0");
56840 return 0;
56841
56842 @@ -976,14 +976,14 @@ nobufs:
56843 spin_unlock(&cookie->lock);
56844 radix_tree_preload_end();
56845 kfree(op);
56846 - fscache_stat(&fscache_n_stores_nobufs);
56847 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56848 _leave(" = -ENOBUFS");
56849 return -ENOBUFS;
56850
56851 nomem_free:
56852 kfree(op);
56853 nomem:
56854 - fscache_stat(&fscache_n_stores_oom);
56855 + fscache_stat_unchecked(&fscache_n_stores_oom);
56856 _leave(" = -ENOMEM");
56857 return -ENOMEM;
56858 }
56859 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56860 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56861 ASSERTCMP(page, !=, NULL);
56862
56863 - fscache_stat(&fscache_n_uncaches);
56864 + fscache_stat_unchecked(&fscache_n_uncaches);
56865
56866 /* cache withdrawal may beat us to it */
56867 if (!PageFsCache(page))
56868 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56869 struct fscache_cookie *cookie = op->op.object->cookie;
56870
56871 #ifdef CONFIG_FSCACHE_STATS
56872 - atomic_inc(&fscache_n_marks);
56873 + atomic_inc_unchecked(&fscache_n_marks);
56874 #endif
56875
56876 _debug("- mark %p{%lx}", page, page->index);
56877 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56878 index 40d13c7..ddf52b9 100644
56879 --- a/fs/fscache/stats.c
56880 +++ b/fs/fscache/stats.c
56881 @@ -18,99 +18,99 @@
56882 /*
56883 * operation counters
56884 */
56885 -atomic_t fscache_n_op_pend;
56886 -atomic_t fscache_n_op_run;
56887 -atomic_t fscache_n_op_enqueue;
56888 -atomic_t fscache_n_op_requeue;
56889 -atomic_t fscache_n_op_deferred_release;
56890 -atomic_t fscache_n_op_release;
56891 -atomic_t fscache_n_op_gc;
56892 -atomic_t fscache_n_op_cancelled;
56893 -atomic_t fscache_n_op_rejected;
56894 +atomic_unchecked_t fscache_n_op_pend;
56895 +atomic_unchecked_t fscache_n_op_run;
56896 +atomic_unchecked_t fscache_n_op_enqueue;
56897 +atomic_unchecked_t fscache_n_op_requeue;
56898 +atomic_unchecked_t fscache_n_op_deferred_release;
56899 +atomic_unchecked_t fscache_n_op_release;
56900 +atomic_unchecked_t fscache_n_op_gc;
56901 +atomic_unchecked_t fscache_n_op_cancelled;
56902 +atomic_unchecked_t fscache_n_op_rejected;
56903
56904 -atomic_t fscache_n_attr_changed;
56905 -atomic_t fscache_n_attr_changed_ok;
56906 -atomic_t fscache_n_attr_changed_nobufs;
56907 -atomic_t fscache_n_attr_changed_nomem;
56908 -atomic_t fscache_n_attr_changed_calls;
56909 +atomic_unchecked_t fscache_n_attr_changed;
56910 +atomic_unchecked_t fscache_n_attr_changed_ok;
56911 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56912 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56913 +atomic_unchecked_t fscache_n_attr_changed_calls;
56914
56915 -atomic_t fscache_n_allocs;
56916 -atomic_t fscache_n_allocs_ok;
56917 -atomic_t fscache_n_allocs_wait;
56918 -atomic_t fscache_n_allocs_nobufs;
56919 -atomic_t fscache_n_allocs_intr;
56920 -atomic_t fscache_n_allocs_object_dead;
56921 -atomic_t fscache_n_alloc_ops;
56922 -atomic_t fscache_n_alloc_op_waits;
56923 +atomic_unchecked_t fscache_n_allocs;
56924 +atomic_unchecked_t fscache_n_allocs_ok;
56925 +atomic_unchecked_t fscache_n_allocs_wait;
56926 +atomic_unchecked_t fscache_n_allocs_nobufs;
56927 +atomic_unchecked_t fscache_n_allocs_intr;
56928 +atomic_unchecked_t fscache_n_allocs_object_dead;
56929 +atomic_unchecked_t fscache_n_alloc_ops;
56930 +atomic_unchecked_t fscache_n_alloc_op_waits;
56931
56932 -atomic_t fscache_n_retrievals;
56933 -atomic_t fscache_n_retrievals_ok;
56934 -atomic_t fscache_n_retrievals_wait;
56935 -atomic_t fscache_n_retrievals_nodata;
56936 -atomic_t fscache_n_retrievals_nobufs;
56937 -atomic_t fscache_n_retrievals_intr;
56938 -atomic_t fscache_n_retrievals_nomem;
56939 -atomic_t fscache_n_retrievals_object_dead;
56940 -atomic_t fscache_n_retrieval_ops;
56941 -atomic_t fscache_n_retrieval_op_waits;
56942 +atomic_unchecked_t fscache_n_retrievals;
56943 +atomic_unchecked_t fscache_n_retrievals_ok;
56944 +atomic_unchecked_t fscache_n_retrievals_wait;
56945 +atomic_unchecked_t fscache_n_retrievals_nodata;
56946 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56947 +atomic_unchecked_t fscache_n_retrievals_intr;
56948 +atomic_unchecked_t fscache_n_retrievals_nomem;
56949 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56950 +atomic_unchecked_t fscache_n_retrieval_ops;
56951 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56952
56953 -atomic_t fscache_n_stores;
56954 -atomic_t fscache_n_stores_ok;
56955 -atomic_t fscache_n_stores_again;
56956 -atomic_t fscache_n_stores_nobufs;
56957 -atomic_t fscache_n_stores_oom;
56958 -atomic_t fscache_n_store_ops;
56959 -atomic_t fscache_n_store_calls;
56960 -atomic_t fscache_n_store_pages;
56961 -atomic_t fscache_n_store_radix_deletes;
56962 -atomic_t fscache_n_store_pages_over_limit;
56963 +atomic_unchecked_t fscache_n_stores;
56964 +atomic_unchecked_t fscache_n_stores_ok;
56965 +atomic_unchecked_t fscache_n_stores_again;
56966 +atomic_unchecked_t fscache_n_stores_nobufs;
56967 +atomic_unchecked_t fscache_n_stores_oom;
56968 +atomic_unchecked_t fscache_n_store_ops;
56969 +atomic_unchecked_t fscache_n_store_calls;
56970 +atomic_unchecked_t fscache_n_store_pages;
56971 +atomic_unchecked_t fscache_n_store_radix_deletes;
56972 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56973
56974 -atomic_t fscache_n_store_vmscan_not_storing;
56975 -atomic_t fscache_n_store_vmscan_gone;
56976 -atomic_t fscache_n_store_vmscan_busy;
56977 -atomic_t fscache_n_store_vmscan_cancelled;
56978 -atomic_t fscache_n_store_vmscan_wait;
56979 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56980 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56981 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56982 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56983 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56984
56985 -atomic_t fscache_n_marks;
56986 -atomic_t fscache_n_uncaches;
56987 +atomic_unchecked_t fscache_n_marks;
56988 +atomic_unchecked_t fscache_n_uncaches;
56989
56990 -atomic_t fscache_n_acquires;
56991 -atomic_t fscache_n_acquires_null;
56992 -atomic_t fscache_n_acquires_no_cache;
56993 -atomic_t fscache_n_acquires_ok;
56994 -atomic_t fscache_n_acquires_nobufs;
56995 -atomic_t fscache_n_acquires_oom;
56996 +atomic_unchecked_t fscache_n_acquires;
56997 +atomic_unchecked_t fscache_n_acquires_null;
56998 +atomic_unchecked_t fscache_n_acquires_no_cache;
56999 +atomic_unchecked_t fscache_n_acquires_ok;
57000 +atomic_unchecked_t fscache_n_acquires_nobufs;
57001 +atomic_unchecked_t fscache_n_acquires_oom;
57002
57003 -atomic_t fscache_n_invalidates;
57004 -atomic_t fscache_n_invalidates_run;
57005 +atomic_unchecked_t fscache_n_invalidates;
57006 +atomic_unchecked_t fscache_n_invalidates_run;
57007
57008 -atomic_t fscache_n_updates;
57009 -atomic_t fscache_n_updates_null;
57010 -atomic_t fscache_n_updates_run;
57011 +atomic_unchecked_t fscache_n_updates;
57012 +atomic_unchecked_t fscache_n_updates_null;
57013 +atomic_unchecked_t fscache_n_updates_run;
57014
57015 -atomic_t fscache_n_relinquishes;
57016 -atomic_t fscache_n_relinquishes_null;
57017 -atomic_t fscache_n_relinquishes_waitcrt;
57018 -atomic_t fscache_n_relinquishes_retire;
57019 +atomic_unchecked_t fscache_n_relinquishes;
57020 +atomic_unchecked_t fscache_n_relinquishes_null;
57021 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57022 +atomic_unchecked_t fscache_n_relinquishes_retire;
57023
57024 -atomic_t fscache_n_cookie_index;
57025 -atomic_t fscache_n_cookie_data;
57026 -atomic_t fscache_n_cookie_special;
57027 +atomic_unchecked_t fscache_n_cookie_index;
57028 +atomic_unchecked_t fscache_n_cookie_data;
57029 +atomic_unchecked_t fscache_n_cookie_special;
57030
57031 -atomic_t fscache_n_object_alloc;
57032 -atomic_t fscache_n_object_no_alloc;
57033 -atomic_t fscache_n_object_lookups;
57034 -atomic_t fscache_n_object_lookups_negative;
57035 -atomic_t fscache_n_object_lookups_positive;
57036 -atomic_t fscache_n_object_lookups_timed_out;
57037 -atomic_t fscache_n_object_created;
57038 -atomic_t fscache_n_object_avail;
57039 -atomic_t fscache_n_object_dead;
57040 +atomic_unchecked_t fscache_n_object_alloc;
57041 +atomic_unchecked_t fscache_n_object_no_alloc;
57042 +atomic_unchecked_t fscache_n_object_lookups;
57043 +atomic_unchecked_t fscache_n_object_lookups_negative;
57044 +atomic_unchecked_t fscache_n_object_lookups_positive;
57045 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57046 +atomic_unchecked_t fscache_n_object_created;
57047 +atomic_unchecked_t fscache_n_object_avail;
57048 +atomic_unchecked_t fscache_n_object_dead;
57049
57050 -atomic_t fscache_n_checkaux_none;
57051 -atomic_t fscache_n_checkaux_okay;
57052 -atomic_t fscache_n_checkaux_update;
57053 -atomic_t fscache_n_checkaux_obsolete;
57054 +atomic_unchecked_t fscache_n_checkaux_none;
57055 +atomic_unchecked_t fscache_n_checkaux_okay;
57056 +atomic_unchecked_t fscache_n_checkaux_update;
57057 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57058
57059 atomic_t fscache_n_cop_alloc_object;
57060 atomic_t fscache_n_cop_lookup_object;
57061 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57062 seq_puts(m, "FS-Cache statistics\n");
57063
57064 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57065 - atomic_read(&fscache_n_cookie_index),
57066 - atomic_read(&fscache_n_cookie_data),
57067 - atomic_read(&fscache_n_cookie_special));
57068 + atomic_read_unchecked(&fscache_n_cookie_index),
57069 + atomic_read_unchecked(&fscache_n_cookie_data),
57070 + atomic_read_unchecked(&fscache_n_cookie_special));
57071
57072 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57073 - atomic_read(&fscache_n_object_alloc),
57074 - atomic_read(&fscache_n_object_no_alloc),
57075 - atomic_read(&fscache_n_object_avail),
57076 - atomic_read(&fscache_n_object_dead));
57077 + atomic_read_unchecked(&fscache_n_object_alloc),
57078 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57079 + atomic_read_unchecked(&fscache_n_object_avail),
57080 + atomic_read_unchecked(&fscache_n_object_dead));
57081 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57082 - atomic_read(&fscache_n_checkaux_none),
57083 - atomic_read(&fscache_n_checkaux_okay),
57084 - atomic_read(&fscache_n_checkaux_update),
57085 - atomic_read(&fscache_n_checkaux_obsolete));
57086 + atomic_read_unchecked(&fscache_n_checkaux_none),
57087 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57088 + atomic_read_unchecked(&fscache_n_checkaux_update),
57089 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57090
57091 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57092 - atomic_read(&fscache_n_marks),
57093 - atomic_read(&fscache_n_uncaches));
57094 + atomic_read_unchecked(&fscache_n_marks),
57095 + atomic_read_unchecked(&fscache_n_uncaches));
57096
57097 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57098 " oom=%u\n",
57099 - atomic_read(&fscache_n_acquires),
57100 - atomic_read(&fscache_n_acquires_null),
57101 - atomic_read(&fscache_n_acquires_no_cache),
57102 - atomic_read(&fscache_n_acquires_ok),
57103 - atomic_read(&fscache_n_acquires_nobufs),
57104 - atomic_read(&fscache_n_acquires_oom));
57105 + atomic_read_unchecked(&fscache_n_acquires),
57106 + atomic_read_unchecked(&fscache_n_acquires_null),
57107 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57108 + atomic_read_unchecked(&fscache_n_acquires_ok),
57109 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57110 + atomic_read_unchecked(&fscache_n_acquires_oom));
57111
57112 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57113 - atomic_read(&fscache_n_object_lookups),
57114 - atomic_read(&fscache_n_object_lookups_negative),
57115 - atomic_read(&fscache_n_object_lookups_positive),
57116 - atomic_read(&fscache_n_object_created),
57117 - atomic_read(&fscache_n_object_lookups_timed_out));
57118 + atomic_read_unchecked(&fscache_n_object_lookups),
57119 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57120 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57121 + atomic_read_unchecked(&fscache_n_object_created),
57122 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57123
57124 seq_printf(m, "Invals : n=%u run=%u\n",
57125 - atomic_read(&fscache_n_invalidates),
57126 - atomic_read(&fscache_n_invalidates_run));
57127 + atomic_read_unchecked(&fscache_n_invalidates),
57128 + atomic_read_unchecked(&fscache_n_invalidates_run));
57129
57130 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57131 - atomic_read(&fscache_n_updates),
57132 - atomic_read(&fscache_n_updates_null),
57133 - atomic_read(&fscache_n_updates_run));
57134 + atomic_read_unchecked(&fscache_n_updates),
57135 + atomic_read_unchecked(&fscache_n_updates_null),
57136 + atomic_read_unchecked(&fscache_n_updates_run));
57137
57138 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57139 - atomic_read(&fscache_n_relinquishes),
57140 - atomic_read(&fscache_n_relinquishes_null),
57141 - atomic_read(&fscache_n_relinquishes_waitcrt),
57142 - atomic_read(&fscache_n_relinquishes_retire));
57143 + atomic_read_unchecked(&fscache_n_relinquishes),
57144 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57145 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57146 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57147
57148 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57149 - atomic_read(&fscache_n_attr_changed),
57150 - atomic_read(&fscache_n_attr_changed_ok),
57151 - atomic_read(&fscache_n_attr_changed_nobufs),
57152 - atomic_read(&fscache_n_attr_changed_nomem),
57153 - atomic_read(&fscache_n_attr_changed_calls));
57154 + atomic_read_unchecked(&fscache_n_attr_changed),
57155 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57156 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57157 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57158 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57159
57160 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57161 - atomic_read(&fscache_n_allocs),
57162 - atomic_read(&fscache_n_allocs_ok),
57163 - atomic_read(&fscache_n_allocs_wait),
57164 - atomic_read(&fscache_n_allocs_nobufs),
57165 - atomic_read(&fscache_n_allocs_intr));
57166 + atomic_read_unchecked(&fscache_n_allocs),
57167 + atomic_read_unchecked(&fscache_n_allocs_ok),
57168 + atomic_read_unchecked(&fscache_n_allocs_wait),
57169 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57170 + atomic_read_unchecked(&fscache_n_allocs_intr));
57171 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57172 - atomic_read(&fscache_n_alloc_ops),
57173 - atomic_read(&fscache_n_alloc_op_waits),
57174 - atomic_read(&fscache_n_allocs_object_dead));
57175 + atomic_read_unchecked(&fscache_n_alloc_ops),
57176 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57177 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57178
57179 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57180 " int=%u oom=%u\n",
57181 - atomic_read(&fscache_n_retrievals),
57182 - atomic_read(&fscache_n_retrievals_ok),
57183 - atomic_read(&fscache_n_retrievals_wait),
57184 - atomic_read(&fscache_n_retrievals_nodata),
57185 - atomic_read(&fscache_n_retrievals_nobufs),
57186 - atomic_read(&fscache_n_retrievals_intr),
57187 - atomic_read(&fscache_n_retrievals_nomem));
57188 + atomic_read_unchecked(&fscache_n_retrievals),
57189 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57190 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57191 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57192 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57193 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57194 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57195 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57196 - atomic_read(&fscache_n_retrieval_ops),
57197 - atomic_read(&fscache_n_retrieval_op_waits),
57198 - atomic_read(&fscache_n_retrievals_object_dead));
57199 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57200 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57201 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57202
57203 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57204 - atomic_read(&fscache_n_stores),
57205 - atomic_read(&fscache_n_stores_ok),
57206 - atomic_read(&fscache_n_stores_again),
57207 - atomic_read(&fscache_n_stores_nobufs),
57208 - atomic_read(&fscache_n_stores_oom));
57209 + atomic_read_unchecked(&fscache_n_stores),
57210 + atomic_read_unchecked(&fscache_n_stores_ok),
57211 + atomic_read_unchecked(&fscache_n_stores_again),
57212 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57213 + atomic_read_unchecked(&fscache_n_stores_oom));
57214 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57215 - atomic_read(&fscache_n_store_ops),
57216 - atomic_read(&fscache_n_store_calls),
57217 - atomic_read(&fscache_n_store_pages),
57218 - atomic_read(&fscache_n_store_radix_deletes),
57219 - atomic_read(&fscache_n_store_pages_over_limit));
57220 + atomic_read_unchecked(&fscache_n_store_ops),
57221 + atomic_read_unchecked(&fscache_n_store_calls),
57222 + atomic_read_unchecked(&fscache_n_store_pages),
57223 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57224 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57225
57226 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57227 - atomic_read(&fscache_n_store_vmscan_not_storing),
57228 - atomic_read(&fscache_n_store_vmscan_gone),
57229 - atomic_read(&fscache_n_store_vmscan_busy),
57230 - atomic_read(&fscache_n_store_vmscan_cancelled),
57231 - atomic_read(&fscache_n_store_vmscan_wait));
57232 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57233 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57234 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57235 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57236 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57237
57238 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57239 - atomic_read(&fscache_n_op_pend),
57240 - atomic_read(&fscache_n_op_run),
57241 - atomic_read(&fscache_n_op_enqueue),
57242 - atomic_read(&fscache_n_op_cancelled),
57243 - atomic_read(&fscache_n_op_rejected));
57244 + atomic_read_unchecked(&fscache_n_op_pend),
57245 + atomic_read_unchecked(&fscache_n_op_run),
57246 + atomic_read_unchecked(&fscache_n_op_enqueue),
57247 + atomic_read_unchecked(&fscache_n_op_cancelled),
57248 + atomic_read_unchecked(&fscache_n_op_rejected));
57249 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57250 - atomic_read(&fscache_n_op_deferred_release),
57251 - atomic_read(&fscache_n_op_release),
57252 - atomic_read(&fscache_n_op_gc));
57253 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57254 + atomic_read_unchecked(&fscache_n_op_release),
57255 + atomic_read_unchecked(&fscache_n_op_gc));
57256
57257 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57258 atomic_read(&fscache_n_cop_alloc_object),
57259 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57260 index aef34b1..59bfd7b 100644
57261 --- a/fs/fuse/cuse.c
57262 +++ b/fs/fuse/cuse.c
57263 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57264 INIT_LIST_HEAD(&cuse_conntbl[i]);
57265
57266 /* inherit and extend fuse_dev_operations */
57267 - cuse_channel_fops = fuse_dev_operations;
57268 - cuse_channel_fops.owner = THIS_MODULE;
57269 - cuse_channel_fops.open = cuse_channel_open;
57270 - cuse_channel_fops.release = cuse_channel_release;
57271 + pax_open_kernel();
57272 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57273 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57274 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57275 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57276 + pax_close_kernel();
57277
57278 cuse_class = class_create(THIS_MODULE, "cuse");
57279 if (IS_ERR(cuse_class))
57280 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57281 index 1d55f94..088da65 100644
57282 --- a/fs/fuse/dev.c
57283 +++ b/fs/fuse/dev.c
57284 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57285 ret = 0;
57286 pipe_lock(pipe);
57287
57288 - if (!pipe->readers) {
57289 + if (!atomic_read(&pipe->readers)) {
57290 send_sig(SIGPIPE, current, 0);
57291 if (!ret)
57292 ret = -EPIPE;
57293 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57294 page_nr++;
57295 ret += buf->len;
57296
57297 - if (pipe->files)
57298 + if (atomic_read(&pipe->files))
57299 do_wakeup = 1;
57300 }
57301
57302 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57303 index 8fec28f..cd40dba 100644
57304 --- a/fs/fuse/dir.c
57305 +++ b/fs/fuse/dir.c
57306 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57307 return link;
57308 }
57309
57310 -static void free_link(char *link)
57311 +static void free_link(const char *link)
57312 {
57313 if (!IS_ERR(link))
57314 free_page((unsigned long) link);
57315 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57316 index 64915ee..6bed500 100644
57317 --- a/fs/gfs2/inode.c
57318 +++ b/fs/gfs2/inode.c
57319 @@ -1506,7 +1506,7 @@ out:
57320
57321 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57322 {
57323 - char *s = nd_get_link(nd);
57324 + const char *s = nd_get_link(nd);
57325 if (!IS_ERR(s))
57326 kfree(s);
57327 }
57328 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57329 index d19b30a..ef89c36 100644
57330 --- a/fs/hugetlbfs/inode.c
57331 +++ b/fs/hugetlbfs/inode.c
57332 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57333 struct mm_struct *mm = current->mm;
57334 struct vm_area_struct *vma;
57335 struct hstate *h = hstate_file(file);
57336 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57337 struct vm_unmapped_area_info info;
57338
57339 if (len & ~huge_page_mask(h))
57340 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57341 return addr;
57342 }
57343
57344 +#ifdef CONFIG_PAX_RANDMMAP
57345 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57346 +#endif
57347 +
57348 if (addr) {
57349 addr = ALIGN(addr, huge_page_size(h));
57350 vma = find_vma(mm, addr);
57351 - if (TASK_SIZE - len >= addr &&
57352 - (!vma || addr + len <= vma->vm_start))
57353 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57354 return addr;
57355 }
57356
57357 info.flags = 0;
57358 info.length = len;
57359 info.low_limit = TASK_UNMAPPED_BASE;
57360 +
57361 +#ifdef CONFIG_PAX_RANDMMAP
57362 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57363 + info.low_limit += mm->delta_mmap;
57364 +#endif
57365 +
57366 info.high_limit = TASK_SIZE;
57367 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57368 info.align_offset = 0;
57369 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57370 };
57371 MODULE_ALIAS_FS("hugetlbfs");
57372
57373 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57374 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57375
57376 static int can_do_hugetlb_shm(void)
57377 {
57378 diff --git a/fs/inode.c b/fs/inode.c
57379 index d6dfb09..602e77e 100644
57380 --- a/fs/inode.c
57381 +++ b/fs/inode.c
57382 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57383
57384 #ifdef CONFIG_SMP
57385 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57386 - static atomic_t shared_last_ino;
57387 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57388 + static atomic_unchecked_t shared_last_ino;
57389 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57390
57391 res = next - LAST_INO_BATCH;
57392 }
57393 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57394 index 4a6cf28..d3a29d3 100644
57395 --- a/fs/jffs2/erase.c
57396 +++ b/fs/jffs2/erase.c
57397 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57398 struct jffs2_unknown_node marker = {
57399 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57400 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57401 - .totlen = cpu_to_je32(c->cleanmarker_size)
57402 + .totlen = cpu_to_je32(c->cleanmarker_size),
57403 + .hdr_crc = cpu_to_je32(0)
57404 };
57405
57406 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57407 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57408 index a6597d6..41b30ec 100644
57409 --- a/fs/jffs2/wbuf.c
57410 +++ b/fs/jffs2/wbuf.c
57411 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57412 {
57413 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57414 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57415 - .totlen = constant_cpu_to_je32(8)
57416 + .totlen = constant_cpu_to_je32(8),
57417 + .hdr_crc = constant_cpu_to_je32(0)
57418 };
57419
57420 /*
57421 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57422 index 6669aa2..36b033d 100644
57423 --- a/fs/jfs/super.c
57424 +++ b/fs/jfs/super.c
57425 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57426
57427 jfs_inode_cachep =
57428 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57429 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57430 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57431 init_once);
57432 if (jfs_inode_cachep == NULL)
57433 return -ENOMEM;
57434 diff --git a/fs/libfs.c b/fs/libfs.c
57435 index 3a3a9b5..3a9b074 100644
57436 --- a/fs/libfs.c
57437 +++ b/fs/libfs.c
57438 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57439
57440 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57441 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57442 + char d_name[sizeof(next->d_iname)];
57443 + const unsigned char *name;
57444 +
57445 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57446 if (!simple_positive(next)) {
57447 spin_unlock(&next->d_lock);
57448 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57449
57450 spin_unlock(&next->d_lock);
57451 spin_unlock(&dentry->d_lock);
57452 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57453 + name = next->d_name.name;
57454 + if (name == next->d_iname) {
57455 + memcpy(d_name, name, next->d_name.len);
57456 + name = d_name;
57457 + }
57458 + if (!dir_emit(ctx, name, next->d_name.len,
57459 next->d_inode->i_ino, dt_type(next->d_inode)))
57460 return 0;
57461 spin_lock(&dentry->d_lock);
57462 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57463 index acd3947..1f896e2 100644
57464 --- a/fs/lockd/clntproc.c
57465 +++ b/fs/lockd/clntproc.c
57466 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57467 /*
57468 * Cookie counter for NLM requests
57469 */
57470 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57471 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57472
57473 void nlmclnt_next_cookie(struct nlm_cookie *c)
57474 {
57475 - u32 cookie = atomic_inc_return(&nlm_cookie);
57476 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57477
57478 memcpy(c->data, &cookie, 4);
57479 c->len=4;
57480 diff --git a/fs/locks.c b/fs/locks.c
57481 index b27a300..4156d0b 100644
57482 --- a/fs/locks.c
57483 +++ b/fs/locks.c
57484 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57485 return;
57486
57487 if (filp->f_op && filp->f_op->flock) {
57488 - struct file_lock fl = {
57489 + struct file_lock flock = {
57490 .fl_pid = current->tgid,
57491 .fl_file = filp,
57492 .fl_flags = FL_FLOCK,
57493 .fl_type = F_UNLCK,
57494 .fl_end = OFFSET_MAX,
57495 };
57496 - filp->f_op->flock(filp, F_SETLKW, &fl);
57497 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57498 - fl.fl_ops->fl_release_private(&fl);
57499 + filp->f_op->flock(filp, F_SETLKW, &flock);
57500 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57501 + flock.fl_ops->fl_release_private(&flock);
57502 }
57503
57504 spin_lock(&inode->i_lock);
57505 diff --git a/fs/namei.c b/fs/namei.c
57506 index 7720fbd..7934bb2 100644
57507 --- a/fs/namei.c
57508 +++ b/fs/namei.c
57509 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57510 if (ret != -EACCES)
57511 return ret;
57512
57513 +#ifdef CONFIG_GRKERNSEC
57514 + /* we'll block if we have to log due to a denied capability use */
57515 + if (mask & MAY_NOT_BLOCK)
57516 + return -ECHILD;
57517 +#endif
57518 +
57519 if (S_ISDIR(inode->i_mode)) {
57520 /* DACs are overridable for directories */
57521 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57522 - return 0;
57523 if (!(mask & MAY_WRITE))
57524 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57525 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57526 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57527 return 0;
57528 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57529 + return 0;
57530 return -EACCES;
57531 }
57532 /*
57533 + * Searching includes executable on directories, else just read.
57534 + */
57535 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57536 + if (mask == MAY_READ)
57537 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57538 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57539 + return 0;
57540 +
57541 + /*
57542 * Read/write DACs are always overridable.
57543 * Executable DACs are overridable when there is
57544 * at least one exec bit set.
57545 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57546 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57547 return 0;
57548
57549 - /*
57550 - * Searching includes executable on directories, else just read.
57551 - */
57552 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57553 - if (mask == MAY_READ)
57554 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57555 - return 0;
57556 -
57557 return -EACCES;
57558 }
57559
57560 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57561 {
57562 struct dentry *dentry = link->dentry;
57563 int error;
57564 - char *s;
57565 + const char *s;
57566
57567 BUG_ON(nd->flags & LOOKUP_RCU);
57568
57569 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57570 if (error)
57571 goto out_put_nd_path;
57572
57573 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57574 + dentry->d_inode, dentry, nd->path.mnt)) {
57575 + error = -EACCES;
57576 + goto out_put_nd_path;
57577 + }
57578 +
57579 nd->last_type = LAST_BIND;
57580 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57581 error = PTR_ERR(*p);
57582 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57583 if (res)
57584 break;
57585 res = walk_component(nd, path, LOOKUP_FOLLOW);
57586 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57587 + res = -EACCES;
57588 put_link(nd, &link, cookie);
57589 } while (res > 0);
57590
57591 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57592 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57593 {
57594 unsigned long a, b, adata, bdata, mask, hash, len;
57595 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57596 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57597
57598 hash = a = 0;
57599 len = -sizeof(unsigned long);
57600 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57601 if (err)
57602 break;
57603 err = lookup_last(nd, &path);
57604 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57605 + err = -EACCES;
57606 put_link(nd, &link, cookie);
57607 }
57608 }
57609 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57610 if (!err)
57611 err = complete_walk(nd);
57612
57613 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57614 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57615 + path_put(&nd->path);
57616 + err = -ENOENT;
57617 + }
57618 + }
57619 +
57620 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57621 if (!can_lookup(nd->inode)) {
57622 path_put(&nd->path);
57623 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57624 retval = path_lookupat(dfd, name->name,
57625 flags | LOOKUP_REVAL, nd);
57626
57627 - if (likely(!retval))
57628 + if (likely(!retval)) {
57629 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57630 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57631 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57632 + path_put(&nd->path);
57633 + return -ENOENT;
57634 + }
57635 + }
57636 + }
57637 return retval;
57638 }
57639
57640 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57641 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57642 return -EPERM;
57643
57644 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57645 + return -EPERM;
57646 + if (gr_handle_rawio(inode))
57647 + return -EPERM;
57648 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57649 + return -EACCES;
57650 +
57651 return 0;
57652 }
57653
57654 @@ -2601,7 +2640,7 @@ looked_up:
57655 * cleared otherwise prior to returning.
57656 */
57657 static int lookup_open(struct nameidata *nd, struct path *path,
57658 - struct file *file,
57659 + struct path *link, struct file *file,
57660 const struct open_flags *op,
57661 bool got_write, int *opened)
57662 {
57663 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57664 /* Negative dentry, just create the file */
57665 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57666 umode_t mode = op->mode;
57667 +
57668 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57669 + error = -EACCES;
57670 + goto out_dput;
57671 + }
57672 +
57673 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57674 + error = -EACCES;
57675 + goto out_dput;
57676 + }
57677 +
57678 if (!IS_POSIXACL(dir->d_inode))
57679 mode &= ~current_umask();
57680 /*
57681 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57682 nd->flags & LOOKUP_EXCL);
57683 if (error)
57684 goto out_dput;
57685 + else
57686 + gr_handle_create(dentry, nd->path.mnt);
57687 }
57688 out_no_open:
57689 path->dentry = dentry;
57690 @@ -2671,7 +2723,7 @@ out_dput:
57691 /*
57692 * Handle the last step of open()
57693 */
57694 -static int do_last(struct nameidata *nd, struct path *path,
57695 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57696 struct file *file, const struct open_flags *op,
57697 int *opened, struct filename *name)
57698 {
57699 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57700 if (error)
57701 return error;
57702
57703 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57704 + error = -ENOENT;
57705 + goto out;
57706 + }
57707 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57708 + error = -EACCES;
57709 + goto out;
57710 + }
57711 +
57712 audit_inode(name, dir, LOOKUP_PARENT);
57713 error = -EISDIR;
57714 /* trailing slashes? */
57715 @@ -2740,7 +2801,7 @@ retry_lookup:
57716 */
57717 }
57718 mutex_lock(&dir->d_inode->i_mutex);
57719 - error = lookup_open(nd, path, file, op, got_write, opened);
57720 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57721 mutex_unlock(&dir->d_inode->i_mutex);
57722
57723 if (error <= 0) {
57724 @@ -2764,11 +2825,28 @@ retry_lookup:
57725 goto finish_open_created;
57726 }
57727
57728 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57729 + error = -ENOENT;
57730 + goto exit_dput;
57731 + }
57732 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57733 + error = -EACCES;
57734 + goto exit_dput;
57735 + }
57736 +
57737 /*
57738 * create/update audit record if it already exists.
57739 */
57740 - if (path->dentry->d_inode)
57741 + if (path->dentry->d_inode) {
57742 + /* only check if O_CREAT is specified, all other checks need to go
57743 + into may_open */
57744 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57745 + error = -EACCES;
57746 + goto exit_dput;
57747 + }
57748 +
57749 audit_inode(name, path->dentry, 0);
57750 + }
57751
57752 /*
57753 * If atomic_open() acquired write access it is dropped now due to
57754 @@ -2809,6 +2887,11 @@ finish_lookup:
57755 }
57756 }
57757 BUG_ON(inode != path->dentry->d_inode);
57758 + /* if we're resolving a symlink to another symlink */
57759 + if (link && gr_handle_symlink_owner(link, inode)) {
57760 + error = -EACCES;
57761 + goto out;
57762 + }
57763 return 1;
57764 }
57765
57766 @@ -2818,7 +2901,6 @@ finish_lookup:
57767 save_parent.dentry = nd->path.dentry;
57768 save_parent.mnt = mntget(path->mnt);
57769 nd->path.dentry = path->dentry;
57770 -
57771 }
57772 nd->inode = inode;
57773 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57774 @@ -2828,7 +2910,18 @@ finish_open:
57775 path_put(&save_parent);
57776 return error;
57777 }
57778 +
57779 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57780 + error = -ENOENT;
57781 + goto out;
57782 + }
57783 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57784 + error = -EACCES;
57785 + goto out;
57786 + }
57787 +
57788 audit_inode(name, nd->path.dentry, 0);
57789 +
57790 error = -EISDIR;
57791 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57792 goto out;
57793 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57794 if (unlikely(error))
57795 goto out;
57796
57797 - error = do_last(nd, &path, file, op, &opened, pathname);
57798 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57799 while (unlikely(error > 0)) { /* trailing symlink */
57800 struct path link = path;
57801 void *cookie;
57802 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57803 error = follow_link(&link, nd, &cookie);
57804 if (unlikely(error))
57805 break;
57806 - error = do_last(nd, &path, file, op, &opened, pathname);
57807 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57808 put_link(nd, &link, cookie);
57809 }
57810 out:
57811 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57812 goto unlock;
57813
57814 error = -EEXIST;
57815 - if (dentry->d_inode)
57816 + if (dentry->d_inode) {
57817 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57818 + error = -ENOENT;
57819 + }
57820 goto fail;
57821 + }
57822 /*
57823 * Special case - lookup gave negative, but... we had foo/bar/
57824 * From the vfs_mknod() POV we just have a negative dentry -
57825 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57826 }
57827 EXPORT_SYMBOL(user_path_create);
57828
57829 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57830 +{
57831 + struct filename *tmp = getname(pathname);
57832 + struct dentry *res;
57833 + if (IS_ERR(tmp))
57834 + return ERR_CAST(tmp);
57835 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57836 + if (IS_ERR(res))
57837 + putname(tmp);
57838 + else
57839 + *to = tmp;
57840 + return res;
57841 +}
57842 +
57843 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57844 {
57845 int error = may_create(dir, dentry);
57846 @@ -3224,6 +3335,17 @@ retry:
57847
57848 if (!IS_POSIXACL(path.dentry->d_inode))
57849 mode &= ~current_umask();
57850 +
57851 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57852 + error = -EPERM;
57853 + goto out;
57854 + }
57855 +
57856 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57857 + error = -EACCES;
57858 + goto out;
57859 + }
57860 +
57861 error = security_path_mknod(&path, dentry, mode, dev);
57862 if (error)
57863 goto out;
57864 @@ -3240,6 +3362,8 @@ retry:
57865 break;
57866 }
57867 out:
57868 + if (!error)
57869 + gr_handle_create(dentry, path.mnt);
57870 done_path_create(&path, dentry);
57871 if (retry_estale(error, lookup_flags)) {
57872 lookup_flags |= LOOKUP_REVAL;
57873 @@ -3292,9 +3416,16 @@ retry:
57874
57875 if (!IS_POSIXACL(path.dentry->d_inode))
57876 mode &= ~current_umask();
57877 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57878 + error = -EACCES;
57879 + goto out;
57880 + }
57881 error = security_path_mkdir(&path, dentry, mode);
57882 if (!error)
57883 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57884 + if (!error)
57885 + gr_handle_create(dentry, path.mnt);
57886 +out:
57887 done_path_create(&path, dentry);
57888 if (retry_estale(error, lookup_flags)) {
57889 lookup_flags |= LOOKUP_REVAL;
57890 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57891 struct filename *name;
57892 struct dentry *dentry;
57893 struct nameidata nd;
57894 + ino_t saved_ino = 0;
57895 + dev_t saved_dev = 0;
57896 unsigned int lookup_flags = 0;
57897 retry:
57898 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57899 @@ -3407,10 +3540,21 @@ retry:
57900 error = -ENOENT;
57901 goto exit3;
57902 }
57903 +
57904 + saved_ino = dentry->d_inode->i_ino;
57905 + saved_dev = gr_get_dev_from_dentry(dentry);
57906 +
57907 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57908 + error = -EACCES;
57909 + goto exit3;
57910 + }
57911 +
57912 error = security_path_rmdir(&nd.path, dentry);
57913 if (error)
57914 goto exit3;
57915 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57916 + if (!error && (saved_dev || saved_ino))
57917 + gr_handle_delete(saved_ino, saved_dev);
57918 exit3:
57919 dput(dentry);
57920 exit2:
57921 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57922 struct dentry *dentry;
57923 struct nameidata nd;
57924 struct inode *inode = NULL;
57925 + ino_t saved_ino = 0;
57926 + dev_t saved_dev = 0;
57927 unsigned int lookup_flags = 0;
57928 retry:
57929 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57930 @@ -3502,10 +3648,22 @@ retry:
57931 if (!inode)
57932 goto slashes;
57933 ihold(inode);
57934 +
57935 + if (inode->i_nlink <= 1) {
57936 + saved_ino = inode->i_ino;
57937 + saved_dev = gr_get_dev_from_dentry(dentry);
57938 + }
57939 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57940 + error = -EACCES;
57941 + goto exit2;
57942 + }
57943 +
57944 error = security_path_unlink(&nd.path, dentry);
57945 if (error)
57946 goto exit2;
57947 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57948 + if (!error && (saved_ino || saved_dev))
57949 + gr_handle_delete(saved_ino, saved_dev);
57950 exit2:
57951 dput(dentry);
57952 }
57953 @@ -3583,9 +3741,17 @@ retry:
57954 if (IS_ERR(dentry))
57955 goto out_putname;
57956
57957 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57958 + error = -EACCES;
57959 + goto out;
57960 + }
57961 +
57962 error = security_path_symlink(&path, dentry, from->name);
57963 if (!error)
57964 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57965 + if (!error)
57966 + gr_handle_create(dentry, path.mnt);
57967 +out:
57968 done_path_create(&path, dentry);
57969 if (retry_estale(error, lookup_flags)) {
57970 lookup_flags |= LOOKUP_REVAL;
57971 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57972 {
57973 struct dentry *new_dentry;
57974 struct path old_path, new_path;
57975 + struct filename *to = NULL;
57976 int how = 0;
57977 int error;
57978
57979 @@ -3688,7 +3855,7 @@ retry:
57980 if (error)
57981 return error;
57982
57983 - new_dentry = user_path_create(newdfd, newname, &new_path,
57984 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57985 (how & LOOKUP_REVAL));
57986 error = PTR_ERR(new_dentry);
57987 if (IS_ERR(new_dentry))
57988 @@ -3700,11 +3867,28 @@ retry:
57989 error = may_linkat(&old_path);
57990 if (unlikely(error))
57991 goto out_dput;
57992 +
57993 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57994 + old_path.dentry->d_inode,
57995 + old_path.dentry->d_inode->i_mode, to)) {
57996 + error = -EACCES;
57997 + goto out_dput;
57998 + }
57999 +
58000 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58001 + old_path.dentry, old_path.mnt, to)) {
58002 + error = -EACCES;
58003 + goto out_dput;
58004 + }
58005 +
58006 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58007 if (error)
58008 goto out_dput;
58009 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58010 + if (!error)
58011 + gr_handle_create(new_dentry, new_path.mnt);
58012 out_dput:
58013 + putname(to);
58014 done_path_create(&new_path, new_dentry);
58015 if (retry_estale(error, how)) {
58016 how |= LOOKUP_REVAL;
58017 @@ -3950,12 +4134,21 @@ retry:
58018 if (new_dentry == trap)
58019 goto exit5;
58020
58021 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58022 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58023 + to);
58024 + if (error)
58025 + goto exit5;
58026 +
58027 error = security_path_rename(&oldnd.path, old_dentry,
58028 &newnd.path, new_dentry);
58029 if (error)
58030 goto exit5;
58031 error = vfs_rename(old_dir->d_inode, old_dentry,
58032 new_dir->d_inode, new_dentry);
58033 + if (!error)
58034 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58035 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58036 exit5:
58037 dput(new_dentry);
58038 exit4:
58039 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58040
58041 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58042 {
58043 + char tmpbuf[64];
58044 + const char *newlink;
58045 int len;
58046
58047 len = PTR_ERR(link);
58048 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58049 len = strlen(link);
58050 if (len > (unsigned) buflen)
58051 len = buflen;
58052 - if (copy_to_user(buffer, link, len))
58053 +
58054 + if (len < sizeof(tmpbuf)) {
58055 + memcpy(tmpbuf, link, len);
58056 + newlink = tmpbuf;
58057 + } else
58058 + newlink = link;
58059 +
58060 + if (copy_to_user(buffer, newlink, len))
58061 len = -EFAULT;
58062 out:
58063 return len;
58064 diff --git a/fs/namespace.c b/fs/namespace.c
58065 index a45ba4f..b4c7d07 100644
58066 --- a/fs/namespace.c
58067 +++ b/fs/namespace.c
58068 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
58069 if (!(sb->s_flags & MS_RDONLY))
58070 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58071 up_write(&sb->s_umount);
58072 +
58073 + gr_log_remount(mnt->mnt_devname, retval);
58074 +
58075 return retval;
58076 }
58077
58078 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
58079 }
58080 br_write_unlock(&vfsmount_lock);
58081 namespace_unlock();
58082 +
58083 + gr_log_unmount(mnt->mnt_devname, retval);
58084 +
58085 return retval;
58086 }
58087
58088 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
58089 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58090 */
58091
58092 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58093 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58094 {
58095 struct path path;
58096 struct mount *mnt;
58097 @@ -1342,7 +1348,7 @@ out:
58098 /*
58099 * The 2.0 compatible umount. No flags.
58100 */
58101 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58102 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58103 {
58104 return sys_umount(name, 0);
58105 }
58106 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58107 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58108 MS_STRICTATIME);
58109
58110 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58111 + retval = -EPERM;
58112 + goto dput_out;
58113 + }
58114 +
58115 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58116 + retval = -EPERM;
58117 + goto dput_out;
58118 + }
58119 +
58120 if (flags & MS_REMOUNT)
58121 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58122 data_page);
58123 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58124 dev_name, data_page);
58125 dput_out:
58126 path_put(&path);
58127 +
58128 + gr_log_mount(dev_name, dir_name, retval);
58129 +
58130 return retval;
58131 }
58132
58133 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58134 * number incrementing at 10Ghz will take 12,427 years to wrap which
58135 * is effectively never, so we can ignore the possibility.
58136 */
58137 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58138 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58139
58140 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58141 {
58142 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58143 kfree(new_ns);
58144 return ERR_PTR(ret);
58145 }
58146 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58147 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58148 atomic_set(&new_ns->count, 1);
58149 new_ns->root = NULL;
58150 INIT_LIST_HEAD(&new_ns->list);
58151 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58152 * Allocate a new namespace structure and populate it with contents
58153 * copied from the namespace of the passed in task structure.
58154 */
58155 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58156 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58157 struct user_namespace *user_ns, struct fs_struct *fs)
58158 {
58159 struct mnt_namespace *new_ns;
58160 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58161 }
58162 EXPORT_SYMBOL(mount_subtree);
58163
58164 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58165 - char __user *, type, unsigned long, flags, void __user *, data)
58166 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58167 + const char __user *, type, unsigned long, flags, void __user *, data)
58168 {
58169 int ret;
58170 char *kernel_type;
58171 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58172 if (error)
58173 goto out2;
58174
58175 + if (gr_handle_chroot_pivot()) {
58176 + error = -EPERM;
58177 + goto out2;
58178 + }
58179 +
58180 get_fs_root(current->fs, &root);
58181 old_mp = lock_mount(&old);
58182 error = PTR_ERR(old_mp);
58183 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58184 !nsown_capable(CAP_SYS_ADMIN))
58185 return -EPERM;
58186
58187 - if (fs->users != 1)
58188 + if (atomic_read(&fs->users) != 1)
58189 return -EINVAL;
58190
58191 get_mnt_ns(mnt_ns);
58192 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58193 index f4ccfe6..a5cf064 100644
58194 --- a/fs/nfs/callback_xdr.c
58195 +++ b/fs/nfs/callback_xdr.c
58196 @@ -51,7 +51,7 @@ struct callback_op {
58197 callback_decode_arg_t decode_args;
58198 callback_encode_res_t encode_res;
58199 long res_maxsize;
58200 -};
58201 +} __do_const;
58202
58203 static struct callback_op callback_ops[];
58204
58205 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58206 index 941246f..17d8724 100644
58207 --- a/fs/nfs/inode.c
58208 +++ b/fs/nfs/inode.c
58209 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58210 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58211 }
58212
58213 -static atomic_long_t nfs_attr_generation_counter;
58214 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58215
58216 static unsigned long nfs_read_attr_generation_counter(void)
58217 {
58218 - return atomic_long_read(&nfs_attr_generation_counter);
58219 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58220 }
58221
58222 unsigned long nfs_inc_attr_generation_counter(void)
58223 {
58224 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58225 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58226 }
58227
58228 void nfs_fattr_init(struct nfs_fattr *fattr)
58229 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58230 index 419572f..5414a23 100644
58231 --- a/fs/nfsd/nfs4proc.c
58232 +++ b/fs/nfsd/nfs4proc.c
58233 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58234 nfsd4op_rsize op_rsize_bop;
58235 stateid_getter op_get_currentstateid;
58236 stateid_setter op_set_currentstateid;
58237 -};
58238 +} __do_const;
58239
58240 static struct nfsd4_operation nfsd4_ops[];
58241
58242 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58243 index c2a4701..fd80e29 100644
58244 --- a/fs/nfsd/nfs4xdr.c
58245 +++ b/fs/nfsd/nfs4xdr.c
58246 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58247
58248 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58249
58250 -static nfsd4_dec nfsd4_dec_ops[] = {
58251 +static const nfsd4_dec nfsd4_dec_ops[] = {
58252 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58253 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58254 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58255 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58256 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58257 };
58258
58259 -static nfsd4_dec nfsd41_dec_ops[] = {
58260 +static const nfsd4_dec nfsd41_dec_ops[] = {
58261 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58262 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58263 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58264 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58265 };
58266
58267 struct nfsd4_minorversion_ops {
58268 - nfsd4_dec *decoders;
58269 + const nfsd4_dec *decoders;
58270 int nops;
58271 };
58272
58273 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58274 index e76244e..9fe8f2f1 100644
58275 --- a/fs/nfsd/nfscache.c
58276 +++ b/fs/nfsd/nfscache.c
58277 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58278 {
58279 struct svc_cacherep *rp = rqstp->rq_cacherep;
58280 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58281 - int len;
58282 + long len;
58283 size_t bufsize = 0;
58284
58285 if (!rp)
58286 return;
58287
58288 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58289 - len >>= 2;
58290 + if (statp) {
58291 + len = (char*)statp - (char*)resv->iov_base;
58292 + len = resv->iov_len - len;
58293 + len >>= 2;
58294 + }
58295
58296 /* Don't cache excessive amounts of data and XDR failures */
58297 if (!statp || len > (256 >> 2)) {
58298 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58299 index c827acb..b253b77 100644
58300 --- a/fs/nfsd/vfs.c
58301 +++ b/fs/nfsd/vfs.c
58302 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58303 } else {
58304 oldfs = get_fs();
58305 set_fs(KERNEL_DS);
58306 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58307 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58308 set_fs(oldfs);
58309 }
58310
58311 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58312
58313 /* Write the data. */
58314 oldfs = get_fs(); set_fs(KERNEL_DS);
58315 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58316 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58317 set_fs(oldfs);
58318 if (host_err < 0)
58319 goto out_nfserr;
58320 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58321 */
58322
58323 oldfs = get_fs(); set_fs(KERNEL_DS);
58324 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58325 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58326 set_fs(oldfs);
58327
58328 if (host_err < 0)
58329 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58330 index fea6bd5..8ee9d81 100644
58331 --- a/fs/nls/nls_base.c
58332 +++ b/fs/nls/nls_base.c
58333 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58334
58335 int register_nls(struct nls_table * nls)
58336 {
58337 - struct nls_table ** tmp = &tables;
58338 + struct nls_table *tmp = tables;
58339
58340 if (nls->next)
58341 return -EBUSY;
58342
58343 spin_lock(&nls_lock);
58344 - while (*tmp) {
58345 - if (nls == *tmp) {
58346 + while (tmp) {
58347 + if (nls == tmp) {
58348 spin_unlock(&nls_lock);
58349 return -EBUSY;
58350 }
58351 - tmp = &(*tmp)->next;
58352 + tmp = tmp->next;
58353 }
58354 - nls->next = tables;
58355 + pax_open_kernel();
58356 + *(struct nls_table **)&nls->next = tables;
58357 + pax_close_kernel();
58358 tables = nls;
58359 spin_unlock(&nls_lock);
58360 return 0;
58361 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58362
58363 int unregister_nls(struct nls_table * nls)
58364 {
58365 - struct nls_table ** tmp = &tables;
58366 + struct nls_table * const * tmp = &tables;
58367
58368 spin_lock(&nls_lock);
58369 while (*tmp) {
58370 if (nls == *tmp) {
58371 - *tmp = nls->next;
58372 + pax_open_kernel();
58373 + *(struct nls_table **)tmp = nls->next;
58374 + pax_close_kernel();
58375 spin_unlock(&nls_lock);
58376 return 0;
58377 }
58378 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58379 index 7424929..35f6be5 100644
58380 --- a/fs/nls/nls_euc-jp.c
58381 +++ b/fs/nls/nls_euc-jp.c
58382 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58383 p_nls = load_nls("cp932");
58384
58385 if (p_nls) {
58386 - table.charset2upper = p_nls->charset2upper;
58387 - table.charset2lower = p_nls->charset2lower;
58388 + pax_open_kernel();
58389 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58390 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58391 + pax_close_kernel();
58392 return register_nls(&table);
58393 }
58394
58395 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58396 index e7bc1d7..06bd4bb 100644
58397 --- a/fs/nls/nls_koi8-ru.c
58398 +++ b/fs/nls/nls_koi8-ru.c
58399 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58400 p_nls = load_nls("koi8-u");
58401
58402 if (p_nls) {
58403 - table.charset2upper = p_nls->charset2upper;
58404 - table.charset2lower = p_nls->charset2lower;
58405 + pax_open_kernel();
58406 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58407 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58408 + pax_close_kernel();
58409 return register_nls(&table);
58410 }
58411
58412 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58413 index e44cb64..4807084 100644
58414 --- a/fs/notify/fanotify/fanotify_user.c
58415 +++ b/fs/notify/fanotify/fanotify_user.c
58416 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58417
58418 fd = fanotify_event_metadata.fd;
58419 ret = -EFAULT;
58420 - if (copy_to_user(buf, &fanotify_event_metadata,
58421 - fanotify_event_metadata.event_len))
58422 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58423 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58424 goto out_close_fd;
58425
58426 ret = prepare_for_access_response(group, event, fd);
58427 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58428 index 7b51b05..5ea5ef6 100644
58429 --- a/fs/notify/notification.c
58430 +++ b/fs/notify/notification.c
58431 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58432 * get set to 0 so it will never get 'freed'
58433 */
58434 static struct fsnotify_event *q_overflow_event;
58435 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58436 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58437
58438 /**
58439 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58440 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58441 */
58442 u32 fsnotify_get_cookie(void)
58443 {
58444 - return atomic_inc_return(&fsnotify_sync_cookie);
58445 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58446 }
58447 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58448
58449 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58450 index 9e38daf..5727cae 100644
58451 --- a/fs/ntfs/dir.c
58452 +++ b/fs/ntfs/dir.c
58453 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58454 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58455 ~(s64)(ndir->itype.index.block_size - 1)));
58456 /* Bounds checks. */
58457 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58458 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58459 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58460 "inode 0x%lx or driver bug.", vdir->i_ino);
58461 goto err_out;
58462 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58463 index c5670b8..d590213 100644
58464 --- a/fs/ntfs/file.c
58465 +++ b/fs/ntfs/file.c
58466 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58467 char *addr;
58468 size_t total = 0;
58469 unsigned len;
58470 - int left;
58471 + unsigned left;
58472
58473 do {
58474 len = PAGE_CACHE_SIZE - ofs;
58475 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58476 index 82650d5..db37dcf 100644
58477 --- a/fs/ntfs/super.c
58478 +++ b/fs/ntfs/super.c
58479 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58480 if (!silent)
58481 ntfs_error(sb, "Primary boot sector is invalid.");
58482 } else if (!silent)
58483 - ntfs_error(sb, read_err_str, "primary");
58484 + ntfs_error(sb, read_err_str, "%s", "primary");
58485 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58486 if (bh_primary)
58487 brelse(bh_primary);
58488 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58489 goto hotfix_primary_boot_sector;
58490 brelse(bh_backup);
58491 } else if (!silent)
58492 - ntfs_error(sb, read_err_str, "backup");
58493 + ntfs_error(sb, read_err_str, "%s", "backup");
58494 /* Try to read NT3.51- backup boot sector. */
58495 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58496 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58497 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58498 "sector.");
58499 brelse(bh_backup);
58500 } else if (!silent)
58501 - ntfs_error(sb, read_err_str, "backup");
58502 + ntfs_error(sb, read_err_str, "%s", "backup");
58503 /* We failed. Cleanup and return. */
58504 if (bh_primary)
58505 brelse(bh_primary);
58506 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58507 index aebeacd..0dcdd26 100644
58508 --- a/fs/ocfs2/localalloc.c
58509 +++ b/fs/ocfs2/localalloc.c
58510 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58511 goto bail;
58512 }
58513
58514 - atomic_inc(&osb->alloc_stats.moves);
58515 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58516
58517 bail:
58518 if (handle)
58519 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58520 index 3a90347..c40bef8 100644
58521 --- a/fs/ocfs2/ocfs2.h
58522 +++ b/fs/ocfs2/ocfs2.h
58523 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58524
58525 struct ocfs2_alloc_stats
58526 {
58527 - atomic_t moves;
58528 - atomic_t local_data;
58529 - atomic_t bitmap_data;
58530 - atomic_t bg_allocs;
58531 - atomic_t bg_extends;
58532 + atomic_unchecked_t moves;
58533 + atomic_unchecked_t local_data;
58534 + atomic_unchecked_t bitmap_data;
58535 + atomic_unchecked_t bg_allocs;
58536 + atomic_unchecked_t bg_extends;
58537 };
58538
58539 enum ocfs2_local_alloc_state
58540 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58541 index 5397c07..54afc55 100644
58542 --- a/fs/ocfs2/suballoc.c
58543 +++ b/fs/ocfs2/suballoc.c
58544 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58545 mlog_errno(status);
58546 goto bail;
58547 }
58548 - atomic_inc(&osb->alloc_stats.bg_extends);
58549 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58550
58551 /* You should never ask for this much metadata */
58552 BUG_ON(bits_wanted >
58553 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58554 mlog_errno(status);
58555 goto bail;
58556 }
58557 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58558 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58559
58560 *suballoc_loc = res.sr_bg_blkno;
58561 *suballoc_bit_start = res.sr_bit_offset;
58562 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58563 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58564 res->sr_bits);
58565
58566 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58567 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58568
58569 BUG_ON(res->sr_bits != 1);
58570
58571 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58572 mlog_errno(status);
58573 goto bail;
58574 }
58575 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58576 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58577
58578 BUG_ON(res.sr_bits != 1);
58579
58580 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58581 cluster_start,
58582 num_clusters);
58583 if (!status)
58584 - atomic_inc(&osb->alloc_stats.local_data);
58585 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58586 } else {
58587 if (min_clusters > (osb->bitmap_cpg - 1)) {
58588 /* The only paths asking for contiguousness
58589 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58590 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58591 res.sr_bg_blkno,
58592 res.sr_bit_offset);
58593 - atomic_inc(&osb->alloc_stats.bitmap_data);
58594 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58595 *num_clusters = res.sr_bits;
58596 }
58597 }
58598 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58599 index 121da2d..a0232bc 100644
58600 --- a/fs/ocfs2/super.c
58601 +++ b/fs/ocfs2/super.c
58602 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58603 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58604 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58605 "Stats",
58606 - atomic_read(&osb->alloc_stats.bitmap_data),
58607 - atomic_read(&osb->alloc_stats.local_data),
58608 - atomic_read(&osb->alloc_stats.bg_allocs),
58609 - atomic_read(&osb->alloc_stats.moves),
58610 - atomic_read(&osb->alloc_stats.bg_extends));
58611 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58612 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58613 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58614 + atomic_read_unchecked(&osb->alloc_stats.moves),
58615 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58616
58617 out += snprintf(buf + out, len - out,
58618 "%10s => State: %u Descriptor: %llu Size: %u bits "
58619 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58620 spin_lock_init(&osb->osb_xattr_lock);
58621 ocfs2_init_steal_slots(osb);
58622
58623 - atomic_set(&osb->alloc_stats.moves, 0);
58624 - atomic_set(&osb->alloc_stats.local_data, 0);
58625 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58626 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58627 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58628 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58629 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58630 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58631 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58632 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58633
58634 /* Copy the blockcheck stats from the superblock probe */
58635 osb->osb_ecc_stats = *stats;
58636 diff --git a/fs/open.c b/fs/open.c
58637 index 7931f76..7b03f3b 100644
58638 --- a/fs/open.c
58639 +++ b/fs/open.c
58640 @@ -32,6 +32,8 @@
58641 #include <linux/dnotify.h>
58642 #include <linux/compat.h>
58643
58644 +#define CREATE_TRACE_POINTS
58645 +#include <trace/events/fs.h>
58646 #include "internal.h"
58647
58648 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58649 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58650 error = locks_verify_truncate(inode, NULL, length);
58651 if (!error)
58652 error = security_path_truncate(path);
58653 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58654 + error = -EACCES;
58655 if (!error)
58656 error = do_truncate(path->dentry, length, 0, NULL);
58657
58658 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58659 error = locks_verify_truncate(inode, f.file, length);
58660 if (!error)
58661 error = security_path_truncate(&f.file->f_path);
58662 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58663 + error = -EACCES;
58664 if (!error)
58665 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58666 sb_end_write(inode->i_sb);
58667 @@ -360,6 +366,9 @@ retry:
58668 if (__mnt_is_readonly(path.mnt))
58669 res = -EROFS;
58670
58671 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58672 + res = -EACCES;
58673 +
58674 out_path_release:
58675 path_put(&path);
58676 if (retry_estale(res, lookup_flags)) {
58677 @@ -391,6 +400,8 @@ retry:
58678 if (error)
58679 goto dput_and_out;
58680
58681 + gr_log_chdir(path.dentry, path.mnt);
58682 +
58683 set_fs_pwd(current->fs, &path);
58684
58685 dput_and_out:
58686 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58687 goto out_putf;
58688
58689 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58690 +
58691 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58692 + error = -EPERM;
58693 +
58694 + if (!error)
58695 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58696 +
58697 if (!error)
58698 set_fs_pwd(current->fs, &f.file->f_path);
58699 out_putf:
58700 @@ -449,7 +467,13 @@ retry:
58701 if (error)
58702 goto dput_and_out;
58703
58704 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58705 + goto dput_and_out;
58706 +
58707 set_fs_root(current->fs, &path);
58708 +
58709 + gr_handle_chroot_chdir(&path);
58710 +
58711 error = 0;
58712 dput_and_out:
58713 path_put(&path);
58714 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58715 if (error)
58716 return error;
58717 mutex_lock(&inode->i_mutex);
58718 +
58719 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58720 + error = -EACCES;
58721 + goto out_unlock;
58722 + }
58723 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58724 + error = -EACCES;
58725 + goto out_unlock;
58726 + }
58727 +
58728 error = security_path_chmod(path, mode);
58729 if (error)
58730 goto out_unlock;
58731 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58732 uid = make_kuid(current_user_ns(), user);
58733 gid = make_kgid(current_user_ns(), group);
58734
58735 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58736 + return -EACCES;
58737 +
58738 newattrs.ia_valid = ATTR_CTIME;
58739 if (user != (uid_t) -1) {
58740 if (!uid_valid(uid))
58741 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58742 } else {
58743 fsnotify_open(f);
58744 fd_install(fd, f);
58745 + trace_do_sys_open(tmp->name, flags, mode);
58746 }
58747 }
58748 putname(tmp);
58749 diff --git a/fs/pipe.c b/fs/pipe.c
58750 index d2c45e1..009fe1c 100644
58751 --- a/fs/pipe.c
58752 +++ b/fs/pipe.c
58753 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58754
58755 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58756 {
58757 - if (pipe->files)
58758 + if (atomic_read(&pipe->files))
58759 mutex_lock_nested(&pipe->mutex, subclass);
58760 }
58761
58762 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58763
58764 void pipe_unlock(struct pipe_inode_info *pipe)
58765 {
58766 - if (pipe->files)
58767 + if (atomic_read(&pipe->files))
58768 mutex_unlock(&pipe->mutex);
58769 }
58770 EXPORT_SYMBOL(pipe_unlock);
58771 @@ -449,9 +449,9 @@ redo:
58772 }
58773 if (bufs) /* More to do? */
58774 continue;
58775 - if (!pipe->writers)
58776 + if (!atomic_read(&pipe->writers))
58777 break;
58778 - if (!pipe->waiting_writers) {
58779 + if (!atomic_read(&pipe->waiting_writers)) {
58780 /* syscall merging: Usually we must not sleep
58781 * if O_NONBLOCK is set, or if we got some data.
58782 * But if a writer sleeps in kernel space, then
58783 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58784 ret = 0;
58785 __pipe_lock(pipe);
58786
58787 - if (!pipe->readers) {
58788 + if (!atomic_read(&pipe->readers)) {
58789 send_sig(SIGPIPE, current, 0);
58790 ret = -EPIPE;
58791 goto out;
58792 @@ -562,7 +562,7 @@ redo1:
58793 for (;;) {
58794 int bufs;
58795
58796 - if (!pipe->readers) {
58797 + if (!atomic_read(&pipe->readers)) {
58798 send_sig(SIGPIPE, current, 0);
58799 if (!ret)
58800 ret = -EPIPE;
58801 @@ -653,9 +653,9 @@ redo2:
58802 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58803 do_wakeup = 0;
58804 }
58805 - pipe->waiting_writers++;
58806 + atomic_inc(&pipe->waiting_writers);
58807 pipe_wait(pipe);
58808 - pipe->waiting_writers--;
58809 + atomic_dec(&pipe->waiting_writers);
58810 }
58811 out:
58812 __pipe_unlock(pipe);
58813 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58814 mask = 0;
58815 if (filp->f_mode & FMODE_READ) {
58816 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58817 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58818 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58819 mask |= POLLHUP;
58820 }
58821
58822 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58823 * Most Unices do not set POLLERR for FIFOs but on Linux they
58824 * behave exactly like pipes for poll().
58825 */
58826 - if (!pipe->readers)
58827 + if (!atomic_read(&pipe->readers))
58828 mask |= POLLERR;
58829 }
58830
58831 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58832
58833 __pipe_lock(pipe);
58834 if (file->f_mode & FMODE_READ)
58835 - pipe->readers--;
58836 + atomic_dec(&pipe->readers);
58837 if (file->f_mode & FMODE_WRITE)
58838 - pipe->writers--;
58839 + atomic_dec(&pipe->writers);
58840
58841 - if (pipe->readers || pipe->writers) {
58842 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58843 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58844 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58845 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58846 }
58847 spin_lock(&inode->i_lock);
58848 - if (!--pipe->files) {
58849 + if (atomic_dec_and_test(&pipe->files)) {
58850 inode->i_pipe = NULL;
58851 kill = 1;
58852 }
58853 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58854 kfree(pipe);
58855 }
58856
58857 -static struct vfsmount *pipe_mnt __read_mostly;
58858 +struct vfsmount *pipe_mnt __read_mostly;
58859
58860 /*
58861 * pipefs_dname() is called from d_path().
58862 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58863 goto fail_iput;
58864
58865 inode->i_pipe = pipe;
58866 - pipe->files = 2;
58867 - pipe->readers = pipe->writers = 1;
58868 + atomic_set(&pipe->files, 2);
58869 + atomic_set(&pipe->readers, 1);
58870 + atomic_set(&pipe->writers, 1);
58871 inode->i_fop = &pipefifo_fops;
58872
58873 /*
58874 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58875 spin_lock(&inode->i_lock);
58876 if (inode->i_pipe) {
58877 pipe = inode->i_pipe;
58878 - pipe->files++;
58879 + atomic_inc(&pipe->files);
58880 spin_unlock(&inode->i_lock);
58881 } else {
58882 spin_unlock(&inode->i_lock);
58883 pipe = alloc_pipe_info();
58884 if (!pipe)
58885 return -ENOMEM;
58886 - pipe->files = 1;
58887 + atomic_set(&pipe->files, 1);
58888 spin_lock(&inode->i_lock);
58889 if (unlikely(inode->i_pipe)) {
58890 - inode->i_pipe->files++;
58891 + atomic_inc(&inode->i_pipe->files);
58892 spin_unlock(&inode->i_lock);
58893 free_pipe_info(pipe);
58894 pipe = inode->i_pipe;
58895 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58896 * opened, even when there is no process writing the FIFO.
58897 */
58898 pipe->r_counter++;
58899 - if (pipe->readers++ == 0)
58900 + if (atomic_inc_return(&pipe->readers) == 1)
58901 wake_up_partner(pipe);
58902
58903 - if (!is_pipe && !pipe->writers) {
58904 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58905 if ((filp->f_flags & O_NONBLOCK)) {
58906 /* suppress POLLHUP until we have
58907 * seen a writer */
58908 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58909 * errno=ENXIO when there is no process reading the FIFO.
58910 */
58911 ret = -ENXIO;
58912 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58913 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58914 goto err;
58915
58916 pipe->w_counter++;
58917 - if (!pipe->writers++)
58918 + if (atomic_inc_return(&pipe->writers) == 1)
58919 wake_up_partner(pipe);
58920
58921 - if (!is_pipe && !pipe->readers) {
58922 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58923 if (wait_for_partner(pipe, &pipe->r_counter))
58924 goto err_wr;
58925 }
58926 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58927 * the process can at least talk to itself.
58928 */
58929
58930 - pipe->readers++;
58931 - pipe->writers++;
58932 + atomic_inc(&pipe->readers);
58933 + atomic_inc(&pipe->writers);
58934 pipe->r_counter++;
58935 pipe->w_counter++;
58936 - if (pipe->readers == 1 || pipe->writers == 1)
58937 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58938 wake_up_partner(pipe);
58939 break;
58940
58941 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58942 return 0;
58943
58944 err_rd:
58945 - if (!--pipe->readers)
58946 + if (atomic_dec_and_test(&pipe->readers))
58947 wake_up_interruptible(&pipe->wait);
58948 ret = -ERESTARTSYS;
58949 goto err;
58950
58951 err_wr:
58952 - if (!--pipe->writers)
58953 + if (atomic_dec_and_test(&pipe->writers))
58954 wake_up_interruptible(&pipe->wait);
58955 ret = -ERESTARTSYS;
58956 goto err;
58957
58958 err:
58959 spin_lock(&inode->i_lock);
58960 - if (!--pipe->files) {
58961 + if (atomic_dec_and_test(&pipe->files)) {
58962 inode->i_pipe = NULL;
58963 kill = 1;
58964 }
58965 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58966 index 15af622..0e9f4467 100644
58967 --- a/fs/proc/Kconfig
58968 +++ b/fs/proc/Kconfig
58969 @@ -30,12 +30,12 @@ config PROC_FS
58970
58971 config PROC_KCORE
58972 bool "/proc/kcore support" if !ARM
58973 - depends on PROC_FS && MMU
58974 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58975
58976 config PROC_VMCORE
58977 bool "/proc/vmcore support"
58978 - depends on PROC_FS && CRASH_DUMP
58979 - default y
58980 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58981 + default n
58982 help
58983 Exports the dump image of crashed kernel in ELF format.
58984
58985 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58986 limited in memory.
58987
58988 config PROC_PAGE_MONITOR
58989 - default y
58990 - depends on PROC_FS && MMU
58991 + default n
58992 + depends on PROC_FS && MMU && !GRKERNSEC
58993 bool "Enable /proc page monitoring" if EXPERT
58994 help
58995 Various /proc files exist to monitor process memory utilization:
58996 diff --git a/fs/proc/array.c b/fs/proc/array.c
58997 index cbd0f1b..adec3f0 100644
58998 --- a/fs/proc/array.c
58999 +++ b/fs/proc/array.c
59000 @@ -60,6 +60,7 @@
59001 #include <linux/tty.h>
59002 #include <linux/string.h>
59003 #include <linux/mman.h>
59004 +#include <linux/grsecurity.h>
59005 #include <linux/proc_fs.h>
59006 #include <linux/ioport.h>
59007 #include <linux/uaccess.h>
59008 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
59009 seq_putc(m, '\n');
59010 }
59011
59012 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59013 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
59014 +{
59015 + if (p->mm)
59016 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
59017 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
59018 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
59019 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
59020 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
59021 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
59022 + else
59023 + seq_printf(m, "PaX:\t-----\n");
59024 +}
59025 +#endif
59026 +
59027 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59028 struct pid *pid, struct task_struct *task)
59029 {
59030 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59031 task_cpus_allowed(m, task);
59032 cpuset_task_status_allowed(m, task);
59033 task_context_switch_counts(m, task);
59034 +
59035 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59036 + task_pax(m, task);
59037 +#endif
59038 +
59039 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
59040 + task_grsec_rbac(m, task);
59041 +#endif
59042 +
59043 return 0;
59044 }
59045
59046 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59047 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59048 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59049 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59050 +#endif
59051 +
59052 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59053 struct pid *pid, struct task_struct *task, int whole)
59054 {
59055 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59056 char tcomm[sizeof(task->comm)];
59057 unsigned long flags;
59058
59059 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59060 + if (current->exec_id != m->exec_id) {
59061 + gr_log_badprocpid("stat");
59062 + return 0;
59063 + }
59064 +#endif
59065 +
59066 state = *get_task_state(task);
59067 vsize = eip = esp = 0;
59068 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59069 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59070 gtime = task_gtime(task);
59071 }
59072
59073 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59074 + if (PAX_RAND_FLAGS(mm)) {
59075 + eip = 0;
59076 + esp = 0;
59077 + wchan = 0;
59078 + }
59079 +#endif
59080 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59081 + wchan = 0;
59082 + eip =0;
59083 + esp =0;
59084 +#endif
59085 +
59086 /* scale priority and nice values from timeslices to -20..20 */
59087 /* to make it look like a "normal" Unix priority/nice value */
59088 priority = task_prio(task);
59089 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59090 seq_put_decimal_ull(m, ' ', vsize);
59091 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59092 seq_put_decimal_ull(m, ' ', rsslim);
59093 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59094 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59095 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59096 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59097 +#else
59098 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59099 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59100 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59101 +#endif
59102 seq_put_decimal_ull(m, ' ', esp);
59103 seq_put_decimal_ull(m, ' ', eip);
59104 /* The signal information here is obsolete.
59105 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59106 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59107 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59108
59109 - if (mm && permitted) {
59110 + if (mm && permitted
59111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59112 + && !PAX_RAND_FLAGS(mm)
59113 +#endif
59114 + ) {
59115 seq_put_decimal_ull(m, ' ', mm->start_data);
59116 seq_put_decimal_ull(m, ' ', mm->end_data);
59117 seq_put_decimal_ull(m, ' ', mm->start_brk);
59118 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59119 struct pid *pid, struct task_struct *task)
59120 {
59121 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59122 - struct mm_struct *mm = get_task_mm(task);
59123 + struct mm_struct *mm;
59124
59125 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59126 + if (current->exec_id != m->exec_id) {
59127 + gr_log_badprocpid("statm");
59128 + return 0;
59129 + }
59130 +#endif
59131 + mm = get_task_mm(task);
59132 if (mm) {
59133 size = task_statm(mm, &shared, &text, &data, &resident);
59134 mmput(mm);
59135 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59136 return 0;
59137 }
59138
59139 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59140 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59141 +{
59142 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59143 +}
59144 +#endif
59145 +
59146 #ifdef CONFIG_CHECKPOINT_RESTORE
59147 static struct pid *
59148 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59149 diff --git a/fs/proc/base.c b/fs/proc/base.c
59150 index 1485e38..8ad4236 100644
59151 --- a/fs/proc/base.c
59152 +++ b/fs/proc/base.c
59153 @@ -113,6 +113,14 @@ struct pid_entry {
59154 union proc_op op;
59155 };
59156
59157 +struct getdents_callback {
59158 + struct linux_dirent __user * current_dir;
59159 + struct linux_dirent __user * previous;
59160 + struct file * file;
59161 + int count;
59162 + int error;
59163 +};
59164 +
59165 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59166 .name = (NAME), \
59167 .len = sizeof(NAME) - 1, \
59168 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59169 if (!mm->arg_end)
59170 goto out_mm; /* Shh! No looking before we're done */
59171
59172 + if (gr_acl_handle_procpidmem(task))
59173 + goto out_mm;
59174 +
59175 len = mm->arg_end - mm->arg_start;
59176
59177 if (len > PAGE_SIZE)
59178 @@ -237,12 +248,28 @@ out:
59179 return res;
59180 }
59181
59182 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59183 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59184 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59185 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59186 +#endif
59187 +
59188 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59189 {
59190 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59191 int res = PTR_ERR(mm);
59192 if (mm && !IS_ERR(mm)) {
59193 unsigned int nwords = 0;
59194 +
59195 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59196 + /* allow if we're currently ptracing this task */
59197 + if (PAX_RAND_FLAGS(mm) &&
59198 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59199 + mmput(mm);
59200 + return 0;
59201 + }
59202 +#endif
59203 +
59204 do {
59205 nwords += 2;
59206 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59207 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59208 }
59209
59210
59211 -#ifdef CONFIG_KALLSYMS
59212 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59213 /*
59214 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59215 * Returns the resolved symbol. If that fails, simply return the address.
59216 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59217 mutex_unlock(&task->signal->cred_guard_mutex);
59218 }
59219
59220 -#ifdef CONFIG_STACKTRACE
59221 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59222
59223 #define MAX_STACK_TRACE_DEPTH 64
59224
59225 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59226 return count;
59227 }
59228
59229 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59230 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59231 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59232 {
59233 long nr;
59234 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59235 /************************************************************************/
59236
59237 /* permission checks */
59238 -static int proc_fd_access_allowed(struct inode *inode)
59239 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59240 {
59241 struct task_struct *task;
59242 int allowed = 0;
59243 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59244 */
59245 task = get_proc_task(inode);
59246 if (task) {
59247 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59248 + if (log)
59249 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59250 + else
59251 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59252 put_task_struct(task);
59253 }
59254 return allowed;
59255 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59256 struct task_struct *task,
59257 int hide_pid_min)
59258 {
59259 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59260 + return false;
59261 +
59262 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59263 + rcu_read_lock();
59264 + {
59265 + const struct cred *tmpcred = current_cred();
59266 + const struct cred *cred = __task_cred(task);
59267 +
59268 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59269 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59270 + || in_group_p(grsec_proc_gid)
59271 +#endif
59272 + ) {
59273 + rcu_read_unlock();
59274 + return true;
59275 + }
59276 + }
59277 + rcu_read_unlock();
59278 +
59279 + if (!pid->hide_pid)
59280 + return false;
59281 +#endif
59282 +
59283 if (pid->hide_pid < hide_pid_min)
59284 return true;
59285 if (in_group_p(pid->pid_gid))
59286 return true;
59287 +
59288 return ptrace_may_access(task, PTRACE_MODE_READ);
59289 }
59290
59291 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59292 put_task_struct(task);
59293
59294 if (!has_perms) {
59295 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59296 + {
59297 +#else
59298 if (pid->hide_pid == 2) {
59299 +#endif
59300 /*
59301 * Let's make getdents(), stat(), and open()
59302 * consistent with each other. If a process
59303 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59304 if (!task)
59305 return -ESRCH;
59306
59307 + if (gr_acl_handle_procpidmem(task)) {
59308 + put_task_struct(task);
59309 + return -EPERM;
59310 + }
59311 +
59312 mm = mm_access(task, mode);
59313 put_task_struct(task);
59314
59315 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59316
59317 file->private_data = mm;
59318
59319 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59320 + file->f_version = current->exec_id;
59321 +#endif
59322 +
59323 return 0;
59324 }
59325
59326 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59327 ssize_t copied;
59328 char *page;
59329
59330 +#ifdef CONFIG_GRKERNSEC
59331 + if (write)
59332 + return -EPERM;
59333 +#endif
59334 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59335 + if (file->f_version != current->exec_id) {
59336 + gr_log_badprocpid("mem");
59337 + return 0;
59338 + }
59339 +#endif
59340 +
59341 if (!mm)
59342 return 0;
59343
59344 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59345 goto free;
59346
59347 while (count > 0) {
59348 - int this_len = min_t(int, count, PAGE_SIZE);
59349 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59350
59351 if (write && copy_from_user(page, buf, this_len)) {
59352 copied = -EFAULT;
59353 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59354 if (!mm)
59355 return 0;
59356
59357 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59358 + if (file->f_version != current->exec_id) {
59359 + gr_log_badprocpid("environ");
59360 + return 0;
59361 + }
59362 +#endif
59363 +
59364 page = (char *)__get_free_page(GFP_TEMPORARY);
59365 if (!page)
59366 return -ENOMEM;
59367 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59368 goto free;
59369 while (count > 0) {
59370 size_t this_len, max_len;
59371 - int retval;
59372 + ssize_t retval;
59373
59374 if (src >= (mm->env_end - mm->env_start))
59375 break;
59376 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59377 int error = -EACCES;
59378
59379 /* Are we allowed to snoop on the tasks file descriptors? */
59380 - if (!proc_fd_access_allowed(inode))
59381 + if (!proc_fd_access_allowed(inode, 0))
59382 goto out;
59383
59384 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59385 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59386 struct path path;
59387
59388 /* Are we allowed to snoop on the tasks file descriptors? */
59389 - if (!proc_fd_access_allowed(inode))
59390 - goto out;
59391 + /* logging this is needed for learning on chromium to work properly,
59392 + but we don't want to flood the logs from 'ps' which does a readlink
59393 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59394 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59395 + */
59396 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59397 + if (!proc_fd_access_allowed(inode,0))
59398 + goto out;
59399 + } else {
59400 + if (!proc_fd_access_allowed(inode,1))
59401 + goto out;
59402 + }
59403
59404 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59405 if (error)
59406 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59407 rcu_read_lock();
59408 cred = __task_cred(task);
59409 inode->i_uid = cred->euid;
59410 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59411 + inode->i_gid = grsec_proc_gid;
59412 +#else
59413 inode->i_gid = cred->egid;
59414 +#endif
59415 rcu_read_unlock();
59416 }
59417 security_task_to_inode(task, inode);
59418 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59419 return -ENOENT;
59420 }
59421 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59422 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59423 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59424 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59425 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59426 +#endif
59427 task_dumpable(task)) {
59428 cred = __task_cred(task);
59429 stat->uid = cred->euid;
59430 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59431 + stat->gid = grsec_proc_gid;
59432 +#else
59433 stat->gid = cred->egid;
59434 +#endif
59435 }
59436 }
59437 rcu_read_unlock();
59438 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59439
59440 if (task) {
59441 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59442 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59443 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59444 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59445 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59446 +#endif
59447 task_dumpable(task)) {
59448 rcu_read_lock();
59449 cred = __task_cred(task);
59450 inode->i_uid = cred->euid;
59451 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59452 + inode->i_gid = grsec_proc_gid;
59453 +#else
59454 inode->i_gid = cred->egid;
59455 +#endif
59456 rcu_read_unlock();
59457 } else {
59458 inode->i_uid = GLOBAL_ROOT_UID;
59459 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59460 if (!task)
59461 goto out_no_task;
59462
59463 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59464 + goto out;
59465 +
59466 /*
59467 * Yes, it does not scale. And it should not. Don't add
59468 * new entries into /proc/<tgid>/ without very good reasons.
59469 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59470 if (!task)
59471 return -ENOENT;
59472
59473 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59474 + goto out;
59475 +
59476 if (!dir_emit_dots(file, ctx))
59477 goto out;
59478
59479 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59480 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59481 #endif
59482 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59483 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59484 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59485 INF("syscall", S_IRUGO, proc_pid_syscall),
59486 #endif
59487 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59488 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59489 #ifdef CONFIG_SECURITY
59490 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59491 #endif
59492 -#ifdef CONFIG_KALLSYMS
59493 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59494 INF("wchan", S_IRUGO, proc_pid_wchan),
59495 #endif
59496 -#ifdef CONFIG_STACKTRACE
59497 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59498 ONE("stack", S_IRUGO, proc_pid_stack),
59499 #endif
59500 #ifdef CONFIG_SCHEDSTATS
59501 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59502 #ifdef CONFIG_HARDWALL
59503 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59504 #endif
59505 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59506 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59507 +#endif
59508 #ifdef CONFIG_USER_NS
59509 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59510 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59511 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59512 if (!inode)
59513 goto out;
59514
59515 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59516 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59517 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59518 + inode->i_gid = grsec_proc_gid;
59519 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59520 +#else
59521 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59522 +#endif
59523 inode->i_op = &proc_tgid_base_inode_operations;
59524 inode->i_fop = &proc_tgid_base_operations;
59525 inode->i_flags|=S_IMMUTABLE;
59526 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59527 if (!task)
59528 goto out;
59529
59530 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59531 + goto out_put_task;
59532 +
59533 result = proc_pid_instantiate(dir, dentry, task, NULL);
59534 +out_put_task:
59535 put_task_struct(task);
59536 out:
59537 return ERR_PTR(result);
59538 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59539 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59540 #endif
59541 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59542 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59543 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59544 INF("syscall", S_IRUGO, proc_pid_syscall),
59545 #endif
59546 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59547 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59548 #ifdef CONFIG_SECURITY
59549 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59550 #endif
59551 -#ifdef CONFIG_KALLSYMS
59552 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59553 INF("wchan", S_IRUGO, proc_pid_wchan),
59554 #endif
59555 -#ifdef CONFIG_STACKTRACE
59556 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59557 ONE("stack", S_IRUGO, proc_pid_stack),
59558 #endif
59559 #ifdef CONFIG_SCHEDSTATS
59560 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59561 index 82676e3..5f8518a 100644
59562 --- a/fs/proc/cmdline.c
59563 +++ b/fs/proc/cmdline.c
59564 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59565
59566 static int __init proc_cmdline_init(void)
59567 {
59568 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59569 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59570 +#else
59571 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59572 +#endif
59573 return 0;
59574 }
59575 module_init(proc_cmdline_init);
59576 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59577 index b143471..bb105e5 100644
59578 --- a/fs/proc/devices.c
59579 +++ b/fs/proc/devices.c
59580 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59581
59582 static int __init proc_devices_init(void)
59583 {
59584 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59585 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59586 +#else
59587 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59588 +#endif
59589 return 0;
59590 }
59591 module_init(proc_devices_init);
59592 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59593 index 0ff80f9..a1d7500 100644
59594 --- a/fs/proc/fd.c
59595 +++ b/fs/proc/fd.c
59596 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59597 if (!task)
59598 return -ENOENT;
59599
59600 - files = get_files_struct(task);
59601 + if (!gr_acl_handle_procpidmem(task))
59602 + files = get_files_struct(task);
59603 put_task_struct(task);
59604
59605 if (files) {
59606 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59607 */
59608 int proc_fd_permission(struct inode *inode, int mask)
59609 {
59610 + struct task_struct *task;
59611 int rv = generic_permission(inode, mask);
59612 - if (rv == 0)
59613 - return 0;
59614 +
59615 if (task_pid(current) == proc_pid(inode))
59616 rv = 0;
59617 +
59618 + task = get_proc_task(inode);
59619 + if (task == NULL)
59620 + return rv;
59621 +
59622 + if (gr_acl_handle_procpidmem(task))
59623 + rv = -EACCES;
59624 +
59625 + put_task_struct(task);
59626 +
59627 return rv;
59628 }
59629
59630 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59631 index 073aea6..0630370 100644
59632 --- a/fs/proc/inode.c
59633 +++ b/fs/proc/inode.c
59634 @@ -23,11 +23,17 @@
59635 #include <linux/slab.h>
59636 #include <linux/mount.h>
59637 #include <linux/magic.h>
59638 +#include <linux/grsecurity.h>
59639
59640 #include <asm/uaccess.h>
59641
59642 #include "internal.h"
59643
59644 +#ifdef CONFIG_PROC_SYSCTL
59645 +extern const struct inode_operations proc_sys_inode_operations;
59646 +extern const struct inode_operations proc_sys_dir_operations;
59647 +#endif
59648 +
59649 static void proc_evict_inode(struct inode *inode)
59650 {
59651 struct proc_dir_entry *de;
59652 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59653 ns = PROC_I(inode)->ns.ns;
59654 if (ns_ops && ns)
59655 ns_ops->put(ns);
59656 +
59657 +#ifdef CONFIG_PROC_SYSCTL
59658 + if (inode->i_op == &proc_sys_inode_operations ||
59659 + inode->i_op == &proc_sys_dir_operations)
59660 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59661 +#endif
59662 +
59663 }
59664
59665 static struct kmem_cache * proc_inode_cachep;
59666 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59667 if (de->mode) {
59668 inode->i_mode = de->mode;
59669 inode->i_uid = de->uid;
59670 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59671 + inode->i_gid = grsec_proc_gid;
59672 +#else
59673 inode->i_gid = de->gid;
59674 +#endif
59675 }
59676 if (de->size)
59677 inode->i_size = de->size;
59678 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59679 index 651d09a..60c73ae 100644
59680 --- a/fs/proc/internal.h
59681 +++ b/fs/proc/internal.h
59682 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59683 struct pid *, struct task_struct *);
59684 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59685 struct pid *, struct task_struct *);
59686 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59687 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59688 +#endif
59689
59690 /*
59691 * base.c
59692 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59693 index 06ea155..9a798c7 100644
59694 --- a/fs/proc/kcore.c
59695 +++ b/fs/proc/kcore.c
59696 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59697 * the addresses in the elf_phdr on our list.
59698 */
59699 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59700 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59701 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59702 + if (tsz > buflen)
59703 tsz = buflen;
59704 -
59705 +
59706 while (buflen) {
59707 struct kcore_list *m;
59708
59709 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59710 kfree(elf_buf);
59711 } else {
59712 if (kern_addr_valid(start)) {
59713 - unsigned long n;
59714 + char *elf_buf;
59715 + mm_segment_t oldfs;
59716
59717 - n = copy_to_user(buffer, (char *)start, tsz);
59718 - /*
59719 - * We cannot distinguish between fault on source
59720 - * and fault on destination. When this happens
59721 - * we clear too and hope it will trigger the
59722 - * EFAULT again.
59723 - */
59724 - if (n) {
59725 - if (clear_user(buffer + tsz - n,
59726 - n))
59727 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59728 + if (!elf_buf)
59729 + return -ENOMEM;
59730 + oldfs = get_fs();
59731 + set_fs(KERNEL_DS);
59732 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59733 + set_fs(oldfs);
59734 + if (copy_to_user(buffer, elf_buf, tsz)) {
59735 + kfree(elf_buf);
59736 return -EFAULT;
59737 + }
59738 }
59739 + set_fs(oldfs);
59740 + kfree(elf_buf);
59741 } else {
59742 if (clear_user(buffer, tsz))
59743 return -EFAULT;
59744 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59745
59746 static int open_kcore(struct inode *inode, struct file *filp)
59747 {
59748 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59749 + return -EPERM;
59750 +#endif
59751 if (!capable(CAP_SYS_RAWIO))
59752 return -EPERM;
59753 if (kcore_need_update)
59754 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59755 index 5aa847a..f77c8d4 100644
59756 --- a/fs/proc/meminfo.c
59757 +++ b/fs/proc/meminfo.c
59758 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59759 vmi.used >> 10,
59760 vmi.largest_chunk >> 10
59761 #ifdef CONFIG_MEMORY_FAILURE
59762 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59763 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59764 #endif
59765 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59766 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59767 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59768 index ccfd99b..1b7e255 100644
59769 --- a/fs/proc/nommu.c
59770 +++ b/fs/proc/nommu.c
59771 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59772 if (len < 1)
59773 len = 1;
59774 seq_printf(m, "%*c", len, ' ');
59775 - seq_path(m, &file->f_path, "");
59776 + seq_path(m, &file->f_path, "\n\\");
59777 }
59778
59779 seq_putc(m, '\n');
59780 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59781 index 4677bb7..408e936 100644
59782 --- a/fs/proc/proc_net.c
59783 +++ b/fs/proc/proc_net.c
59784 @@ -23,6 +23,7 @@
59785 #include <linux/nsproxy.h>
59786 #include <net/net_namespace.h>
59787 #include <linux/seq_file.h>
59788 +#include <linux/grsecurity.h>
59789
59790 #include "internal.h"
59791
59792 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59793 struct task_struct *task;
59794 struct nsproxy *ns;
59795 struct net *net = NULL;
59796 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59797 + const struct cred *cred = current_cred();
59798 +#endif
59799 +
59800 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59801 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59802 + return net;
59803 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59804 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59805 + return net;
59806 +#endif
59807
59808 rcu_read_lock();
59809 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59810 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59811 index 7129046..f2779c6 100644
59812 --- a/fs/proc/proc_sysctl.c
59813 +++ b/fs/proc/proc_sysctl.c
59814 @@ -13,11 +13,15 @@
59815 #include <linux/module.h>
59816 #include "internal.h"
59817
59818 +extern int gr_handle_chroot_sysctl(const int op);
59819 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59820 + const int op);
59821 +
59822 static const struct dentry_operations proc_sys_dentry_operations;
59823 static const struct file_operations proc_sys_file_operations;
59824 -static const struct inode_operations proc_sys_inode_operations;
59825 +const struct inode_operations proc_sys_inode_operations;
59826 static const struct file_operations proc_sys_dir_file_operations;
59827 -static const struct inode_operations proc_sys_dir_operations;
59828 +const struct inode_operations proc_sys_dir_operations;
59829
59830 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59831 {
59832 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59833
59834 err = NULL;
59835 d_set_d_op(dentry, &proc_sys_dentry_operations);
59836 +
59837 + gr_handle_proc_create(dentry, inode);
59838 +
59839 d_add(dentry, inode);
59840
59841 out:
59842 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59843 struct inode *inode = file_inode(filp);
59844 struct ctl_table_header *head = grab_header(inode);
59845 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59846 + int op = write ? MAY_WRITE : MAY_READ;
59847 ssize_t error;
59848 size_t res;
59849
59850 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59851 * and won't be until we finish.
59852 */
59853 error = -EPERM;
59854 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59855 + if (sysctl_perm(head, table, op))
59856 goto out;
59857
59858 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59859 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59860 if (!table->proc_handler)
59861 goto out;
59862
59863 +#ifdef CONFIG_GRKERNSEC
59864 + error = -EPERM;
59865 + if (gr_handle_chroot_sysctl(op))
59866 + goto out;
59867 + dget(filp->f_path.dentry);
59868 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59869 + dput(filp->f_path.dentry);
59870 + goto out;
59871 + }
59872 + dput(filp->f_path.dentry);
59873 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59874 + goto out;
59875 + if (write && !capable(CAP_SYS_ADMIN))
59876 + goto out;
59877 +#endif
59878 +
59879 /* careful: calling conventions are nasty here */
59880 res = count;
59881 error = table->proc_handler(table, write, buf, &res, ppos);
59882 @@ -598,6 +622,9 @@ static bool proc_sys_fill_cache(struct file *file,
59883 return false;
59884 } else {
59885 d_set_d_op(child, &proc_sys_dentry_operations);
59886 +
59887 + gr_handle_proc_create(child, inode);
59888 +
59889 d_add(child, inode);
59890 }
59891 } else {
59892 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59893 if ((*pos)++ < ctx->pos)
59894 return true;
59895
59896 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59897 + return 0;
59898 +
59899 if (unlikely(S_ISLNK(table->mode)))
59900 res = proc_sys_link_fill_cache(file, ctx, head, table);
59901 else
59902 @@ -734,6 +764,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59903 if (IS_ERR(head))
59904 return PTR_ERR(head);
59905
59906 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59907 + return -ENOENT;
59908 +
59909 generic_fillattr(inode, stat);
59910 if (table)
59911 stat->mode = (stat->mode & S_IFMT) | table->mode;
59912 @@ -756,13 +789,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59913 .llseek = generic_file_llseek,
59914 };
59915
59916 -static const struct inode_operations proc_sys_inode_operations = {
59917 +const struct inode_operations proc_sys_inode_operations = {
59918 .permission = proc_sys_permission,
59919 .setattr = proc_sys_setattr,
59920 .getattr = proc_sys_getattr,
59921 };
59922
59923 -static const struct inode_operations proc_sys_dir_operations = {
59924 +const struct inode_operations proc_sys_dir_operations = {
59925 .lookup = proc_sys_lookup,
59926 .permission = proc_sys_permission,
59927 .setattr = proc_sys_setattr,
59928 @@ -839,7 +872,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59929 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59930 const char *name, int namelen)
59931 {
59932 - struct ctl_table *table;
59933 + ctl_table_no_const *table;
59934 struct ctl_dir *new;
59935 struct ctl_node *node;
59936 char *new_name;
59937 @@ -851,7 +884,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59938 return NULL;
59939
59940 node = (struct ctl_node *)(new + 1);
59941 - table = (struct ctl_table *)(node + 1);
59942 + table = (ctl_table_no_const *)(node + 1);
59943 new_name = (char *)(table + 2);
59944 memcpy(new_name, name, namelen);
59945 new_name[namelen] = '\0';
59946 @@ -1020,7 +1053,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59947 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59948 struct ctl_table_root *link_root)
59949 {
59950 - struct ctl_table *link_table, *entry, *link;
59951 + ctl_table_no_const *link_table, *link;
59952 + struct ctl_table *entry;
59953 struct ctl_table_header *links;
59954 struct ctl_node *node;
59955 char *link_name;
59956 @@ -1043,7 +1077,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59957 return NULL;
59958
59959 node = (struct ctl_node *)(links + 1);
59960 - link_table = (struct ctl_table *)(node + nr_entries);
59961 + link_table = (ctl_table_no_const *)(node + nr_entries);
59962 link_name = (char *)&link_table[nr_entries + 1];
59963
59964 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59965 @@ -1291,8 +1325,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59966 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59967 struct ctl_table *table)
59968 {
59969 - struct ctl_table *ctl_table_arg = NULL;
59970 - struct ctl_table *entry, *files;
59971 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59972 + struct ctl_table *entry;
59973 int nr_files = 0;
59974 int nr_dirs = 0;
59975 int err = -ENOMEM;
59976 @@ -1304,10 +1338,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59977 nr_files++;
59978 }
59979
59980 - files = table;
59981 /* If there are mixed files and directories we need a new table */
59982 if (nr_dirs && nr_files) {
59983 - struct ctl_table *new;
59984 + ctl_table_no_const *new;
59985 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59986 GFP_KERNEL);
59987 if (!files)
59988 @@ -1325,7 +1358,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59989 /* Register everything except a directory full of subdirectories */
59990 if (nr_files || !nr_dirs) {
59991 struct ctl_table_header *header;
59992 - header = __register_sysctl_table(set, path, files);
59993 + header = __register_sysctl_table(set, path, files ? files : table);
59994 if (!header) {
59995 kfree(ctl_table_arg);
59996 goto out;
59997 diff --git a/fs/proc/root.c b/fs/proc/root.c
59998 index 0e0e83c..005ba6a 100644
59999 --- a/fs/proc/root.c
60000 +++ b/fs/proc/root.c
60001 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
60002 #ifdef CONFIG_PROC_DEVICETREE
60003 proc_device_tree_init();
60004 #endif
60005 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60006 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60007 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
60008 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60009 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
60010 +#endif
60011 +#else
60012 proc_mkdir("bus", NULL);
60013 +#endif
60014 proc_sys_init();
60015 }
60016
60017 diff --git a/fs/proc/self.c b/fs/proc/self.c
60018 index 6b6a993..807cccc 100644
60019 --- a/fs/proc/self.c
60020 +++ b/fs/proc/self.c
60021 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
60022 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
60023 void *cookie)
60024 {
60025 - char *s = nd_get_link(nd);
60026 + const char *s = nd_get_link(nd);
60027 if (!IS_ERR(s))
60028 kfree(s);
60029 }
60030 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
60031 index 107d026..c715aeb 100644
60032 --- a/fs/proc/task_mmu.c
60033 +++ b/fs/proc/task_mmu.c
60034 @@ -12,12 +12,19 @@
60035 #include <linux/swap.h>
60036 #include <linux/swapops.h>
60037 #include <linux/mmu_notifier.h>
60038 +#include <linux/grsecurity.h>
60039
60040 #include <asm/elf.h>
60041 #include <asm/uaccess.h>
60042 #include <asm/tlbflush.h>
60043 #include "internal.h"
60044
60045 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60046 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60047 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60048 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60049 +#endif
60050 +
60051 void task_mem(struct seq_file *m, struct mm_struct *mm)
60052 {
60053 unsigned long data, text, lib, swap;
60054 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60055 "VmExe:\t%8lu kB\n"
60056 "VmLib:\t%8lu kB\n"
60057 "VmPTE:\t%8lu kB\n"
60058 - "VmSwap:\t%8lu kB\n",
60059 - hiwater_vm << (PAGE_SHIFT-10),
60060 + "VmSwap:\t%8lu kB\n"
60061 +
60062 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60063 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60064 +#endif
60065 +
60066 + ,hiwater_vm << (PAGE_SHIFT-10),
60067 total_vm << (PAGE_SHIFT-10),
60068 mm->locked_vm << (PAGE_SHIFT-10),
60069 mm->pinned_vm << (PAGE_SHIFT-10),
60070 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60071 data << (PAGE_SHIFT-10),
60072 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60073 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60074 - swap << (PAGE_SHIFT-10));
60075 + swap << (PAGE_SHIFT-10)
60076 +
60077 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60078 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60079 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60080 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60081 +#else
60082 + , mm->context.user_cs_base
60083 + , mm->context.user_cs_limit
60084 +#endif
60085 +#endif
60086 +
60087 + );
60088 }
60089
60090 unsigned long task_vsize(struct mm_struct *mm)
60091 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60092 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60093 }
60094
60095 - /* We don't show the stack guard page in /proc/maps */
60096 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60097 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60098 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60099 +#else
60100 start = vma->vm_start;
60101 - if (stack_guard_page_start(vma, start))
60102 - start += PAGE_SIZE;
60103 end = vma->vm_end;
60104 - if (stack_guard_page_end(vma, end))
60105 - end -= PAGE_SIZE;
60106 +#endif
60107
60108 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60109 start,
60110 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60111 flags & VM_WRITE ? 'w' : '-',
60112 flags & VM_EXEC ? 'x' : '-',
60113 flags & VM_MAYSHARE ? 's' : 'p',
60114 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60115 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60116 +#else
60117 pgoff,
60118 +#endif
60119 MAJOR(dev), MINOR(dev), ino, &len);
60120
60121 /*
60122 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60123 */
60124 if (file) {
60125 pad_len_spaces(m, len);
60126 - seq_path(m, &file->f_path, "\n");
60127 + seq_path(m, &file->f_path, "\n\\");
60128 goto done;
60129 }
60130
60131 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60132 * Thread stack in /proc/PID/task/TID/maps or
60133 * the main process stack.
60134 */
60135 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60136 - vma->vm_end >= mm->start_stack)) {
60137 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60138 + (vma->vm_start <= mm->start_stack &&
60139 + vma->vm_end >= mm->start_stack)) {
60140 name = "[stack]";
60141 } else {
60142 /* Thread stack in /proc/PID/maps */
60143 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60144 struct proc_maps_private *priv = m->private;
60145 struct task_struct *task = priv->task;
60146
60147 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60148 + if (current->exec_id != m->exec_id) {
60149 + gr_log_badprocpid("maps");
60150 + return 0;
60151 + }
60152 +#endif
60153 +
60154 show_map_vma(m, vma, is_pid);
60155
60156 if (m->count < m->size) /* vma is copied successfully */
60157 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60158 .private = &mss,
60159 };
60160
60161 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60162 + if (current->exec_id != m->exec_id) {
60163 + gr_log_badprocpid("smaps");
60164 + return 0;
60165 + }
60166 +#endif
60167 memset(&mss, 0, sizeof mss);
60168 - mss.vma = vma;
60169 - /* mmap_sem is held in m_start */
60170 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60171 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60172 -
60173 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60174 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60175 +#endif
60176 + mss.vma = vma;
60177 + /* mmap_sem is held in m_start */
60178 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60179 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60180 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60181 + }
60182 +#endif
60183 show_map_vma(m, vma, is_pid);
60184
60185 seq_printf(m,
60186 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60187 "KernelPageSize: %8lu kB\n"
60188 "MMUPageSize: %8lu kB\n"
60189 "Locked: %8lu kB\n",
60190 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60191 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60192 +#else
60193 (vma->vm_end - vma->vm_start) >> 10,
60194 +#endif
60195 mss.resident >> 10,
60196 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60197 mss.shared_clean >> 10,
60198 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60199 int n;
60200 char buffer[50];
60201
60202 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60203 + if (current->exec_id != m->exec_id) {
60204 + gr_log_badprocpid("numa_maps");
60205 + return 0;
60206 + }
60207 +#endif
60208 +
60209 if (!mm)
60210 return 0;
60211
60212 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60213 mpol_to_str(buffer, sizeof(buffer), pol);
60214 mpol_cond_put(pol);
60215
60216 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60217 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60218 +#else
60219 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60220 +#endif
60221
60222 if (file) {
60223 seq_printf(m, " file=");
60224 - seq_path(m, &file->f_path, "\n\t= ");
60225 + seq_path(m, &file->f_path, "\n\t\\= ");
60226 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60227 seq_printf(m, " heap");
60228 } else {
60229 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60230 index 56123a6..5a2f6ec 100644
60231 --- a/fs/proc/task_nommu.c
60232 +++ b/fs/proc/task_nommu.c
60233 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60234 else
60235 bytes += kobjsize(mm);
60236
60237 - if (current->fs && current->fs->users > 1)
60238 + if (current->fs && atomic_read(&current->fs->users) > 1)
60239 sbytes += kobjsize(current->fs);
60240 else
60241 bytes += kobjsize(current->fs);
60242 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60243
60244 if (file) {
60245 pad_len_spaces(m, len);
60246 - seq_path(m, &file->f_path, "");
60247 + seq_path(m, &file->f_path, "\n\\");
60248 } else if (mm) {
60249 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60250
60251 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60252 index a1a16eb..6be46ed 100644
60253 --- a/fs/proc/vmcore.c
60254 +++ b/fs/proc/vmcore.c
60255 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60256 nr_bytes = count;
60257
60258 /* If pfn is not ram, return zeros for sparse dump files */
60259 - if (pfn_is_ram(pfn) == 0)
60260 - memset(buf, 0, nr_bytes);
60261 - else {
60262 + if (pfn_is_ram(pfn) == 0) {
60263 + if (userbuf) {
60264 + if (clear_user((char __force_user *)buf, nr_bytes))
60265 + return -EFAULT;
60266 + } else
60267 + memset(buf, 0, nr_bytes);
60268 + } else {
60269 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60270 offset, userbuf);
60271 if (tmp < 0)
60272 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60273 if (*fpos < m->offset + m->size) {
60274 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60275 start = m->paddr + *fpos - m->offset;
60276 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60277 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60278 if (tmp < 0)
60279 return tmp;
60280 buflen -= tsz;
60281 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60282 index b00fcc9..e0c6381 100644
60283 --- a/fs/qnx6/qnx6.h
60284 +++ b/fs/qnx6/qnx6.h
60285 @@ -74,7 +74,7 @@ enum {
60286 BYTESEX_BE,
60287 };
60288
60289 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60290 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60291 {
60292 if (sbi->s_bytesex == BYTESEX_LE)
60293 return le64_to_cpu((__force __le64)n);
60294 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60295 return (__force __fs64)cpu_to_be64(n);
60296 }
60297
60298 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60299 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60300 {
60301 if (sbi->s_bytesex == BYTESEX_LE)
60302 return le32_to_cpu((__force __le32)n);
60303 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60304 index 16e8abb..2dcf914 100644
60305 --- a/fs/quota/netlink.c
60306 +++ b/fs/quota/netlink.c
60307 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60308 void quota_send_warning(struct kqid qid, dev_t dev,
60309 const char warntype)
60310 {
60311 - static atomic_t seq;
60312 + static atomic_unchecked_t seq;
60313 struct sk_buff *skb;
60314 void *msg_head;
60315 int ret;
60316 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60317 "VFS: Not enough memory to send quota warning.\n");
60318 return;
60319 }
60320 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60321 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60322 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60323 if (!msg_head) {
60324 printk(KERN_ERR
60325 diff --git a/fs/read_write.c b/fs/read_write.c
60326 index 122a384..0b7ecf2 100644
60327 --- a/fs/read_write.c
60328 +++ b/fs/read_write.c
60329 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60330
60331 old_fs = get_fs();
60332 set_fs(get_ds());
60333 - p = (__force const char __user *)buf;
60334 + p = (const char __force_user *)buf;
60335 if (count > MAX_RW_COUNT)
60336 count = MAX_RW_COUNT;
60337 if (file->f_op->write)
60338 diff --git a/fs/readdir.c b/fs/readdir.c
60339 index 93d71e5..6a14be8 100644
60340 --- a/fs/readdir.c
60341 +++ b/fs/readdir.c
60342 @@ -17,6 +17,7 @@
60343 #include <linux/security.h>
60344 #include <linux/syscalls.h>
60345 #include <linux/unistd.h>
60346 +#include <linux/namei.h>
60347
60348 #include <asm/uaccess.h>
60349
60350 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60351 struct readdir_callback {
60352 struct dir_context ctx;
60353 struct old_linux_dirent __user * dirent;
60354 + struct file * file;
60355 int result;
60356 };
60357
60358 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60359 buf->result = -EOVERFLOW;
60360 return -EOVERFLOW;
60361 }
60362 +
60363 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60364 + return 0;
60365 +
60366 buf->result++;
60367 dirent = buf->dirent;
60368 if (!access_ok(VERIFY_WRITE, dirent,
60369 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60370 if (!f.file)
60371 return -EBADF;
60372
60373 + buf.file = f.file;
60374 error = iterate_dir(f.file, &buf.ctx);
60375 if (buf.result)
60376 error = buf.result;
60377 @@ -142,6 +149,7 @@ struct getdents_callback {
60378 struct dir_context ctx;
60379 struct linux_dirent __user * current_dir;
60380 struct linux_dirent __user * previous;
60381 + struct file * file;
60382 int count;
60383 int error;
60384 };
60385 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60386 buf->error = -EOVERFLOW;
60387 return -EOVERFLOW;
60388 }
60389 +
60390 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60391 + return 0;
60392 +
60393 dirent = buf->previous;
60394 if (dirent) {
60395 if (__put_user(offset, &dirent->d_off))
60396 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60397 if (!f.file)
60398 return -EBADF;
60399
60400 + buf.file = f.file;
60401 error = iterate_dir(f.file, &buf.ctx);
60402 if (error >= 0)
60403 error = buf.error;
60404 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60405 struct dir_context ctx;
60406 struct linux_dirent64 __user * current_dir;
60407 struct linux_dirent64 __user * previous;
60408 + struct file *file;
60409 int count;
60410 int error;
60411 };
60412 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60413 buf->error = -EINVAL; /* only used if we fail.. */
60414 if (reclen > buf->count)
60415 return -EINVAL;
60416 +
60417 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60418 + return 0;
60419 +
60420 dirent = buf->previous;
60421 if (dirent) {
60422 if (__put_user(offset, &dirent->d_off))
60423 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60424 if (!f.file)
60425 return -EBADF;
60426
60427 + buf.file = f.file;
60428 error = iterate_dir(f.file, &buf.ctx);
60429 if (error >= 0)
60430 error = buf.error;
60431 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60432 index 2b7882b..1c5ef48 100644
60433 --- a/fs/reiserfs/do_balan.c
60434 +++ b/fs/reiserfs/do_balan.c
60435 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60436 return;
60437 }
60438
60439 - atomic_inc(&(fs_generation(tb->tb_sb)));
60440 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60441 do_balance_starts(tb);
60442
60443 /* balance leaf returns 0 except if combining L R and S into
60444 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60445 index a958444..42b2323 100644
60446 --- a/fs/reiserfs/procfs.c
60447 +++ b/fs/reiserfs/procfs.c
60448 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60449 "SMALL_TAILS " : "NO_TAILS ",
60450 replay_only(sb) ? "REPLAY_ONLY " : "",
60451 convert_reiserfs(sb) ? "CONV " : "",
60452 - atomic_read(&r->s_generation_counter),
60453 + atomic_read_unchecked(&r->s_generation_counter),
60454 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60455 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60456 SF(s_good_search_by_key_reada), SF(s_bmaps),
60457 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60458 index 3df5ce6..8c0f4b0 100644
60459 --- a/fs/reiserfs/reiserfs.h
60460 +++ b/fs/reiserfs/reiserfs.h
60461 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60462 /* Comment? -Hans */
60463 wait_queue_head_t s_wait;
60464 /* To be obsoleted soon by per buffer seals.. -Hans */
60465 - atomic_t s_generation_counter; // increased by one every time the
60466 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60467 // tree gets re-balanced
60468 unsigned long s_properties; /* File system properties. Currently holds
60469 on-disk FS format */
60470 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60471 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60472
60473 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60474 -#define get_generation(s) atomic_read (&fs_generation(s))
60475 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60476 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60477 #define __fs_changed(gen,s) (gen != get_generation (s))
60478 #define fs_changed(gen,s) \
60479 diff --git a/fs/select.c b/fs/select.c
60480 index 35d4adc7..d6c60db 100644
60481 --- a/fs/select.c
60482 +++ b/fs/select.c
60483 @@ -20,6 +20,7 @@
60484 #include <linux/export.h>
60485 #include <linux/slab.h>
60486 #include <linux/poll.h>
60487 +#include <linux/security.h>
60488 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60489 #include <linux/file.h>
60490 #include <linux/fdtable.h>
60491 @@ -881,6 +882,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60492 struct poll_list *walk = head;
60493 unsigned long todo = nfds;
60494
60495 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60496 if (nfds > rlimit(RLIMIT_NOFILE))
60497 return -EINVAL;
60498
60499 diff --git a/fs/seq_file.c b/fs/seq_file.c
60500 index 3135c25..d0395dd 100644
60501 --- a/fs/seq_file.c
60502 +++ b/fs/seq_file.c
60503 @@ -10,6 +10,7 @@
60504 #include <linux/seq_file.h>
60505 #include <linux/slab.h>
60506 #include <linux/cred.h>
60507 +#include <linux/sched.h>
60508
60509 #include <asm/uaccess.h>
60510 #include <asm/page.h>
60511 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60512 #ifdef CONFIG_USER_NS
60513 p->user_ns = file->f_cred->user_ns;
60514 #endif
60515 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60516 + p->exec_id = current->exec_id;
60517 +#endif
60518
60519 /*
60520 * Wrappers around seq_open(e.g. swaps_open) need to be
60521 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60522 return 0;
60523 }
60524 if (!m->buf) {
60525 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60526 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60527 if (!m->buf)
60528 return -ENOMEM;
60529 }
60530 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60531 Eoverflow:
60532 m->op->stop(m, p);
60533 kfree(m->buf);
60534 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60535 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60536 return !m->buf ? -ENOMEM : -EAGAIN;
60537 }
60538
60539 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60540
60541 /* grab buffer if we didn't have one */
60542 if (!m->buf) {
60543 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60544 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60545 if (!m->buf)
60546 goto Enomem;
60547 }
60548 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60549 goto Fill;
60550 m->op->stop(m, p);
60551 kfree(m->buf);
60552 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60553 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60554 if (!m->buf)
60555 goto Enomem;
60556 m->count = 0;
60557 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
60558 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60559 void *data)
60560 {
60561 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60562 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60563 int res = -ENOMEM;
60564
60565 if (op) {
60566 diff --git a/fs/splice.c b/fs/splice.c
60567 index 3b7ee65..87fc2e4 100644
60568 --- a/fs/splice.c
60569 +++ b/fs/splice.c
60570 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60571 pipe_lock(pipe);
60572
60573 for (;;) {
60574 - if (!pipe->readers) {
60575 + if (!atomic_read(&pipe->readers)) {
60576 send_sig(SIGPIPE, current, 0);
60577 if (!ret)
60578 ret = -EPIPE;
60579 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60580 page_nr++;
60581 ret += buf->len;
60582
60583 - if (pipe->files)
60584 + if (atomic_read(&pipe->files))
60585 do_wakeup = 1;
60586
60587 if (!--spd->nr_pages)
60588 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60589 do_wakeup = 0;
60590 }
60591
60592 - pipe->waiting_writers++;
60593 + atomic_inc(&pipe->waiting_writers);
60594 pipe_wait(pipe);
60595 - pipe->waiting_writers--;
60596 + atomic_dec(&pipe->waiting_writers);
60597 }
60598
60599 pipe_unlock(pipe);
60600 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60601 old_fs = get_fs();
60602 set_fs(get_ds());
60603 /* The cast to a user pointer is valid due to the set_fs() */
60604 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60605 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60606 set_fs(old_fs);
60607
60608 return res;
60609 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60610 old_fs = get_fs();
60611 set_fs(get_ds());
60612 /* The cast to a user pointer is valid due to the set_fs() */
60613 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60614 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60615 set_fs(old_fs);
60616
60617 return res;
60618 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60619 goto err;
60620
60621 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60622 - vec[i].iov_base = (void __user *) page_address(page);
60623 + vec[i].iov_base = (void __force_user *) page_address(page);
60624 vec[i].iov_len = this_len;
60625 spd.pages[i] = page;
60626 spd.nr_pages++;
60627 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60628 ops->release(pipe, buf);
60629 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60630 pipe->nrbufs--;
60631 - if (pipe->files)
60632 + if (atomic_read(&pipe->files))
60633 sd->need_wakeup = true;
60634 }
60635
60636 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60637 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60638 {
60639 while (!pipe->nrbufs) {
60640 - if (!pipe->writers)
60641 + if (!atomic_read(&pipe->writers))
60642 return 0;
60643
60644 - if (!pipe->waiting_writers && sd->num_spliced)
60645 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60646 return 0;
60647
60648 if (sd->flags & SPLICE_F_NONBLOCK)
60649 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60650 * out of the pipe right after the splice_to_pipe(). So set
60651 * PIPE_READERS appropriately.
60652 */
60653 - pipe->readers = 1;
60654 + atomic_set(&pipe->readers, 1);
60655
60656 current->splice_pipe = pipe;
60657 }
60658 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60659
60660 partial[buffers].offset = off;
60661 partial[buffers].len = plen;
60662 + partial[buffers].private = 0;
60663
60664 off = 0;
60665 len -= plen;
60666 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60667 ret = -ERESTARTSYS;
60668 break;
60669 }
60670 - if (!pipe->writers)
60671 + if (!atomic_read(&pipe->writers))
60672 break;
60673 - if (!pipe->waiting_writers) {
60674 + if (!atomic_read(&pipe->waiting_writers)) {
60675 if (flags & SPLICE_F_NONBLOCK) {
60676 ret = -EAGAIN;
60677 break;
60678 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60679 pipe_lock(pipe);
60680
60681 while (pipe->nrbufs >= pipe->buffers) {
60682 - if (!pipe->readers) {
60683 + if (!atomic_read(&pipe->readers)) {
60684 send_sig(SIGPIPE, current, 0);
60685 ret = -EPIPE;
60686 break;
60687 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60688 ret = -ERESTARTSYS;
60689 break;
60690 }
60691 - pipe->waiting_writers++;
60692 + atomic_inc(&pipe->waiting_writers);
60693 pipe_wait(pipe);
60694 - pipe->waiting_writers--;
60695 + atomic_dec(&pipe->waiting_writers);
60696 }
60697
60698 pipe_unlock(pipe);
60699 @@ -1862,14 +1863,14 @@ retry:
60700 pipe_double_lock(ipipe, opipe);
60701
60702 do {
60703 - if (!opipe->readers) {
60704 + if (!atomic_read(&opipe->readers)) {
60705 send_sig(SIGPIPE, current, 0);
60706 if (!ret)
60707 ret = -EPIPE;
60708 break;
60709 }
60710
60711 - if (!ipipe->nrbufs && !ipipe->writers)
60712 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60713 break;
60714
60715 /*
60716 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60717 pipe_double_lock(ipipe, opipe);
60718
60719 do {
60720 - if (!opipe->readers) {
60721 + if (!atomic_read(&opipe->readers)) {
60722 send_sig(SIGPIPE, current, 0);
60723 if (!ret)
60724 ret = -EPIPE;
60725 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60726 * return EAGAIN if we have the potential of some data in the
60727 * future, otherwise just return 0
60728 */
60729 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60730 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60731 ret = -EAGAIN;
60732
60733 pipe_unlock(ipipe);
60734 diff --git a/fs/stat.c b/fs/stat.c
60735 index 04ce1ac..a13dd1e 100644
60736 --- a/fs/stat.c
60737 +++ b/fs/stat.c
60738 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60739 stat->gid = inode->i_gid;
60740 stat->rdev = inode->i_rdev;
60741 stat->size = i_size_read(inode);
60742 - stat->atime = inode->i_atime;
60743 - stat->mtime = inode->i_mtime;
60744 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60745 + stat->atime = inode->i_ctime;
60746 + stat->mtime = inode->i_ctime;
60747 + } else {
60748 + stat->atime = inode->i_atime;
60749 + stat->mtime = inode->i_mtime;
60750 + }
60751 stat->ctime = inode->i_ctime;
60752 stat->blksize = (1 << inode->i_blkbits);
60753 stat->blocks = inode->i_blocks;
60754 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60755 if (retval)
60756 return retval;
60757
60758 - if (inode->i_op->getattr)
60759 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60760 + if (inode->i_op->getattr) {
60761 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60762 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60763 + stat->atime = stat->ctime;
60764 + stat->mtime = stat->ctime;
60765 + }
60766 + return retval;
60767 + }
60768
60769 generic_fillattr(inode, stat);
60770 return 0;
60771 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60772 index 15c68f9..36a8b3e 100644
60773 --- a/fs/sysfs/bin.c
60774 +++ b/fs/sysfs/bin.c
60775 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60776 return ret;
60777 }
60778
60779 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60780 - void *buf, int len, int write)
60781 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60782 + void *buf, size_t len, int write)
60783 {
60784 struct file *file = vma->vm_file;
60785 struct bin_buffer *bb = file->private_data;
60786 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60787 - int ret;
60788 + ssize_t ret;
60789
60790 if (!bb->vm_ops)
60791 return -EINVAL;
60792 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60793 index e068e74..92edeb8 100644
60794 --- a/fs/sysfs/dir.c
60795 +++ b/fs/sysfs/dir.c
60796 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60797 *
60798 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60799 */
60800 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60801 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60802 {
60803 unsigned long hash = init_name_hash();
60804 unsigned int len = strlen(name);
60805 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60806 struct sysfs_dirent *sd;
60807 int rc;
60808
60809 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60810 + const char *parent_name = parent_sd->s_name;
60811 +
60812 + mode = S_IFDIR | S_IRWXU;
60813 +
60814 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60815 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60816 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60817 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60818 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60819 +#endif
60820 +
60821 /* allocate */
60822 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60823 if (!sd)
60824 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60825 index d2bb7ed..fe8c331 100644
60826 --- a/fs/sysfs/file.c
60827 +++ b/fs/sysfs/file.c
60828 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60829
60830 struct sysfs_open_dirent {
60831 atomic_t refcnt;
60832 - atomic_t event;
60833 + atomic_unchecked_t event;
60834 wait_queue_head_t poll;
60835 struct list_head buffers; /* goes through sysfs_buffer.list */
60836 };
60837 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60838 if (!sysfs_get_active(attr_sd))
60839 return -ENODEV;
60840
60841 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60842 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60843 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60844
60845 sysfs_put_active(attr_sd);
60846 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60847 return -ENOMEM;
60848
60849 atomic_set(&new_od->refcnt, 0);
60850 - atomic_set(&new_od->event, 1);
60851 + atomic_set_unchecked(&new_od->event, 1);
60852 init_waitqueue_head(&new_od->poll);
60853 INIT_LIST_HEAD(&new_od->buffers);
60854 goto retry;
60855 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60856
60857 sysfs_put_active(attr_sd);
60858
60859 - if (buffer->event != atomic_read(&od->event))
60860 + if (buffer->event != atomic_read_unchecked(&od->event))
60861 goto trigger;
60862
60863 return DEFAULT_POLLMASK;
60864 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60865 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60866 od = sd->s_attr.open;
60867 if (od) {
60868 - atomic_inc(&od->event);
60869 + atomic_inc_unchecked(&od->event);
60870 wake_up_interruptible(&od->poll);
60871 }
60872 }
60873 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60874 index 8c940df..25b733e 100644
60875 --- a/fs/sysfs/symlink.c
60876 +++ b/fs/sysfs/symlink.c
60877 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60878
60879 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60880 {
60881 - char *page = nd_get_link(nd);
60882 + const char *page = nd_get_link(nd);
60883 if (!IS_ERR(page))
60884 free_page((unsigned long)page);
60885 }
60886 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60887 index 69d4889..a810bd4 100644
60888 --- a/fs/sysv/sysv.h
60889 +++ b/fs/sysv/sysv.h
60890 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60891 #endif
60892 }
60893
60894 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60895 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60896 {
60897 if (sbi->s_bytesex == BYTESEX_PDP)
60898 return PDP_swab((__force __u32)n);
60899 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60900 index e18b988..f1d4ad0f 100644
60901 --- a/fs/ubifs/io.c
60902 +++ b/fs/ubifs/io.c
60903 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60904 return err;
60905 }
60906
60907 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60908 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60909 {
60910 int err;
60911
60912 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60913 index c175b4d..8f36a16 100644
60914 --- a/fs/udf/misc.c
60915 +++ b/fs/udf/misc.c
60916 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60917
60918 u8 udf_tag_checksum(const struct tag *t)
60919 {
60920 - u8 *data = (u8 *)t;
60921 + const u8 *data = (const u8 *)t;
60922 u8 checksum = 0;
60923 int i;
60924 for (i = 0; i < sizeof(struct tag); ++i)
60925 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60926 index 8d974c4..b82f6ec 100644
60927 --- a/fs/ufs/swab.h
60928 +++ b/fs/ufs/swab.h
60929 @@ -22,7 +22,7 @@ enum {
60930 BYTESEX_BE
60931 };
60932
60933 -static inline u64
60934 +static inline u64 __intentional_overflow(-1)
60935 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60936 {
60937 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60938 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60939 return (__force __fs64)cpu_to_be64(n);
60940 }
60941
60942 -static inline u32
60943 +static inline u32 __intentional_overflow(-1)
60944 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60945 {
60946 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60947 diff --git a/fs/utimes.c b/fs/utimes.c
60948 index f4fb7ec..3fe03c0 100644
60949 --- a/fs/utimes.c
60950 +++ b/fs/utimes.c
60951 @@ -1,6 +1,7 @@
60952 #include <linux/compiler.h>
60953 #include <linux/file.h>
60954 #include <linux/fs.h>
60955 +#include <linux/security.h>
60956 #include <linux/linkage.h>
60957 #include <linux/mount.h>
60958 #include <linux/namei.h>
60959 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60960 goto mnt_drop_write_and_out;
60961 }
60962 }
60963 +
60964 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60965 + error = -EACCES;
60966 + goto mnt_drop_write_and_out;
60967 + }
60968 +
60969 mutex_lock(&inode->i_mutex);
60970 error = notify_change(path->dentry, &newattrs);
60971 mutex_unlock(&inode->i_mutex);
60972 diff --git a/fs/xattr.c b/fs/xattr.c
60973 index 3377dff..4d074d9 100644
60974 --- a/fs/xattr.c
60975 +++ b/fs/xattr.c
60976 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60977 return rc;
60978 }
60979
60980 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60981 +ssize_t
60982 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60983 +{
60984 + struct inode *inode = dentry->d_inode;
60985 + ssize_t error;
60986 +
60987 + error = inode_permission(inode, MAY_EXEC);
60988 + if (error)
60989 + return error;
60990 +
60991 + if (inode->i_op->getxattr)
60992 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60993 + else
60994 + error = -EOPNOTSUPP;
60995 +
60996 + return error;
60997 +}
60998 +EXPORT_SYMBOL(pax_getxattr);
60999 +#endif
61000 +
61001 ssize_t
61002 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
61003 {
61004 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
61005 * Extended attribute SET operations
61006 */
61007 static long
61008 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
61009 +setxattr(struct path *path, const char __user *name, const void __user *value,
61010 size_t size, int flags)
61011 {
61012 int error;
61013 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
61014 posix_acl_fix_xattr_from_user(kvalue, size);
61015 }
61016
61017 - error = vfs_setxattr(d, kname, kvalue, size, flags);
61018 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
61019 + error = -EACCES;
61020 + goto out;
61021 + }
61022 +
61023 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
61024 out:
61025 if (vvalue)
61026 vfree(vvalue);
61027 @@ -377,7 +403,7 @@ retry:
61028 return error;
61029 error = mnt_want_write(path.mnt);
61030 if (!error) {
61031 - error = setxattr(path.dentry, name, value, size, flags);
61032 + error = setxattr(&path, name, value, size, flags);
61033 mnt_drop_write(path.mnt);
61034 }
61035 path_put(&path);
61036 @@ -401,7 +427,7 @@ retry:
61037 return error;
61038 error = mnt_want_write(path.mnt);
61039 if (!error) {
61040 - error = setxattr(path.dentry, name, value, size, flags);
61041 + error = setxattr(&path, name, value, size, flags);
61042 mnt_drop_write(path.mnt);
61043 }
61044 path_put(&path);
61045 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
61046 const void __user *,value, size_t, size, int, flags)
61047 {
61048 struct fd f = fdget(fd);
61049 - struct dentry *dentry;
61050 int error = -EBADF;
61051
61052 if (!f.file)
61053 return error;
61054 - dentry = f.file->f_path.dentry;
61055 - audit_inode(NULL, dentry, 0);
61056 + audit_inode(NULL, f.file->f_path.dentry, 0);
61057 error = mnt_want_write_file(f.file);
61058 if (!error) {
61059 - error = setxattr(dentry, name, value, size, flags);
61060 + error = setxattr(&f.file->f_path, name, value, size, flags);
61061 mnt_drop_write_file(f.file);
61062 }
61063 fdput(f);
61064 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61065 index 9fbea87..6b19972 100644
61066 --- a/fs/xattr_acl.c
61067 +++ b/fs/xattr_acl.c
61068 @@ -76,8 +76,8 @@ struct posix_acl *
61069 posix_acl_from_xattr(struct user_namespace *user_ns,
61070 const void *value, size_t size)
61071 {
61072 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61073 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61074 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61075 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61076 int count;
61077 struct posix_acl *acl;
61078 struct posix_acl_entry *acl_e;
61079 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61080 index 05c698c..6b918af 100644
61081 --- a/fs/xfs/xfs_bmap.c
61082 +++ b/fs/xfs/xfs_bmap.c
61083 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
61084
61085 #else
61086 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61087 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61088 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61089 #endif /* DEBUG */
61090
61091 /*
61092 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
61093 index 97676a3..399a75d 100644
61094 --- a/fs/xfs/xfs_dir2_sf.c
61095 +++ b/fs/xfs/xfs_dir2_sf.c
61096 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61097
61098 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61099 ctx->pos = off & 0x7fffffff;
61100 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61101 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61102 + char name[sfep->namelen];
61103 + memcpy(name, sfep->name, sfep->namelen);
61104 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61105 + return 0;
61106 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61107 ino, DT_UNKNOWN))
61108 return 0;
61109 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61110 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61111 index 6e2bca5..6ce80d3 100644
61112 --- a/fs/xfs/xfs_ioctl.c
61113 +++ b/fs/xfs/xfs_ioctl.c
61114 @@ -127,7 +127,7 @@ xfs_find_handle(
61115 }
61116
61117 error = -EFAULT;
61118 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61119 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61120 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61121 goto out_put;
61122
61123 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61124 index 96dda62..d6c6a52 100644
61125 --- a/fs/xfs/xfs_iops.c
61126 +++ b/fs/xfs/xfs_iops.c
61127 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61128 struct nameidata *nd,
61129 void *p)
61130 {
61131 - char *s = nd_get_link(nd);
61132 + const char *s = nd_get_link(nd);
61133
61134 if (!IS_ERR(s))
61135 kfree(s);
61136 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61137 new file mode 100644
61138 index 0000000..0fd7c82
61139 --- /dev/null
61140 +++ b/grsecurity/Kconfig
61141 @@ -0,0 +1,1080 @@
61142 +#
61143 +# grecurity configuration
61144 +#
61145 +menu "Memory Protections"
61146 +depends on GRKERNSEC
61147 +
61148 +config GRKERNSEC_KMEM
61149 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61150 + default y if GRKERNSEC_CONFIG_AUTO
61151 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61152 + help
61153 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61154 + be written to or read from to modify or leak the contents of the running
61155 + kernel. /dev/port will also not be allowed to be opened and support
61156 + for /dev/cpu/*/msr will be removed. If you have module
61157 + support disabled, enabling this will close up five ways that are
61158 + currently used to insert malicious code into the running kernel.
61159 +
61160 + Even with all these features enabled, we still highly recommend that
61161 + you use the RBAC system, as it is still possible for an attacker to
61162 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61163 +
61164 + If you are not using XFree86, you may be able to stop this additional
61165 + case by enabling the 'Disable privileged I/O' option. Though nothing
61166 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61167 + but only to video memory, which is the only writing we allow in this
61168 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61169 + not be allowed to mprotect it with PROT_WRITE later.
61170 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61171 + from working.
61172 +
61173 + It is highly recommended that you say Y here if you meet all the
61174 + conditions above.
61175 +
61176 +config GRKERNSEC_VM86
61177 + bool "Restrict VM86 mode"
61178 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61179 + depends on X86_32
61180 +
61181 + help
61182 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61183 + make use of a special execution mode on 32bit x86 processors called
61184 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61185 + video cards and will still work with this option enabled. The purpose
61186 + of the option is to prevent exploitation of emulation errors in
61187 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61188 + Nearly all users should be able to enable this option.
61189 +
61190 +config GRKERNSEC_IO
61191 + bool "Disable privileged I/O"
61192 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61193 + depends on X86
61194 + select RTC_CLASS
61195 + select RTC_INTF_DEV
61196 + select RTC_DRV_CMOS
61197 +
61198 + help
61199 + If you say Y here, all ioperm and iopl calls will return an error.
61200 + Ioperm and iopl can be used to modify the running kernel.
61201 + Unfortunately, some programs need this access to operate properly,
61202 + the most notable of which are XFree86 and hwclock. hwclock can be
61203 + remedied by having RTC support in the kernel, so real-time
61204 + clock support is enabled if this option is enabled, to ensure
61205 + that hwclock operates correctly. XFree86 still will not
61206 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61207 + IF YOU USE XFree86. If you use XFree86 and you still want to
61208 + protect your kernel against modification, use the RBAC system.
61209 +
61210 +config GRKERNSEC_JIT_HARDEN
61211 + bool "Harden BPF JIT against spray attacks"
61212 + default y if GRKERNSEC_CONFIG_AUTO
61213 + depends on BPF_JIT
61214 + help
61215 + If you say Y here, the native code generated by the kernel's Berkeley
61216 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61217 + attacks that attempt to fit attacker-beneficial instructions in
61218 + 32bit immediate fields of JIT-generated native instructions. The
61219 + attacker will generally aim to cause an unintended instruction sequence
61220 + of JIT-generated native code to execute by jumping into the middle of
61221 + a generated instruction. This feature effectively randomizes the 32bit
61222 + immediate constants present in the generated code to thwart such attacks.
61223 +
61224 + If you're using KERNEXEC, it's recommended that you enable this option
61225 + to supplement the hardening of the kernel.
61226 +
61227 +config GRKERNSEC_PERF_HARDEN
61228 + bool "Disable unprivileged PERF_EVENTS usage by default"
61229 + default y if GRKERNSEC_CONFIG_AUTO
61230 + depends on PERF_EVENTS
61231 + help
61232 + If you say Y here, the range of acceptable values for the
61233 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61234 + default to a new value: 3. When the sysctl is set to this value, no
61235 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61236 +
61237 + Though PERF_EVENTS can be used legitimately for performance monitoring
61238 + and low-level application profiling, it is forced on regardless of
61239 + configuration, has been at fault for several vulnerabilities, and
61240 + creates new opportunities for side channels and other information leaks.
61241 +
61242 + This feature puts PERF_EVENTS into a secure default state and permits
61243 + the administrator to change out of it temporarily if unprivileged
61244 + application profiling is needed.
61245 +
61246 +config GRKERNSEC_RAND_THREADSTACK
61247 + bool "Insert random gaps between thread stacks"
61248 + default y if GRKERNSEC_CONFIG_AUTO
61249 + depends on PAX_RANDMMAP && !PPC
61250 + help
61251 + If you say Y here, a random-sized gap will be enforced between allocated
61252 + thread stacks. Glibc's NPTL and other threading libraries that
61253 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61254 + The implementation currently provides 8 bits of entropy for the gap.
61255 +
61256 + Many distributions do not compile threaded remote services with the
61257 + -fstack-check argument to GCC, causing the variable-sized stack-based
61258 + allocator, alloca(), to not probe the stack on allocation. This
61259 + permits an unbounded alloca() to skip over any guard page and potentially
61260 + modify another thread's stack reliably. An enforced random gap
61261 + reduces the reliability of such an attack and increases the chance
61262 + that such a read/write to another thread's stack instead lands in
61263 + an unmapped area, causing a crash and triggering grsecurity's
61264 + anti-bruteforcing logic.
61265 +
61266 +config GRKERNSEC_PROC_MEMMAP
61267 + bool "Harden ASLR against information leaks and entropy reduction"
61268 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61269 + depends on PAX_NOEXEC || PAX_ASLR
61270 + help
61271 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61272 + give no information about the addresses of its mappings if
61273 + PaX features that rely on random addresses are enabled on the task.
61274 + In addition to sanitizing this information and disabling other
61275 + dangerous sources of information, this option causes reads of sensitive
61276 + /proc/<pid> entries where the file descriptor was opened in a different
61277 + task than the one performing the read. Such attempts are logged.
61278 + This option also limits argv/env strings for suid/sgid binaries
61279 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61280 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61281 + binaries to prevent alternative mmap layouts from being abused.
61282 +
61283 + If you use PaX it is essential that you say Y here as it closes up
61284 + several holes that make full ASLR useless locally.
61285 +
61286 +config GRKERNSEC_BRUTE
61287 + bool "Deter exploit bruteforcing"
61288 + default y if GRKERNSEC_CONFIG_AUTO
61289 + help
61290 + If you say Y here, attempts to bruteforce exploits against forking
61291 + daemons such as apache or sshd, as well as against suid/sgid binaries
61292 + will be deterred. When a child of a forking daemon is killed by PaX
61293 + or crashes due to an illegal instruction or other suspicious signal,
61294 + the parent process will be delayed 30 seconds upon every subsequent
61295 + fork until the administrator is able to assess the situation and
61296 + restart the daemon.
61297 + In the suid/sgid case, the attempt is logged, the user has all their
61298 + existing instances of the suid/sgid binary terminated and will
61299 + be unable to execute any suid/sgid binaries for 15 minutes.
61300 +
61301 + It is recommended that you also enable signal logging in the auditing
61302 + section so that logs are generated when a process triggers a suspicious
61303 + signal.
61304 + If the sysctl option is enabled, a sysctl option with name
61305 + "deter_bruteforce" is created.
61306 +
61307 +
61308 +config GRKERNSEC_MODHARDEN
61309 + bool "Harden module auto-loading"
61310 + default y if GRKERNSEC_CONFIG_AUTO
61311 + depends on MODULES
61312 + help
61313 + If you say Y here, module auto-loading in response to use of some
61314 + feature implemented by an unloaded module will be restricted to
61315 + root users. Enabling this option helps defend against attacks
61316 + by unprivileged users who abuse the auto-loading behavior to
61317 + cause a vulnerable module to load that is then exploited.
61318 +
61319 + If this option prevents a legitimate use of auto-loading for a
61320 + non-root user, the administrator can execute modprobe manually
61321 + with the exact name of the module mentioned in the alert log.
61322 + Alternatively, the administrator can add the module to the list
61323 + of modules loaded at boot by modifying init scripts.
61324 +
61325 + Modification of init scripts will most likely be needed on
61326 + Ubuntu servers with encrypted home directory support enabled,
61327 + as the first non-root user logging in will cause the ecb(aes),
61328 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61329 +
61330 +config GRKERNSEC_HIDESYM
61331 + bool "Hide kernel symbols"
61332 + default y if GRKERNSEC_CONFIG_AUTO
61333 + select PAX_USERCOPY_SLABS
61334 + help
61335 + If you say Y here, getting information on loaded modules, and
61336 + displaying all kernel symbols through a syscall will be restricted
61337 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61338 + /proc/kallsyms will be restricted to the root user. The RBAC
61339 + system can hide that entry even from root.
61340 +
61341 + This option also prevents leaking of kernel addresses through
61342 + several /proc entries.
61343 +
61344 + Note that this option is only effective provided the following
61345 + conditions are met:
61346 + 1) The kernel using grsecurity is not precompiled by some distribution
61347 + 2) You have also enabled GRKERNSEC_DMESG
61348 + 3) You are using the RBAC system and hiding other files such as your
61349 + kernel image and System.map. Alternatively, enabling this option
61350 + causes the permissions on /boot, /lib/modules, and the kernel
61351 + source directory to change at compile time to prevent
61352 + reading by non-root users.
61353 + If the above conditions are met, this option will aid in providing a
61354 + useful protection against local kernel exploitation of overflows
61355 + and arbitrary read/write vulnerabilities.
61356 +
61357 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61358 + in addition to this feature.
61359 +
61360 +config GRKERNSEC_KERN_LOCKOUT
61361 + bool "Active kernel exploit response"
61362 + default y if GRKERNSEC_CONFIG_AUTO
61363 + depends on X86 || ARM || PPC || SPARC
61364 + help
61365 + If you say Y here, when a PaX alert is triggered due to suspicious
61366 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61367 + or an OOPS occurs due to bad memory accesses, instead of just
61368 + terminating the offending process (and potentially allowing
61369 + a subsequent exploit from the same user), we will take one of two
61370 + actions:
61371 + If the user was root, we will panic the system
61372 + If the user was non-root, we will log the attempt, terminate
61373 + all processes owned by the user, then prevent them from creating
61374 + any new processes until the system is restarted
61375 + This deters repeated kernel exploitation/bruteforcing attempts
61376 + and is useful for later forensics.
61377 +
61378 +endmenu
61379 +menu "Role Based Access Control Options"
61380 +depends on GRKERNSEC
61381 +
61382 +config GRKERNSEC_RBAC_DEBUG
61383 + bool
61384 +
61385 +config GRKERNSEC_NO_RBAC
61386 + bool "Disable RBAC system"
61387 + help
61388 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61389 + preventing the RBAC system from being enabled. You should only say Y
61390 + here if you have no intention of using the RBAC system, so as to prevent
61391 + an attacker with root access from misusing the RBAC system to hide files
61392 + and processes when loadable module support and /dev/[k]mem have been
61393 + locked down.
61394 +
61395 +config GRKERNSEC_ACL_HIDEKERN
61396 + bool "Hide kernel processes"
61397 + help
61398 + If you say Y here, all kernel threads will be hidden to all
61399 + processes but those whose subject has the "view hidden processes"
61400 + flag.
61401 +
61402 +config GRKERNSEC_ACL_MAXTRIES
61403 + int "Maximum tries before password lockout"
61404 + default 3
61405 + help
61406 + This option enforces the maximum number of times a user can attempt
61407 + to authorize themselves with the grsecurity RBAC system before being
61408 + denied the ability to attempt authorization again for a specified time.
61409 + The lower the number, the harder it will be to brute-force a password.
61410 +
61411 +config GRKERNSEC_ACL_TIMEOUT
61412 + int "Time to wait after max password tries, in seconds"
61413 + default 30
61414 + help
61415 + This option specifies the time the user must wait after attempting to
61416 + authorize to the RBAC system with the maximum number of invalid
61417 + passwords. The higher the number, the harder it will be to brute-force
61418 + a password.
61419 +
61420 +endmenu
61421 +menu "Filesystem Protections"
61422 +depends on GRKERNSEC
61423 +
61424 +config GRKERNSEC_PROC
61425 + bool "Proc restrictions"
61426 + default y if GRKERNSEC_CONFIG_AUTO
61427 + help
61428 + If you say Y here, the permissions of the /proc filesystem
61429 + will be altered to enhance system security and privacy. You MUST
61430 + choose either a user only restriction or a user and group restriction.
61431 + Depending upon the option you choose, you can either restrict users to
61432 + see only the processes they themselves run, or choose a group that can
61433 + view all processes and files normally restricted to root if you choose
61434 + the "restrict to user only" option. NOTE: If you're running identd or
61435 + ntpd as a non-root user, you will have to run it as the group you
61436 + specify here.
61437 +
61438 +config GRKERNSEC_PROC_USER
61439 + bool "Restrict /proc to user only"
61440 + depends on GRKERNSEC_PROC
61441 + help
61442 + If you say Y here, non-root users will only be able to view their own
61443 + processes, and restricts them from viewing network-related information,
61444 + and viewing kernel symbol and module information.
61445 +
61446 +config GRKERNSEC_PROC_USERGROUP
61447 + bool "Allow special group"
61448 + default y if GRKERNSEC_CONFIG_AUTO
61449 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61450 + help
61451 + If you say Y here, you will be able to select a group that will be
61452 + able to view all processes and network-related information. If you've
61453 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61454 + remain hidden. This option is useful if you want to run identd as
61455 + a non-root user. The group you select may also be chosen at boot time
61456 + via "grsec_proc_gid=" on the kernel commandline.
61457 +
61458 +config GRKERNSEC_PROC_GID
61459 + int "GID for special group"
61460 + depends on GRKERNSEC_PROC_USERGROUP
61461 + default 1001
61462 +
61463 +config GRKERNSEC_PROC_ADD
61464 + bool "Additional restrictions"
61465 + default y if GRKERNSEC_CONFIG_AUTO
61466 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61467 + help
61468 + If you say Y here, additional restrictions will be placed on
61469 + /proc that keep normal users from viewing device information and
61470 + slabinfo information that could be useful for exploits.
61471 +
61472 +config GRKERNSEC_LINK
61473 + bool "Linking restrictions"
61474 + default y if GRKERNSEC_CONFIG_AUTO
61475 + help
61476 + If you say Y here, /tmp race exploits will be prevented, since users
61477 + will no longer be able to follow symlinks owned by other users in
61478 + world-writable +t directories (e.g. /tmp), unless the owner of the
61479 + symlink is the owner of the directory. users will also not be
61480 + able to hardlink to files they do not own. If the sysctl option is
61481 + enabled, a sysctl option with name "linking_restrictions" is created.
61482 +
61483 +config GRKERNSEC_SYMLINKOWN
61484 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61485 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61486 + help
61487 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61488 + that prevents it from being used as a security feature. As Apache
61489 + verifies the symlink by performing a stat() against the target of
61490 + the symlink before it is followed, an attacker can setup a symlink
61491 + to point to a same-owned file, then replace the symlink with one
61492 + that targets another user's file just after Apache "validates" the
61493 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61494 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61495 + will be in place for the group you specify. If the sysctl option
61496 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61497 + created.
61498 +
61499 +config GRKERNSEC_SYMLINKOWN_GID
61500 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61501 + depends on GRKERNSEC_SYMLINKOWN
61502 + default 1006
61503 + help
61504 + Setting this GID determines what group kernel-enforced
61505 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61506 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61507 +
61508 +config GRKERNSEC_FIFO
61509 + bool "FIFO restrictions"
61510 + default y if GRKERNSEC_CONFIG_AUTO
61511 + help
61512 + If you say Y here, users will not be able to write to FIFOs they don't
61513 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61514 + the FIFO is the same owner of the directory it's held in. If the sysctl
61515 + option is enabled, a sysctl option with name "fifo_restrictions" is
61516 + created.
61517 +
61518 +config GRKERNSEC_SYSFS_RESTRICT
61519 + bool "Sysfs/debugfs restriction"
61520 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61521 + depends on SYSFS
61522 + help
61523 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61524 + any filesystem normally mounted under it (e.g. debugfs) will be
61525 + mostly accessible only by root. These filesystems generally provide access
61526 + to hardware and debug information that isn't appropriate for unprivileged
61527 + users of the system. Sysfs and debugfs have also become a large source
61528 + of new vulnerabilities, ranging from infoleaks to local compromise.
61529 + There has been very little oversight with an eye toward security involved
61530 + in adding new exporters of information to these filesystems, so their
61531 + use is discouraged.
61532 + For reasons of compatibility, a few directories have been whitelisted
61533 + for access by non-root users:
61534 + /sys/fs/selinux
61535 + /sys/fs/fuse
61536 + /sys/devices/system/cpu
61537 +
61538 +config GRKERNSEC_ROFS
61539 + bool "Runtime read-only mount protection"
61540 + depends on SYSCTL
61541 + help
61542 + If you say Y here, a sysctl option with name "romount_protect" will
61543 + be created. By setting this option to 1 at runtime, filesystems
61544 + will be protected in the following ways:
61545 + * No new writable mounts will be allowed
61546 + * Existing read-only mounts won't be able to be remounted read/write
61547 + * Write operations will be denied on all block devices
61548 + This option acts independently of grsec_lock: once it is set to 1,
61549 + it cannot be turned off. Therefore, please be mindful of the resulting
61550 + behavior if this option is enabled in an init script on a read-only
61551 + filesystem. This feature is mainly intended for secure embedded systems.
61552 +
61553 +config GRKERNSEC_DEVICE_SIDECHANNEL
61554 + bool "Eliminate stat/notify-based device sidechannels"
61555 + default y if GRKERNSEC_CONFIG_AUTO
61556 + help
61557 + If you say Y here, timing analyses on block or character
61558 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61559 + will be thwarted for unprivileged users. If a process without
61560 + CAP_MKNOD stats such a device, the last access and last modify times
61561 + will match the device's create time. No access or modify events
61562 + will be triggered through inotify/dnotify/fanotify for such devices.
61563 + This feature will prevent attacks that may at a minimum
61564 + allow an attacker to determine the administrator's password length.
61565 +
61566 +config GRKERNSEC_CHROOT
61567 + bool "Chroot jail restrictions"
61568 + default y if GRKERNSEC_CONFIG_AUTO
61569 + help
61570 + If you say Y here, you will be able to choose several options that will
61571 + make breaking out of a chrooted jail much more difficult. If you
61572 + encounter no software incompatibilities with the following options, it
61573 + is recommended that you enable each one.
61574 +
61575 +config GRKERNSEC_CHROOT_MOUNT
61576 + bool "Deny mounts"
61577 + default y if GRKERNSEC_CONFIG_AUTO
61578 + depends on GRKERNSEC_CHROOT
61579 + help
61580 + If you say Y here, processes inside a chroot will not be able to
61581 + mount or remount filesystems. If the sysctl option is enabled, a
61582 + sysctl option with name "chroot_deny_mount" is created.
61583 +
61584 +config GRKERNSEC_CHROOT_DOUBLE
61585 + bool "Deny double-chroots"
61586 + default y if GRKERNSEC_CONFIG_AUTO
61587 + depends on GRKERNSEC_CHROOT
61588 + help
61589 + If you say Y here, processes inside a chroot will not be able to chroot
61590 + again outside the chroot. This is a widely used method of breaking
61591 + out of a chroot jail and should not be allowed. If the sysctl
61592 + option is enabled, a sysctl option with name
61593 + "chroot_deny_chroot" is created.
61594 +
61595 +config GRKERNSEC_CHROOT_PIVOT
61596 + bool "Deny pivot_root in chroot"
61597 + default y if GRKERNSEC_CONFIG_AUTO
61598 + depends on GRKERNSEC_CHROOT
61599 + help
61600 + If you say Y here, processes inside a chroot will not be able to use
61601 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61602 + works similar to chroot in that it changes the root filesystem. This
61603 + function could be misused in a chrooted process to attempt to break out
61604 + of the chroot, and therefore should not be allowed. If the sysctl
61605 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61606 + created.
61607 +
61608 +config GRKERNSEC_CHROOT_CHDIR
61609 + bool "Enforce chdir(\"/\") on all chroots"
61610 + default y if GRKERNSEC_CONFIG_AUTO
61611 + depends on GRKERNSEC_CHROOT
61612 + help
61613 + If you say Y here, the current working directory of all newly-chrooted
61614 + applications will be set to the the root directory of the chroot.
61615 + The man page on chroot(2) states:
61616 + Note that this call does not change the current working
61617 + directory, so that `.' can be outside the tree rooted at
61618 + `/'. In particular, the super-user can escape from a
61619 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61620 +
61621 + It is recommended that you say Y here, since it's not known to break
61622 + any software. If the sysctl option is enabled, a sysctl option with
61623 + name "chroot_enforce_chdir" is created.
61624 +
61625 +config GRKERNSEC_CHROOT_CHMOD
61626 + bool "Deny (f)chmod +s"
61627 + default y if GRKERNSEC_CONFIG_AUTO
61628 + depends on GRKERNSEC_CHROOT
61629 + help
61630 + If you say Y here, processes inside a chroot will not be able to chmod
61631 + or fchmod files to make them have suid or sgid bits. This protects
61632 + against another published method of breaking a chroot. If the sysctl
61633 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61634 + created.
61635 +
61636 +config GRKERNSEC_CHROOT_FCHDIR
61637 + bool "Deny fchdir out of chroot"
61638 + default y if GRKERNSEC_CONFIG_AUTO
61639 + depends on GRKERNSEC_CHROOT
61640 + help
61641 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61642 + to a file descriptor of the chrooting process that points to a directory
61643 + outside the filesystem will be stopped. If the sysctl option
61644 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61645 +
61646 +config GRKERNSEC_CHROOT_MKNOD
61647 + bool "Deny mknod"
61648 + default y if GRKERNSEC_CONFIG_AUTO
61649 + depends on GRKERNSEC_CHROOT
61650 + help
61651 + If you say Y here, processes inside a chroot will not be allowed to
61652 + mknod. The problem with using mknod inside a chroot is that it
61653 + would allow an attacker to create a device entry that is the same
61654 + as one on the physical root of your system, which could range from
61655 + anything from the console device to a device for your harddrive (which
61656 + they could then use to wipe the drive or steal data). It is recommended
61657 + that you say Y here, unless you run into software incompatibilities.
61658 + If the sysctl option is enabled, a sysctl option with name
61659 + "chroot_deny_mknod" is created.
61660 +
61661 +config GRKERNSEC_CHROOT_SHMAT
61662 + bool "Deny shmat() out of chroot"
61663 + default y if GRKERNSEC_CONFIG_AUTO
61664 + depends on GRKERNSEC_CHROOT
61665 + help
61666 + If you say Y here, processes inside a chroot will not be able to attach
61667 + to shared memory segments that were created outside of the chroot jail.
61668 + It is recommended that you say Y here. If the sysctl option is enabled,
61669 + a sysctl option with name "chroot_deny_shmat" is created.
61670 +
61671 +config GRKERNSEC_CHROOT_UNIX
61672 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61673 + default y if GRKERNSEC_CONFIG_AUTO
61674 + depends on GRKERNSEC_CHROOT
61675 + help
61676 + If you say Y here, processes inside a chroot will not be able to
61677 + connect to abstract (meaning not belonging to a filesystem) Unix
61678 + domain sockets that were bound outside of a chroot. It is recommended
61679 + that you say Y here. If the sysctl option is enabled, a sysctl option
61680 + with name "chroot_deny_unix" is created.
61681 +
61682 +config GRKERNSEC_CHROOT_FINDTASK
61683 + bool "Protect outside processes"
61684 + default y if GRKERNSEC_CONFIG_AUTO
61685 + depends on GRKERNSEC_CHROOT
61686 + help
61687 + If you say Y here, processes inside a chroot will not be able to
61688 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61689 + getsid, or view any process outside of the chroot. If the sysctl
61690 + option is enabled, a sysctl option with name "chroot_findtask" is
61691 + created.
61692 +
61693 +config GRKERNSEC_CHROOT_NICE
61694 + bool "Restrict priority changes"
61695 + default y if GRKERNSEC_CONFIG_AUTO
61696 + depends on GRKERNSEC_CHROOT
61697 + help
61698 + If you say Y here, processes inside a chroot will not be able to raise
61699 + the priority of processes in the chroot, or alter the priority of
61700 + processes outside the chroot. This provides more security than simply
61701 + removing CAP_SYS_NICE from the process' capability set. If the
61702 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61703 + is created.
61704 +
61705 +config GRKERNSEC_CHROOT_SYSCTL
61706 + bool "Deny sysctl writes"
61707 + default y if GRKERNSEC_CONFIG_AUTO
61708 + depends on GRKERNSEC_CHROOT
61709 + help
61710 + If you say Y here, an attacker in a chroot will not be able to
61711 + write to sysctl entries, either by sysctl(2) or through a /proc
61712 + interface. It is strongly recommended that you say Y here. If the
61713 + sysctl option is enabled, a sysctl option with name
61714 + "chroot_deny_sysctl" is created.
61715 +
61716 +config GRKERNSEC_CHROOT_CAPS
61717 + bool "Capability restrictions"
61718 + default y if GRKERNSEC_CONFIG_AUTO
61719 + depends on GRKERNSEC_CHROOT
61720 + help
61721 + If you say Y here, the capabilities on all processes within a
61722 + chroot jail will be lowered to stop module insertion, raw i/o,
61723 + system and net admin tasks, rebooting the system, modifying immutable
61724 + files, modifying IPC owned by another, and changing the system time.
61725 + This is left an option because it can break some apps. Disable this
61726 + if your chrooted apps are having problems performing those kinds of
61727 + tasks. If the sysctl option is enabled, a sysctl option with
61728 + name "chroot_caps" is created.
61729 +
61730 +config GRKERNSEC_CHROOT_INITRD
61731 + bool "Exempt initrd tasks from restrictions"
61732 + default y if GRKERNSEC_CONFIG_AUTO
61733 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61734 + help
61735 + If you say Y here, tasks started prior to init will be exempted from
61736 + grsecurity's chroot restrictions. This option is mainly meant to
61737 + resolve Plymouth's performing privileged operations unnecessarily
61738 + in a chroot.
61739 +
61740 +endmenu
61741 +menu "Kernel Auditing"
61742 +depends on GRKERNSEC
61743 +
61744 +config GRKERNSEC_AUDIT_GROUP
61745 + bool "Single group for auditing"
61746 + help
61747 + If you say Y here, the exec and chdir logging features will only operate
61748 + on a group you specify. This option is recommended if you only want to
61749 + watch certain users instead of having a large amount of logs from the
61750 + entire system. If the sysctl option is enabled, a sysctl option with
61751 + name "audit_group" is created.
61752 +
61753 +config GRKERNSEC_AUDIT_GID
61754 + int "GID for auditing"
61755 + depends on GRKERNSEC_AUDIT_GROUP
61756 + default 1007
61757 +
61758 +config GRKERNSEC_EXECLOG
61759 + bool "Exec logging"
61760 + help
61761 + If you say Y here, all execve() calls will be logged (since the
61762 + other exec*() calls are frontends to execve(), all execution
61763 + will be logged). Useful for shell-servers that like to keep track
61764 + of their users. If the sysctl option is enabled, a sysctl option with
61765 + name "exec_logging" is created.
61766 + WARNING: This option when enabled will produce a LOT of logs, especially
61767 + on an active system.
61768 +
61769 +config GRKERNSEC_RESLOG
61770 + bool "Resource logging"
61771 + default y if GRKERNSEC_CONFIG_AUTO
61772 + help
61773 + If you say Y here, all attempts to overstep resource limits will
61774 + be logged with the resource name, the requested size, and the current
61775 + limit. It is highly recommended that you say Y here. If the sysctl
61776 + option is enabled, a sysctl option with name "resource_logging" is
61777 + created. If the RBAC system is enabled, the sysctl value is ignored.
61778 +
61779 +config GRKERNSEC_CHROOT_EXECLOG
61780 + bool "Log execs within chroot"
61781 + help
61782 + If you say Y here, all executions inside a chroot jail will be logged
61783 + to syslog. This can cause a large amount of logs if certain
61784 + applications (eg. djb's daemontools) are installed on the system, and
61785 + is therefore left as an option. If the sysctl option is enabled, a
61786 + sysctl option with name "chroot_execlog" is created.
61787 +
61788 +config GRKERNSEC_AUDIT_PTRACE
61789 + bool "Ptrace logging"
61790 + help
61791 + If you say Y here, all attempts to attach to a process via ptrace
61792 + will be logged. If the sysctl option is enabled, a sysctl option
61793 + with name "audit_ptrace" is created.
61794 +
61795 +config GRKERNSEC_AUDIT_CHDIR
61796 + bool "Chdir logging"
61797 + help
61798 + If you say Y here, all chdir() calls will be logged. If the sysctl
61799 + option is enabled, a sysctl option with name "audit_chdir" is created.
61800 +
61801 +config GRKERNSEC_AUDIT_MOUNT
61802 + bool "(Un)Mount logging"
61803 + help
61804 + If you say Y here, all mounts and unmounts will be logged. If the
61805 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61806 + created.
61807 +
61808 +config GRKERNSEC_SIGNAL
61809 + bool "Signal logging"
61810 + default y if GRKERNSEC_CONFIG_AUTO
61811 + help
61812 + If you say Y here, certain important signals will be logged, such as
61813 + SIGSEGV, which will as a result inform you of when a error in a program
61814 + occurred, which in some cases could mean a possible exploit attempt.
61815 + If the sysctl option is enabled, a sysctl option with name
61816 + "signal_logging" is created.
61817 +
61818 +config GRKERNSEC_FORKFAIL
61819 + bool "Fork failure logging"
61820 + help
61821 + If you say Y here, all failed fork() attempts will be logged.
61822 + This could suggest a fork bomb, or someone attempting to overstep
61823 + their process limit. If the sysctl option is enabled, a sysctl option
61824 + with name "forkfail_logging" is created.
61825 +
61826 +config GRKERNSEC_TIME
61827 + bool "Time change logging"
61828 + default y if GRKERNSEC_CONFIG_AUTO
61829 + help
61830 + If you say Y here, any changes of the system clock will be logged.
61831 + If the sysctl option is enabled, a sysctl option with name
61832 + "timechange_logging" is created.
61833 +
61834 +config GRKERNSEC_PROC_IPADDR
61835 + bool "/proc/<pid>/ipaddr support"
61836 + default y if GRKERNSEC_CONFIG_AUTO
61837 + help
61838 + If you say Y here, a new entry will be added to each /proc/<pid>
61839 + directory that contains the IP address of the person using the task.
61840 + The IP is carried across local TCP and AF_UNIX stream sockets.
61841 + This information can be useful for IDS/IPSes to perform remote response
61842 + to a local attack. The entry is readable by only the owner of the
61843 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61844 + the RBAC system), and thus does not create privacy concerns.
61845 +
61846 +config GRKERNSEC_RWXMAP_LOG
61847 + bool 'Denied RWX mmap/mprotect logging'
61848 + default y if GRKERNSEC_CONFIG_AUTO
61849 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61850 + help
61851 + If you say Y here, calls to mmap() and mprotect() with explicit
61852 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61853 + denied by the PAX_MPROTECT feature. This feature will also
61854 + log other problematic scenarios that can occur when PAX_MPROTECT
61855 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61856 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61857 + is created.
61858 +
61859 +endmenu
61860 +
61861 +menu "Executable Protections"
61862 +depends on GRKERNSEC
61863 +
61864 +config GRKERNSEC_DMESG
61865 + bool "Dmesg(8) restriction"
61866 + default y if GRKERNSEC_CONFIG_AUTO
61867 + help
61868 + If you say Y here, non-root users will not be able to use dmesg(8)
61869 + to view the contents of the kernel's circular log buffer.
61870 + The kernel's log buffer often contains kernel addresses and other
61871 + identifying information useful to an attacker in fingerprinting a
61872 + system for a targeted exploit.
61873 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61874 + created.
61875 +
61876 +config GRKERNSEC_HARDEN_PTRACE
61877 + bool "Deter ptrace-based process snooping"
61878 + default y if GRKERNSEC_CONFIG_AUTO
61879 + help
61880 + If you say Y here, TTY sniffers and other malicious monitoring
61881 + programs implemented through ptrace will be defeated. If you
61882 + have been using the RBAC system, this option has already been
61883 + enabled for several years for all users, with the ability to make
61884 + fine-grained exceptions.
61885 +
61886 + This option only affects the ability of non-root users to ptrace
61887 + processes that are not a descendent of the ptracing process.
61888 + This means that strace ./binary and gdb ./binary will still work,
61889 + but attaching to arbitrary processes will not. If the sysctl
61890 + option is enabled, a sysctl option with name "harden_ptrace" is
61891 + created.
61892 +
61893 +config GRKERNSEC_PTRACE_READEXEC
61894 + bool "Require read access to ptrace sensitive binaries"
61895 + default y if GRKERNSEC_CONFIG_AUTO
61896 + help
61897 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61898 + binaries. This option is useful in environments that
61899 + remove the read bits (e.g. file mode 4711) from suid binaries to
61900 + prevent infoleaking of their contents. This option adds
61901 + consistency to the use of that file mode, as the binary could normally
61902 + be read out when run without privileges while ptracing.
61903 +
61904 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61905 + is created.
61906 +
61907 +config GRKERNSEC_SETXID
61908 + bool "Enforce consistent multithreaded privileges"
61909 + default y if GRKERNSEC_CONFIG_AUTO
61910 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61911 + help
61912 + If you say Y here, a change from a root uid to a non-root uid
61913 + in a multithreaded application will cause the resulting uids,
61914 + gids, supplementary groups, and capabilities in that thread
61915 + to be propagated to the other threads of the process. In most
61916 + cases this is unnecessary, as glibc will emulate this behavior
61917 + on behalf of the application. Other libcs do not act in the
61918 + same way, allowing the other threads of the process to continue
61919 + running with root privileges. If the sysctl option is enabled,
61920 + a sysctl option with name "consistent_setxid" is created.
61921 +
61922 +config GRKERNSEC_TPE
61923 + bool "Trusted Path Execution (TPE)"
61924 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61925 + help
61926 + If you say Y here, you will be able to choose a gid to add to the
61927 + supplementary groups of users you want to mark as "untrusted."
61928 + These users will not be able to execute any files that are not in
61929 + root-owned directories writable only by root. If the sysctl option
61930 + is enabled, a sysctl option with name "tpe" is created.
61931 +
61932 +config GRKERNSEC_TPE_ALL
61933 + bool "Partially restrict all non-root users"
61934 + depends on GRKERNSEC_TPE
61935 + help
61936 + If you say Y here, all non-root users will be covered under
61937 + a weaker TPE restriction. This is separate from, and in addition to,
61938 + the main TPE options that you have selected elsewhere. Thus, if a
61939 + "trusted" GID is chosen, this restriction applies to even that GID.
61940 + Under this restriction, all non-root users will only be allowed to
61941 + execute files in directories they own that are not group or
61942 + world-writable, or in directories owned by root and writable only by
61943 + root. If the sysctl option is enabled, a sysctl option with name
61944 + "tpe_restrict_all" is created.
61945 +
61946 +config GRKERNSEC_TPE_INVERT
61947 + bool "Invert GID option"
61948 + depends on GRKERNSEC_TPE
61949 + help
61950 + If you say Y here, the group you specify in the TPE configuration will
61951 + decide what group TPE restrictions will be *disabled* for. This
61952 + option is useful if you want TPE restrictions to be applied to most
61953 + users on the system. If the sysctl option is enabled, a sysctl option
61954 + with name "tpe_invert" is created. Unlike other sysctl options, this
61955 + entry will default to on for backward-compatibility.
61956 +
61957 +config GRKERNSEC_TPE_GID
61958 + int
61959 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61960 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61961 +
61962 +config GRKERNSEC_TPE_UNTRUSTED_GID
61963 + int "GID for TPE-untrusted users"
61964 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61965 + default 1005
61966 + help
61967 + Setting this GID determines what group TPE restrictions will be
61968 + *enabled* for. If the sysctl option is enabled, a sysctl option
61969 + with name "tpe_gid" is created.
61970 +
61971 +config GRKERNSEC_TPE_TRUSTED_GID
61972 + int "GID for TPE-trusted users"
61973 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61974 + default 1005
61975 + help
61976 + Setting this GID determines what group TPE restrictions will be
61977 + *disabled* for. If the sysctl option is enabled, a sysctl option
61978 + with name "tpe_gid" is created.
61979 +
61980 +endmenu
61981 +menu "Network Protections"
61982 +depends on GRKERNSEC
61983 +
61984 +config GRKERNSEC_RANDNET
61985 + bool "Larger entropy pools"
61986 + default y if GRKERNSEC_CONFIG_AUTO
61987 + help
61988 + If you say Y here, the entropy pools used for many features of Linux
61989 + and grsecurity will be doubled in size. Since several grsecurity
61990 + features use additional randomness, it is recommended that you say Y
61991 + here. Saying Y here has a similar effect as modifying
61992 + /proc/sys/kernel/random/poolsize.
61993 +
61994 +config GRKERNSEC_BLACKHOLE
61995 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61996 + default y if GRKERNSEC_CONFIG_AUTO
61997 + depends on NET
61998 + help
61999 + If you say Y here, neither TCP resets nor ICMP
62000 + destination-unreachable packets will be sent in response to packets
62001 + sent to ports for which no associated listening process exists.
62002 + This feature supports both IPV4 and IPV6 and exempts the
62003 + loopback interface from blackholing. Enabling this feature
62004 + makes a host more resilient to DoS attacks and reduces network
62005 + visibility against scanners.
62006 +
62007 + The blackhole feature as-implemented is equivalent to the FreeBSD
62008 + blackhole feature, as it prevents RST responses to all packets, not
62009 + just SYNs. Under most application behavior this causes no
62010 + problems, but applications (like haproxy) may not close certain
62011 + connections in a way that cleanly terminates them on the remote
62012 + end, leaving the remote host in LAST_ACK state. Because of this
62013 + side-effect and to prevent intentional LAST_ACK DoSes, this
62014 + feature also adds automatic mitigation against such attacks.
62015 + The mitigation drastically reduces the amount of time a socket
62016 + can spend in LAST_ACK state. If you're using haproxy and not
62017 + all servers it connects to have this option enabled, consider
62018 + disabling this feature on the haproxy host.
62019 +
62020 + If the sysctl option is enabled, two sysctl options with names
62021 + "ip_blackhole" and "lastack_retries" will be created.
62022 + While "ip_blackhole" takes the standard zero/non-zero on/off
62023 + toggle, "lastack_retries" uses the same kinds of values as
62024 + "tcp_retries1" and "tcp_retries2". The default value of 4
62025 + prevents a socket from lasting more than 45 seconds in LAST_ACK
62026 + state.
62027 +
62028 +config GRKERNSEC_NO_SIMULT_CONNECT
62029 + bool "Disable TCP Simultaneous Connect"
62030 + default y if GRKERNSEC_CONFIG_AUTO
62031 + depends on NET
62032 + help
62033 + If you say Y here, a feature by Willy Tarreau will be enabled that
62034 + removes a weakness in Linux's strict implementation of TCP that
62035 + allows two clients to connect to each other without either entering
62036 + a listening state. The weakness allows an attacker to easily prevent
62037 + a client from connecting to a known server provided the source port
62038 + for the connection is guessed correctly.
62039 +
62040 + As the weakness could be used to prevent an antivirus or IPS from
62041 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62042 + it should be eliminated by enabling this option. Though Linux is
62043 + one of few operating systems supporting simultaneous connect, it
62044 + has no legitimate use in practice and is rarely supported by firewalls.
62045 +
62046 +config GRKERNSEC_SOCKET
62047 + bool "Socket restrictions"
62048 + depends on NET
62049 + help
62050 + If you say Y here, you will be able to choose from several options.
62051 + If you assign a GID on your system and add it to the supplementary
62052 + groups of users you want to restrict socket access to, this patch
62053 + will perform up to three things, based on the option(s) you choose.
62054 +
62055 +config GRKERNSEC_SOCKET_ALL
62056 + bool "Deny any sockets to group"
62057 + depends on GRKERNSEC_SOCKET
62058 + help
62059 + If you say Y here, you will be able to choose a GID of whose users will
62060 + be unable to connect to other hosts from your machine or run server
62061 + applications from your machine. If the sysctl option is enabled, a
62062 + sysctl option with name "socket_all" is created.
62063 +
62064 +config GRKERNSEC_SOCKET_ALL_GID
62065 + int "GID to deny all sockets for"
62066 + depends on GRKERNSEC_SOCKET_ALL
62067 + default 1004
62068 + help
62069 + Here you can choose the GID to disable socket access for. Remember to
62070 + add the users you want socket access disabled for to the GID
62071 + specified here. If the sysctl option is enabled, a sysctl option
62072 + with name "socket_all_gid" is created.
62073 +
62074 +config GRKERNSEC_SOCKET_CLIENT
62075 + bool "Deny client sockets to group"
62076 + depends on GRKERNSEC_SOCKET
62077 + help
62078 + If you say Y here, you will be able to choose a GID of whose users will
62079 + be unable to connect to other hosts from your machine, but will be
62080 + able to run servers. If this option is enabled, all users in the group
62081 + you specify will have to use passive mode when initiating ftp transfers
62082 + from the shell on your machine. If the sysctl option is enabled, a
62083 + sysctl option with name "socket_client" is created.
62084 +
62085 +config GRKERNSEC_SOCKET_CLIENT_GID
62086 + int "GID to deny client sockets for"
62087 + depends on GRKERNSEC_SOCKET_CLIENT
62088 + default 1003
62089 + help
62090 + Here you can choose the GID to disable client socket access for.
62091 + Remember to add the users you want client socket access disabled for to
62092 + the GID specified here. If the sysctl option is enabled, a sysctl
62093 + option with name "socket_client_gid" is created.
62094 +
62095 +config GRKERNSEC_SOCKET_SERVER
62096 + bool "Deny server sockets to group"
62097 + depends on GRKERNSEC_SOCKET
62098 + help
62099 + If you say Y here, you will be able to choose a GID of whose users will
62100 + be unable to run server applications from your machine. If the sysctl
62101 + option is enabled, a sysctl option with name "socket_server" is created.
62102 +
62103 +config GRKERNSEC_SOCKET_SERVER_GID
62104 + int "GID to deny server sockets for"
62105 + depends on GRKERNSEC_SOCKET_SERVER
62106 + default 1002
62107 + help
62108 + Here you can choose the GID to disable server socket access for.
62109 + Remember to add the users you want server socket access disabled for to
62110 + the GID specified here. If the sysctl option is enabled, a sysctl
62111 + option with name "socket_server_gid" is created.
62112 +
62113 +endmenu
62114 +
62115 +menu "Physical Protections"
62116 +depends on GRKERNSEC
62117 +
62118 +config GRKERNSEC_DENYUSB
62119 + bool "Deny new USB connections after toggle"
62120 + default y if GRKERNSEC_CONFIG_AUTO
62121 + depends on SYSCTL && USB_SUPPORT
62122 + help
62123 + If you say Y here, a new sysctl option with name "deny_new_usb"
62124 + will be created. Setting its value to 1 will prevent any new
62125 + USB devices from being recognized by the OS. Any attempted USB
62126 + device insertion will be logged. This option is intended to be
62127 + used against custom USB devices designed to exploit vulnerabilities
62128 + in various USB device drivers.
62129 +
62130 + For greatest effectiveness, this sysctl should be set after any
62131 + relevant init scripts. This option is safe to enable in distros
62132 + as each user can choose whether or not to toggle the sysctl.
62133 +
62134 +config GRKERNSEC_DENYUSB_FORCE
62135 + bool "Reject all USB devices not connected at boot"
62136 + select USB
62137 + depends on GRKERNSEC_DENYUSB
62138 + help
62139 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62140 + that doesn't involve a sysctl entry. This option should only be
62141 + enabled if you're sure you want to deny all new USB connections
62142 + at runtime and don't want to modify init scripts. This should not
62143 + be enabled by distros. It forces the core USB code to be built
62144 + into the kernel image so that all devices connected at boot time
62145 + can be recognized and new USB device connections can be prevented
62146 + prior to init running.
62147 +
62148 +endmenu
62149 +
62150 +menu "Sysctl Support"
62151 +depends on GRKERNSEC && SYSCTL
62152 +
62153 +config GRKERNSEC_SYSCTL
62154 + bool "Sysctl support"
62155 + default y if GRKERNSEC_CONFIG_AUTO
62156 + help
62157 + If you say Y here, you will be able to change the options that
62158 + grsecurity runs with at bootup, without having to recompile your
62159 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62160 + to enable (1) or disable (0) various features. All the sysctl entries
62161 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62162 + All features enabled in the kernel configuration are disabled at boot
62163 + if you do not say Y to the "Turn on features by default" option.
62164 + All options should be set at startup, and the grsec_lock entry should
62165 + be set to a non-zero value after all the options are set.
62166 + *THIS IS EXTREMELY IMPORTANT*
62167 +
62168 +config GRKERNSEC_SYSCTL_DISTRO
62169 + bool "Extra sysctl support for distro makers (READ HELP)"
62170 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62171 + help
62172 + If you say Y here, additional sysctl options will be created
62173 + for features that affect processes running as root. Therefore,
62174 + it is critical when using this option that the grsec_lock entry be
62175 + enabled after boot. Only distros with prebuilt kernel packages
62176 + with this option enabled that can ensure grsec_lock is enabled
62177 + after boot should use this option.
62178 + *Failure to set grsec_lock after boot makes all grsec features
62179 + this option covers useless*
62180 +
62181 + Currently this option creates the following sysctl entries:
62182 + "Disable Privileged I/O": "disable_priv_io"
62183 +
62184 +config GRKERNSEC_SYSCTL_ON
62185 + bool "Turn on features by default"
62186 + default y if GRKERNSEC_CONFIG_AUTO
62187 + depends on GRKERNSEC_SYSCTL
62188 + help
62189 + If you say Y here, instead of having all features enabled in the
62190 + kernel configuration disabled at boot time, the features will be
62191 + enabled at boot time. It is recommended you say Y here unless
62192 + there is some reason you would want all sysctl-tunable features to
62193 + be disabled by default. As mentioned elsewhere, it is important
62194 + to enable the grsec_lock entry once you have finished modifying
62195 + the sysctl entries.
62196 +
62197 +endmenu
62198 +menu "Logging Options"
62199 +depends on GRKERNSEC
62200 +
62201 +config GRKERNSEC_FLOODTIME
62202 + int "Seconds in between log messages (minimum)"
62203 + default 10
62204 + help
62205 + This option allows you to enforce the number of seconds between
62206 + grsecurity log messages. The default should be suitable for most
62207 + people, however, if you choose to change it, choose a value small enough
62208 + to allow informative logs to be produced, but large enough to
62209 + prevent flooding.
62210 +
62211 +config GRKERNSEC_FLOODBURST
62212 + int "Number of messages in a burst (maximum)"
62213 + default 6
62214 + help
62215 + This option allows you to choose the maximum number of messages allowed
62216 + within the flood time interval you chose in a separate option. The
62217 + default should be suitable for most people, however if you find that
62218 + many of your logs are being interpreted as flooding, you may want to
62219 + raise this value.
62220 +
62221 +endmenu
62222 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62223 new file mode 100644
62224 index 0000000..b0b77d5
62225 --- /dev/null
62226 +++ b/grsecurity/Makefile
62227 @@ -0,0 +1,43 @@
62228 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62229 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62230 +# into an RBAC system
62231 +#
62232 +# All code in this directory and various hooks inserted throughout the kernel
62233 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62234 +# under the GPL v2 or higher
62235 +
62236 +KBUILD_CFLAGS += -Werror
62237 +
62238 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62239 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62240 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62241 + grsec_usb.o
62242 +
62243 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62244 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62245 + gracl_learn.o grsec_log.o
62246 +ifdef CONFIG_COMPAT
62247 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62248 +endif
62249 +
62250 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62251 +
62252 +ifdef CONFIG_NET
62253 +obj-y += grsec_sock.o
62254 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62255 +endif
62256 +
62257 +ifndef CONFIG_GRKERNSEC
62258 +obj-y += grsec_disabled.o
62259 +endif
62260 +
62261 +ifdef CONFIG_GRKERNSEC_HIDESYM
62262 +extra-y := grsec_hidesym.o
62263 +$(obj)/grsec_hidesym.o:
62264 + @-chmod -f 500 /boot
62265 + @-chmod -f 500 /lib/modules
62266 + @-chmod -f 500 /lib64/modules
62267 + @-chmod -f 500 /lib32/modules
62268 + @-chmod -f 700 .
62269 + @echo ' grsec: protected kernel image paths'
62270 +endif
62271 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62272 new file mode 100644
62273 index 0000000..c0793fd
62274 --- /dev/null
62275 +++ b/grsecurity/gracl.c
62276 @@ -0,0 +1,4178 @@
62277 +#include <linux/kernel.h>
62278 +#include <linux/module.h>
62279 +#include <linux/sched.h>
62280 +#include <linux/mm.h>
62281 +#include <linux/file.h>
62282 +#include <linux/fs.h>
62283 +#include <linux/namei.h>
62284 +#include <linux/mount.h>
62285 +#include <linux/tty.h>
62286 +#include <linux/proc_fs.h>
62287 +#include <linux/lglock.h>
62288 +#include <linux/slab.h>
62289 +#include <linux/vmalloc.h>
62290 +#include <linux/types.h>
62291 +#include <linux/sysctl.h>
62292 +#include <linux/netdevice.h>
62293 +#include <linux/ptrace.h>
62294 +#include <linux/gracl.h>
62295 +#include <linux/gralloc.h>
62296 +#include <linux/security.h>
62297 +#include <linux/grinternal.h>
62298 +#include <linux/pid_namespace.h>
62299 +#include <linux/stop_machine.h>
62300 +#include <linux/fdtable.h>
62301 +#include <linux/percpu.h>
62302 +#include <linux/lglock.h>
62303 +#include <linux/hugetlb.h>
62304 +#include <linux/posix-timers.h>
62305 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62306 +#include <linux/magic.h>
62307 +#include <linux/pagemap.h>
62308 +#include "../fs/btrfs/async-thread.h"
62309 +#include "../fs/btrfs/ctree.h"
62310 +#include "../fs/btrfs/btrfs_inode.h"
62311 +#endif
62312 +#include "../fs/mount.h"
62313 +
62314 +#include <asm/uaccess.h>
62315 +#include <asm/errno.h>
62316 +#include <asm/mman.h>
62317 +
62318 +extern struct lglock vfsmount_lock;
62319 +
62320 +static struct acl_role_db acl_role_set;
62321 +static struct name_db name_set;
62322 +static struct inodev_db inodev_set;
62323 +
62324 +/* for keeping track of userspace pointers used for subjects, so we
62325 + can share references in the kernel as well
62326 +*/
62327 +
62328 +static struct path real_root;
62329 +
62330 +static struct acl_subj_map_db subj_map_set;
62331 +
62332 +static struct acl_role_label *default_role;
62333 +
62334 +static struct acl_role_label *role_list;
62335 +
62336 +static u16 acl_sp_role_value;
62337 +
62338 +extern char *gr_shared_page[4];
62339 +static DEFINE_MUTEX(gr_dev_mutex);
62340 +DEFINE_RWLOCK(gr_inode_lock);
62341 +
62342 +struct gr_arg *gr_usermode;
62343 +
62344 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62345 +
62346 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62347 +extern void gr_clear_learn_entries(void);
62348 +
62349 +unsigned char *gr_system_salt;
62350 +unsigned char *gr_system_sum;
62351 +
62352 +static struct sprole_pw **acl_special_roles = NULL;
62353 +static __u16 num_sprole_pws = 0;
62354 +
62355 +static struct acl_role_label *kernel_role = NULL;
62356 +
62357 +static unsigned int gr_auth_attempts = 0;
62358 +static unsigned long gr_auth_expires = 0UL;
62359 +
62360 +#ifdef CONFIG_NET
62361 +extern struct vfsmount *sock_mnt;
62362 +#endif
62363 +
62364 +extern struct vfsmount *pipe_mnt;
62365 +extern struct vfsmount *shm_mnt;
62366 +
62367 +#ifdef CONFIG_HUGETLBFS
62368 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62369 +#endif
62370 +
62371 +static struct acl_object_label *fakefs_obj_rw;
62372 +static struct acl_object_label *fakefs_obj_rwx;
62373 +
62374 +extern int gr_init_uidset(void);
62375 +extern void gr_free_uidset(void);
62376 +extern void gr_remove_uid(uid_t uid);
62377 +extern int gr_find_uid(uid_t uid);
62378 +
62379 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62380 +{
62381 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62382 + return -EFAULT;
62383 +
62384 + return 0;
62385 +}
62386 +
62387 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62388 +{
62389 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62390 + return -EFAULT;
62391 +
62392 + return 0;
62393 +}
62394 +
62395 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62396 +{
62397 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62398 + return -EFAULT;
62399 +
62400 + return 0;
62401 +}
62402 +
62403 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62404 +{
62405 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62406 + return -EFAULT;
62407 +
62408 + return 0;
62409 +}
62410 +
62411 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62412 +{
62413 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62414 + return -EFAULT;
62415 +
62416 + return 0;
62417 +}
62418 +
62419 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62420 +{
62421 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62422 + return -EFAULT;
62423 +
62424 + return 0;
62425 +}
62426 +
62427 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62428 +{
62429 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62430 + return -EFAULT;
62431 +
62432 + return 0;
62433 +}
62434 +
62435 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62436 +{
62437 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62438 + return -EFAULT;
62439 +
62440 + return 0;
62441 +}
62442 +
62443 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62444 +{
62445 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62446 + return -EFAULT;
62447 +
62448 + return 0;
62449 +}
62450 +
62451 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62452 +{
62453 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62454 + return -EFAULT;
62455 +
62456 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62457 + return -EINVAL;
62458 +
62459 + return 0;
62460 +}
62461 +
62462 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62463 +{
62464 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62465 + return -EFAULT;
62466 +
62467 + return 0;
62468 +}
62469 +
62470 +static size_t get_gr_arg_wrapper_size_normal(void)
62471 +{
62472 + return sizeof(struct gr_arg_wrapper);
62473 +}
62474 +
62475 +#ifdef CONFIG_COMPAT
62476 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62477 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62478 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62479 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62480 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62481 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62482 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62483 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62484 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62485 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62486 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62487 +extern size_t get_gr_arg_wrapper_size_compat(void);
62488 +
62489 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62490 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62491 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62492 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62493 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62494 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62495 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62496 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62497 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62498 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62499 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62500 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62501 +
62502 +#else
62503 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62504 +#define copy_gr_arg copy_gr_arg_normal
62505 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62506 +#define copy_acl_object_label copy_acl_object_label_normal
62507 +#define copy_acl_subject_label copy_acl_subject_label_normal
62508 +#define copy_acl_role_label copy_acl_role_label_normal
62509 +#define copy_acl_ip_label copy_acl_ip_label_normal
62510 +#define copy_pointer_from_array copy_pointer_from_array_normal
62511 +#define copy_sprole_pw copy_sprole_pw_normal
62512 +#define copy_role_transition copy_role_transition_normal
62513 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62514 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62515 +#endif
62516 +
62517 +__inline__ int
62518 +gr_acl_is_enabled(void)
62519 +{
62520 + return (gr_status & GR_READY);
62521 +}
62522 +
62523 +static inline dev_t __get_dev(const struct dentry *dentry)
62524 +{
62525 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62526 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62527 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62528 + else
62529 +#endif
62530 + return dentry->d_sb->s_dev;
62531 +}
62532 +
62533 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62534 +{
62535 + return __get_dev(dentry);
62536 +}
62537 +
62538 +static char gr_task_roletype_to_char(struct task_struct *task)
62539 +{
62540 + switch (task->role->roletype &
62541 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62542 + GR_ROLE_SPECIAL)) {
62543 + case GR_ROLE_DEFAULT:
62544 + return 'D';
62545 + case GR_ROLE_USER:
62546 + return 'U';
62547 + case GR_ROLE_GROUP:
62548 + return 'G';
62549 + case GR_ROLE_SPECIAL:
62550 + return 'S';
62551 + }
62552 +
62553 + return 'X';
62554 +}
62555 +
62556 +char gr_roletype_to_char(void)
62557 +{
62558 + return gr_task_roletype_to_char(current);
62559 +}
62560 +
62561 +__inline__ int
62562 +gr_acl_tpe_check(void)
62563 +{
62564 + if (unlikely(!(gr_status & GR_READY)))
62565 + return 0;
62566 + if (current->role->roletype & GR_ROLE_TPE)
62567 + return 1;
62568 + else
62569 + return 0;
62570 +}
62571 +
62572 +int
62573 +gr_handle_rawio(const struct inode *inode)
62574 +{
62575 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62576 + if (inode && S_ISBLK(inode->i_mode) &&
62577 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62578 + !capable(CAP_SYS_RAWIO))
62579 + return 1;
62580 +#endif
62581 + return 0;
62582 +}
62583 +
62584 +static int
62585 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62586 +{
62587 + if (likely(lena != lenb))
62588 + return 0;
62589 +
62590 + return !memcmp(a, b, lena);
62591 +}
62592 +
62593 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62594 +{
62595 + *buflen -= namelen;
62596 + if (*buflen < 0)
62597 + return -ENAMETOOLONG;
62598 + *buffer -= namelen;
62599 + memcpy(*buffer, str, namelen);
62600 + return 0;
62601 +}
62602 +
62603 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62604 +{
62605 + return prepend(buffer, buflen, name->name, name->len);
62606 +}
62607 +
62608 +static int prepend_path(const struct path *path, struct path *root,
62609 + char **buffer, int *buflen)
62610 +{
62611 + struct dentry *dentry = path->dentry;
62612 + struct vfsmount *vfsmnt = path->mnt;
62613 + struct mount *mnt = real_mount(vfsmnt);
62614 + bool slash = false;
62615 + int error = 0;
62616 +
62617 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62618 + struct dentry * parent;
62619 +
62620 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62621 + /* Global root? */
62622 + if (!mnt_has_parent(mnt)) {
62623 + goto out;
62624 + }
62625 + dentry = mnt->mnt_mountpoint;
62626 + mnt = mnt->mnt_parent;
62627 + vfsmnt = &mnt->mnt;
62628 + continue;
62629 + }
62630 + parent = dentry->d_parent;
62631 + prefetch(parent);
62632 + spin_lock(&dentry->d_lock);
62633 + error = prepend_name(buffer, buflen, &dentry->d_name);
62634 + spin_unlock(&dentry->d_lock);
62635 + if (!error)
62636 + error = prepend(buffer, buflen, "/", 1);
62637 + if (error)
62638 + break;
62639 +
62640 + slash = true;
62641 + dentry = parent;
62642 + }
62643 +
62644 +out:
62645 + if (!error && !slash)
62646 + error = prepend(buffer, buflen, "/", 1);
62647 +
62648 + return error;
62649 +}
62650 +
62651 +/* this must be called with vfsmount_lock and rename_lock held */
62652 +
62653 +static char *__our_d_path(const struct path *path, struct path *root,
62654 + char *buf, int buflen)
62655 +{
62656 + char *res = buf + buflen;
62657 + int error;
62658 +
62659 + prepend(&res, &buflen, "\0", 1);
62660 + error = prepend_path(path, root, &res, &buflen);
62661 + if (error)
62662 + return ERR_PTR(error);
62663 +
62664 + return res;
62665 +}
62666 +
62667 +static char *
62668 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62669 +{
62670 + char *retval;
62671 +
62672 + retval = __our_d_path(path, root, buf, buflen);
62673 + if (unlikely(IS_ERR(retval)))
62674 + retval = strcpy(buf, "<path too long>");
62675 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62676 + retval[1] = '\0';
62677 +
62678 + return retval;
62679 +}
62680 +
62681 +static char *
62682 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62683 + char *buf, int buflen)
62684 +{
62685 + struct path path;
62686 + char *res;
62687 +
62688 + path.dentry = (struct dentry *)dentry;
62689 + path.mnt = (struct vfsmount *)vfsmnt;
62690 +
62691 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62692 + by the RBAC system */
62693 + res = gen_full_path(&path, &real_root, buf, buflen);
62694 +
62695 + return res;
62696 +}
62697 +
62698 +static char *
62699 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62700 + char *buf, int buflen)
62701 +{
62702 + char *res;
62703 + struct path path;
62704 + struct path root;
62705 + struct task_struct *reaper = init_pid_ns.child_reaper;
62706 +
62707 + path.dentry = (struct dentry *)dentry;
62708 + path.mnt = (struct vfsmount *)vfsmnt;
62709 +
62710 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62711 + get_fs_root(reaper->fs, &root);
62712 +
62713 + br_read_lock(&vfsmount_lock);
62714 + write_seqlock(&rename_lock);
62715 + res = gen_full_path(&path, &root, buf, buflen);
62716 + write_sequnlock(&rename_lock);
62717 + br_read_unlock(&vfsmount_lock);
62718 +
62719 + path_put(&root);
62720 + return res;
62721 +}
62722 +
62723 +static char *
62724 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62725 +{
62726 + char *ret;
62727 + br_read_lock(&vfsmount_lock);
62728 + write_seqlock(&rename_lock);
62729 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62730 + PAGE_SIZE);
62731 + write_sequnlock(&rename_lock);
62732 + br_read_unlock(&vfsmount_lock);
62733 + return ret;
62734 +}
62735 +
62736 +static char *
62737 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62738 +{
62739 + char *ret;
62740 + char *buf;
62741 + int buflen;
62742 +
62743 + br_read_lock(&vfsmount_lock);
62744 + write_seqlock(&rename_lock);
62745 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62746 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62747 + buflen = (int)(ret - buf);
62748 + if (buflen >= 5)
62749 + prepend(&ret, &buflen, "/proc", 5);
62750 + else
62751 + ret = strcpy(buf, "<path too long>");
62752 + write_sequnlock(&rename_lock);
62753 + br_read_unlock(&vfsmount_lock);
62754 + return ret;
62755 +}
62756 +
62757 +char *
62758 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62759 +{
62760 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62761 + PAGE_SIZE);
62762 +}
62763 +
62764 +char *
62765 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62766 +{
62767 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62768 + PAGE_SIZE);
62769 +}
62770 +
62771 +char *
62772 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62773 +{
62774 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62775 + PAGE_SIZE);
62776 +}
62777 +
62778 +char *
62779 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62780 +{
62781 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62782 + PAGE_SIZE);
62783 +}
62784 +
62785 +char *
62786 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62787 +{
62788 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62789 + PAGE_SIZE);
62790 +}
62791 +
62792 +__inline__ __u32
62793 +to_gr_audit(const __u32 reqmode)
62794 +{
62795 + /* masks off auditable permission flags, then shifts them to create
62796 + auditing flags, and adds the special case of append auditing if
62797 + we're requesting write */
62798 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62799 +}
62800 +
62801 +struct acl_subject_label *
62802 +lookup_subject_map(const struct acl_subject_label *userp)
62803 +{
62804 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62805 + struct subject_map *match;
62806 +
62807 + match = subj_map_set.s_hash[index];
62808 +
62809 + while (match && match->user != userp)
62810 + match = match->next;
62811 +
62812 + if (match != NULL)
62813 + return match->kernel;
62814 + else
62815 + return NULL;
62816 +}
62817 +
62818 +static void
62819 +insert_subj_map_entry(struct subject_map *subjmap)
62820 +{
62821 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62822 + struct subject_map **curr;
62823 +
62824 + subjmap->prev = NULL;
62825 +
62826 + curr = &subj_map_set.s_hash[index];
62827 + if (*curr != NULL)
62828 + (*curr)->prev = subjmap;
62829 +
62830 + subjmap->next = *curr;
62831 + *curr = subjmap;
62832 +
62833 + return;
62834 +}
62835 +
62836 +static struct acl_role_label *
62837 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62838 + const gid_t gid)
62839 +{
62840 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62841 + struct acl_role_label *match;
62842 + struct role_allowed_ip *ipp;
62843 + unsigned int x;
62844 + u32 curr_ip = task->signal->curr_ip;
62845 +
62846 + task->signal->saved_ip = curr_ip;
62847 +
62848 + match = acl_role_set.r_hash[index];
62849 +
62850 + while (match) {
62851 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62852 + for (x = 0; x < match->domain_child_num; x++) {
62853 + if (match->domain_children[x] == uid)
62854 + goto found;
62855 + }
62856 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62857 + break;
62858 + match = match->next;
62859 + }
62860 +found:
62861 + if (match == NULL) {
62862 + try_group:
62863 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62864 + match = acl_role_set.r_hash[index];
62865 +
62866 + while (match) {
62867 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62868 + for (x = 0; x < match->domain_child_num; x++) {
62869 + if (match->domain_children[x] == gid)
62870 + goto found2;
62871 + }
62872 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62873 + break;
62874 + match = match->next;
62875 + }
62876 +found2:
62877 + if (match == NULL)
62878 + match = default_role;
62879 + if (match->allowed_ips == NULL)
62880 + return match;
62881 + else {
62882 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62883 + if (likely
62884 + ((ntohl(curr_ip) & ipp->netmask) ==
62885 + (ntohl(ipp->addr) & ipp->netmask)))
62886 + return match;
62887 + }
62888 + match = default_role;
62889 + }
62890 + } else if (match->allowed_ips == NULL) {
62891 + return match;
62892 + } else {
62893 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62894 + if (likely
62895 + ((ntohl(curr_ip) & ipp->netmask) ==
62896 + (ntohl(ipp->addr) & ipp->netmask)))
62897 + return match;
62898 + }
62899 + goto try_group;
62900 + }
62901 +
62902 + return match;
62903 +}
62904 +
62905 +struct acl_subject_label *
62906 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62907 + const struct acl_role_label *role)
62908 +{
62909 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62910 + struct acl_subject_label *match;
62911 +
62912 + match = role->subj_hash[index];
62913 +
62914 + while (match && (match->inode != ino || match->device != dev ||
62915 + (match->mode & GR_DELETED))) {
62916 + match = match->next;
62917 + }
62918 +
62919 + if (match && !(match->mode & GR_DELETED))
62920 + return match;
62921 + else
62922 + return NULL;
62923 +}
62924 +
62925 +struct acl_subject_label *
62926 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62927 + const struct acl_role_label *role)
62928 +{
62929 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62930 + struct acl_subject_label *match;
62931 +
62932 + match = role->subj_hash[index];
62933 +
62934 + while (match && (match->inode != ino || match->device != dev ||
62935 + !(match->mode & GR_DELETED))) {
62936 + match = match->next;
62937 + }
62938 +
62939 + if (match && (match->mode & GR_DELETED))
62940 + return match;
62941 + else
62942 + return NULL;
62943 +}
62944 +
62945 +static struct acl_object_label *
62946 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62947 + const struct acl_subject_label *subj)
62948 +{
62949 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62950 + struct acl_object_label *match;
62951 +
62952 + match = subj->obj_hash[index];
62953 +
62954 + while (match && (match->inode != ino || match->device != dev ||
62955 + (match->mode & GR_DELETED))) {
62956 + match = match->next;
62957 + }
62958 +
62959 + if (match && !(match->mode & GR_DELETED))
62960 + return match;
62961 + else
62962 + return NULL;
62963 +}
62964 +
62965 +static struct acl_object_label *
62966 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62967 + const struct acl_subject_label *subj)
62968 +{
62969 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62970 + struct acl_object_label *match;
62971 +
62972 + match = subj->obj_hash[index];
62973 +
62974 + while (match && (match->inode != ino || match->device != dev ||
62975 + !(match->mode & GR_DELETED))) {
62976 + match = match->next;
62977 + }
62978 +
62979 + if (match && (match->mode & GR_DELETED))
62980 + return match;
62981 +
62982 + match = subj->obj_hash[index];
62983 +
62984 + while (match && (match->inode != ino || match->device != dev ||
62985 + (match->mode & GR_DELETED))) {
62986 + match = match->next;
62987 + }
62988 +
62989 + if (match && !(match->mode & GR_DELETED))
62990 + return match;
62991 + else
62992 + return NULL;
62993 +}
62994 +
62995 +static struct name_entry *
62996 +lookup_name_entry(const char *name)
62997 +{
62998 + unsigned int len = strlen(name);
62999 + unsigned int key = full_name_hash(name, len);
63000 + unsigned int index = key % name_set.n_size;
63001 + struct name_entry *match;
63002 +
63003 + match = name_set.n_hash[index];
63004 +
63005 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63006 + match = match->next;
63007 +
63008 + return match;
63009 +}
63010 +
63011 +static struct name_entry *
63012 +lookup_name_entry_create(const char *name)
63013 +{
63014 + unsigned int len = strlen(name);
63015 + unsigned int key = full_name_hash(name, len);
63016 + unsigned int index = key % name_set.n_size;
63017 + struct name_entry *match;
63018 +
63019 + match = name_set.n_hash[index];
63020 +
63021 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63022 + !match->deleted))
63023 + match = match->next;
63024 +
63025 + if (match && match->deleted)
63026 + return match;
63027 +
63028 + match = name_set.n_hash[index];
63029 +
63030 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63031 + match->deleted))
63032 + match = match->next;
63033 +
63034 + if (match && !match->deleted)
63035 + return match;
63036 + else
63037 + return NULL;
63038 +}
63039 +
63040 +static struct inodev_entry *
63041 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
63042 +{
63043 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
63044 + struct inodev_entry *match;
63045 +
63046 + match = inodev_set.i_hash[index];
63047 +
63048 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63049 + match = match->next;
63050 +
63051 + return match;
63052 +}
63053 +
63054 +static void
63055 +insert_inodev_entry(struct inodev_entry *entry)
63056 +{
63057 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63058 + inodev_set.i_size);
63059 + struct inodev_entry **curr;
63060 +
63061 + entry->prev = NULL;
63062 +
63063 + curr = &inodev_set.i_hash[index];
63064 + if (*curr != NULL)
63065 + (*curr)->prev = entry;
63066 +
63067 + entry->next = *curr;
63068 + *curr = entry;
63069 +
63070 + return;
63071 +}
63072 +
63073 +static void
63074 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
63075 +{
63076 + unsigned int index =
63077 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
63078 + struct acl_role_label **curr;
63079 + struct acl_role_label *tmp, *tmp2;
63080 +
63081 + curr = &acl_role_set.r_hash[index];
63082 +
63083 + /* simple case, slot is empty, just set it to our role */
63084 + if (*curr == NULL) {
63085 + *curr = role;
63086 + } else {
63087 + /* example:
63088 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
63089 + 2 -> 3
63090 + */
63091 + /* first check to see if we can already be reached via this slot */
63092 + tmp = *curr;
63093 + while (tmp && tmp != role)
63094 + tmp = tmp->next;
63095 + if (tmp == role) {
63096 + /* we don't need to add ourselves to this slot's chain */
63097 + return;
63098 + }
63099 + /* we need to add ourselves to this chain, two cases */
63100 + if (role->next == NULL) {
63101 + /* simple case, append the current chain to our role */
63102 + role->next = *curr;
63103 + *curr = role;
63104 + } else {
63105 + /* 1 -> 2 -> 3 -> 4
63106 + 2 -> 3 -> 4
63107 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63108 + */
63109 + /* trickier case: walk our role's chain until we find
63110 + the role for the start of the current slot's chain */
63111 + tmp = role;
63112 + tmp2 = *curr;
63113 + while (tmp->next && tmp->next != tmp2)
63114 + tmp = tmp->next;
63115 + if (tmp->next == tmp2) {
63116 + /* from example above, we found 3, so just
63117 + replace this slot's chain with ours */
63118 + *curr = role;
63119 + } else {
63120 + /* we didn't find a subset of our role's chain
63121 + in the current slot's chain, so append their
63122 + chain to ours, and set us as the first role in
63123 + the slot's chain
63124 +
63125 + we could fold this case with the case above,
63126 + but making it explicit for clarity
63127 + */
63128 + tmp->next = tmp2;
63129 + *curr = role;
63130 + }
63131 + }
63132 + }
63133 +
63134 + return;
63135 +}
63136 +
63137 +static void
63138 +insert_acl_role_label(struct acl_role_label *role)
63139 +{
63140 + int i;
63141 +
63142 + if (role_list == NULL) {
63143 + role_list = role;
63144 + role->prev = NULL;
63145 + } else {
63146 + role->prev = role_list;
63147 + role_list = role;
63148 + }
63149 +
63150 + /* used for hash chains */
63151 + role->next = NULL;
63152 +
63153 + if (role->roletype & GR_ROLE_DOMAIN) {
63154 + for (i = 0; i < role->domain_child_num; i++)
63155 + __insert_acl_role_label(role, role->domain_children[i]);
63156 + } else
63157 + __insert_acl_role_label(role, role->uidgid);
63158 +}
63159 +
63160 +static int
63161 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63162 +{
63163 + struct name_entry **curr, *nentry;
63164 + struct inodev_entry *ientry;
63165 + unsigned int len = strlen(name);
63166 + unsigned int key = full_name_hash(name, len);
63167 + unsigned int index = key % name_set.n_size;
63168 +
63169 + curr = &name_set.n_hash[index];
63170 +
63171 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63172 + curr = &((*curr)->next);
63173 +
63174 + if (*curr != NULL)
63175 + return 1;
63176 +
63177 + nentry = acl_alloc(sizeof (struct name_entry));
63178 + if (nentry == NULL)
63179 + return 0;
63180 + ientry = acl_alloc(sizeof (struct inodev_entry));
63181 + if (ientry == NULL)
63182 + return 0;
63183 + ientry->nentry = nentry;
63184 +
63185 + nentry->key = key;
63186 + nentry->name = name;
63187 + nentry->inode = inode;
63188 + nentry->device = device;
63189 + nentry->len = len;
63190 + nentry->deleted = deleted;
63191 +
63192 + nentry->prev = NULL;
63193 + curr = &name_set.n_hash[index];
63194 + if (*curr != NULL)
63195 + (*curr)->prev = nentry;
63196 + nentry->next = *curr;
63197 + *curr = nentry;
63198 +
63199 + /* insert us into the table searchable by inode/dev */
63200 + insert_inodev_entry(ientry);
63201 +
63202 + return 1;
63203 +}
63204 +
63205 +static void
63206 +insert_acl_obj_label(struct acl_object_label *obj,
63207 + struct acl_subject_label *subj)
63208 +{
63209 + unsigned int index =
63210 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63211 + struct acl_object_label **curr;
63212 +
63213 +
63214 + obj->prev = NULL;
63215 +
63216 + curr = &subj->obj_hash[index];
63217 + if (*curr != NULL)
63218 + (*curr)->prev = obj;
63219 +
63220 + obj->next = *curr;
63221 + *curr = obj;
63222 +
63223 + return;
63224 +}
63225 +
63226 +static void
63227 +insert_acl_subj_label(struct acl_subject_label *obj,
63228 + struct acl_role_label *role)
63229 +{
63230 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63231 + struct acl_subject_label **curr;
63232 +
63233 + obj->prev = NULL;
63234 +
63235 + curr = &role->subj_hash[index];
63236 + if (*curr != NULL)
63237 + (*curr)->prev = obj;
63238 +
63239 + obj->next = *curr;
63240 + *curr = obj;
63241 +
63242 + return;
63243 +}
63244 +
63245 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63246 +
63247 +static void *
63248 +create_table(__u32 * len, int elementsize)
63249 +{
63250 + unsigned int table_sizes[] = {
63251 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63252 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63253 + 4194301, 8388593, 16777213, 33554393, 67108859
63254 + };
63255 + void *newtable = NULL;
63256 + unsigned int pwr = 0;
63257 +
63258 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63259 + table_sizes[pwr] <= *len)
63260 + pwr++;
63261 +
63262 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63263 + return newtable;
63264 +
63265 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63266 + newtable =
63267 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63268 + else
63269 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63270 +
63271 + *len = table_sizes[pwr];
63272 +
63273 + return newtable;
63274 +}
63275 +
63276 +static int
63277 +init_variables(const struct gr_arg *arg)
63278 +{
63279 + struct task_struct *reaper = init_pid_ns.child_reaper;
63280 + unsigned int stacksize;
63281 +
63282 + subj_map_set.s_size = arg->role_db.num_subjects;
63283 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63284 + name_set.n_size = arg->role_db.num_objects;
63285 + inodev_set.i_size = arg->role_db.num_objects;
63286 +
63287 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63288 + !name_set.n_size || !inodev_set.i_size)
63289 + return 1;
63290 +
63291 + if (!gr_init_uidset())
63292 + return 1;
63293 +
63294 + /* set up the stack that holds allocation info */
63295 +
63296 + stacksize = arg->role_db.num_pointers + 5;
63297 +
63298 + if (!acl_alloc_stack_init(stacksize))
63299 + return 1;
63300 +
63301 + /* grab reference for the real root dentry and vfsmount */
63302 + get_fs_root(reaper->fs, &real_root);
63303 +
63304 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63305 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63306 +#endif
63307 +
63308 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63309 + if (fakefs_obj_rw == NULL)
63310 + return 1;
63311 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63312 +
63313 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63314 + if (fakefs_obj_rwx == NULL)
63315 + return 1;
63316 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63317 +
63318 + subj_map_set.s_hash =
63319 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63320 + acl_role_set.r_hash =
63321 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63322 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63323 + inodev_set.i_hash =
63324 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63325 +
63326 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63327 + !name_set.n_hash || !inodev_set.i_hash)
63328 + return 1;
63329 +
63330 + memset(subj_map_set.s_hash, 0,
63331 + sizeof(struct subject_map *) * subj_map_set.s_size);
63332 + memset(acl_role_set.r_hash, 0,
63333 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63334 + memset(name_set.n_hash, 0,
63335 + sizeof (struct name_entry *) * name_set.n_size);
63336 + memset(inodev_set.i_hash, 0,
63337 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63338 +
63339 + return 0;
63340 +}
63341 +
63342 +/* free information not needed after startup
63343 + currently contains user->kernel pointer mappings for subjects
63344 +*/
63345 +
63346 +static void
63347 +free_init_variables(void)
63348 +{
63349 + __u32 i;
63350 +
63351 + if (subj_map_set.s_hash) {
63352 + for (i = 0; i < subj_map_set.s_size; i++) {
63353 + if (subj_map_set.s_hash[i]) {
63354 + kfree(subj_map_set.s_hash[i]);
63355 + subj_map_set.s_hash[i] = NULL;
63356 + }
63357 + }
63358 +
63359 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63360 + PAGE_SIZE)
63361 + kfree(subj_map_set.s_hash);
63362 + else
63363 + vfree(subj_map_set.s_hash);
63364 + }
63365 +
63366 + return;
63367 +}
63368 +
63369 +static void
63370 +free_variables(void)
63371 +{
63372 + struct acl_subject_label *s;
63373 + struct acl_role_label *r;
63374 + struct task_struct *task, *task2;
63375 + unsigned int x;
63376 +
63377 + gr_clear_learn_entries();
63378 +
63379 + read_lock(&tasklist_lock);
63380 + do_each_thread(task2, task) {
63381 + task->acl_sp_role = 0;
63382 + task->acl_role_id = 0;
63383 + task->acl = NULL;
63384 + task->role = NULL;
63385 + } while_each_thread(task2, task);
63386 + read_unlock(&tasklist_lock);
63387 +
63388 + /* release the reference to the real root dentry and vfsmount */
63389 + path_put(&real_root);
63390 + memset(&real_root, 0, sizeof(real_root));
63391 +
63392 + /* free all object hash tables */
63393 +
63394 + FOR_EACH_ROLE_START(r)
63395 + if (r->subj_hash == NULL)
63396 + goto next_role;
63397 + FOR_EACH_SUBJECT_START(r, s, x)
63398 + if (s->obj_hash == NULL)
63399 + break;
63400 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63401 + kfree(s->obj_hash);
63402 + else
63403 + vfree(s->obj_hash);
63404 + FOR_EACH_SUBJECT_END(s, x)
63405 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63406 + if (s->obj_hash == NULL)
63407 + break;
63408 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63409 + kfree(s->obj_hash);
63410 + else
63411 + vfree(s->obj_hash);
63412 + FOR_EACH_NESTED_SUBJECT_END(s)
63413 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63414 + kfree(r->subj_hash);
63415 + else
63416 + vfree(r->subj_hash);
63417 + r->subj_hash = NULL;
63418 +next_role:
63419 + FOR_EACH_ROLE_END(r)
63420 +
63421 + acl_free_all();
63422 +
63423 + if (acl_role_set.r_hash) {
63424 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63425 + PAGE_SIZE)
63426 + kfree(acl_role_set.r_hash);
63427 + else
63428 + vfree(acl_role_set.r_hash);
63429 + }
63430 + if (name_set.n_hash) {
63431 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63432 + PAGE_SIZE)
63433 + kfree(name_set.n_hash);
63434 + else
63435 + vfree(name_set.n_hash);
63436 + }
63437 +
63438 + if (inodev_set.i_hash) {
63439 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63440 + PAGE_SIZE)
63441 + kfree(inodev_set.i_hash);
63442 + else
63443 + vfree(inodev_set.i_hash);
63444 + }
63445 +
63446 + gr_free_uidset();
63447 +
63448 + memset(&name_set, 0, sizeof (struct name_db));
63449 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63450 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63451 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63452 +
63453 + default_role = NULL;
63454 + kernel_role = NULL;
63455 + role_list = NULL;
63456 +
63457 + return;
63458 +}
63459 +
63460 +static struct acl_subject_label *
63461 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63462 +
63463 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63464 +{
63465 + unsigned int len = strnlen_user(*name, maxlen);
63466 + char *tmp;
63467 +
63468 + if (!len || len >= maxlen)
63469 + return -EINVAL;
63470 +
63471 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63472 + return -ENOMEM;
63473 +
63474 + if (copy_from_user(tmp, *name, len))
63475 + return -EFAULT;
63476 +
63477 + tmp[len-1] = '\0';
63478 + *name = tmp;
63479 +
63480 + return 0;
63481 +}
63482 +
63483 +static int
63484 +copy_user_glob(struct acl_object_label *obj)
63485 +{
63486 + struct acl_object_label *g_tmp, **guser;
63487 + int error;
63488 +
63489 + if (obj->globbed == NULL)
63490 + return 0;
63491 +
63492 + guser = &obj->globbed;
63493 + while (*guser) {
63494 + g_tmp = (struct acl_object_label *)
63495 + acl_alloc(sizeof (struct acl_object_label));
63496 + if (g_tmp == NULL)
63497 + return -ENOMEM;
63498 +
63499 + if (copy_acl_object_label(g_tmp, *guser))
63500 + return -EFAULT;
63501 +
63502 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63503 + if (error)
63504 + return error;
63505 +
63506 + *guser = g_tmp;
63507 + guser = &(g_tmp->next);
63508 + }
63509 +
63510 + return 0;
63511 +}
63512 +
63513 +static int
63514 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63515 + struct acl_role_label *role)
63516 +{
63517 + struct acl_object_label *o_tmp;
63518 + int ret;
63519 +
63520 + while (userp) {
63521 + if ((o_tmp = (struct acl_object_label *)
63522 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63523 + return -ENOMEM;
63524 +
63525 + if (copy_acl_object_label(o_tmp, userp))
63526 + return -EFAULT;
63527 +
63528 + userp = o_tmp->prev;
63529 +
63530 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63531 + if (ret)
63532 + return ret;
63533 +
63534 + insert_acl_obj_label(o_tmp, subj);
63535 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63536 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63537 + return -ENOMEM;
63538 +
63539 + ret = copy_user_glob(o_tmp);
63540 + if (ret)
63541 + return ret;
63542 +
63543 + if (o_tmp->nested) {
63544 + int already_copied;
63545 +
63546 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63547 + if (IS_ERR(o_tmp->nested))
63548 + return PTR_ERR(o_tmp->nested);
63549 +
63550 + /* insert into nested subject list if we haven't copied this one yet
63551 + to prevent duplicate entries */
63552 + if (!already_copied) {
63553 + o_tmp->nested->next = role->hash->first;
63554 + role->hash->first = o_tmp->nested;
63555 + }
63556 + }
63557 + }
63558 +
63559 + return 0;
63560 +}
63561 +
63562 +static __u32
63563 +count_user_subjs(struct acl_subject_label *userp)
63564 +{
63565 + struct acl_subject_label s_tmp;
63566 + __u32 num = 0;
63567 +
63568 + while (userp) {
63569 + if (copy_acl_subject_label(&s_tmp, userp))
63570 + break;
63571 +
63572 + userp = s_tmp.prev;
63573 + }
63574 +
63575 + return num;
63576 +}
63577 +
63578 +static int
63579 +copy_user_allowedips(struct acl_role_label *rolep)
63580 +{
63581 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63582 +
63583 + ruserip = rolep->allowed_ips;
63584 +
63585 + while (ruserip) {
63586 + rlast = rtmp;
63587 +
63588 + if ((rtmp = (struct role_allowed_ip *)
63589 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63590 + return -ENOMEM;
63591 +
63592 + if (copy_role_allowed_ip(rtmp, ruserip))
63593 + return -EFAULT;
63594 +
63595 + ruserip = rtmp->prev;
63596 +
63597 + if (!rlast) {
63598 + rtmp->prev = NULL;
63599 + rolep->allowed_ips = rtmp;
63600 + } else {
63601 + rlast->next = rtmp;
63602 + rtmp->prev = rlast;
63603 + }
63604 +
63605 + if (!ruserip)
63606 + rtmp->next = NULL;
63607 + }
63608 +
63609 + return 0;
63610 +}
63611 +
63612 +static int
63613 +copy_user_transitions(struct acl_role_label *rolep)
63614 +{
63615 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63616 + int error;
63617 +
63618 + rusertp = rolep->transitions;
63619 +
63620 + while (rusertp) {
63621 + rlast = rtmp;
63622 +
63623 + if ((rtmp = (struct role_transition *)
63624 + acl_alloc(sizeof (struct role_transition))) == NULL)
63625 + return -ENOMEM;
63626 +
63627 + if (copy_role_transition(rtmp, rusertp))
63628 + return -EFAULT;
63629 +
63630 + rusertp = rtmp->prev;
63631 +
63632 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63633 + if (error)
63634 + return error;
63635 +
63636 + if (!rlast) {
63637 + rtmp->prev = NULL;
63638 + rolep->transitions = rtmp;
63639 + } else {
63640 + rlast->next = rtmp;
63641 + rtmp->prev = rlast;
63642 + }
63643 +
63644 + if (!rusertp)
63645 + rtmp->next = NULL;
63646 + }
63647 +
63648 + return 0;
63649 +}
63650 +
63651 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63652 +{
63653 + struct acl_object_label o_tmp;
63654 + __u32 num = 0;
63655 +
63656 + while (userp) {
63657 + if (copy_acl_object_label(&o_tmp, userp))
63658 + break;
63659 +
63660 + userp = o_tmp.prev;
63661 + num++;
63662 + }
63663 +
63664 + return num;
63665 +}
63666 +
63667 +static struct acl_subject_label *
63668 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63669 +{
63670 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63671 + __u32 num_objs;
63672 + struct acl_ip_label **i_tmp, *i_utmp2;
63673 + struct gr_hash_struct ghash;
63674 + struct subject_map *subjmap;
63675 + unsigned int i_num;
63676 + int err;
63677 +
63678 + if (already_copied != NULL)
63679 + *already_copied = 0;
63680 +
63681 + s_tmp = lookup_subject_map(userp);
63682 +
63683 + /* we've already copied this subject into the kernel, just return
63684 + the reference to it, and don't copy it over again
63685 + */
63686 + if (s_tmp) {
63687 + if (already_copied != NULL)
63688 + *already_copied = 1;
63689 + return(s_tmp);
63690 + }
63691 +
63692 + if ((s_tmp = (struct acl_subject_label *)
63693 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63694 + return ERR_PTR(-ENOMEM);
63695 +
63696 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63697 + if (subjmap == NULL)
63698 + return ERR_PTR(-ENOMEM);
63699 +
63700 + subjmap->user = userp;
63701 + subjmap->kernel = s_tmp;
63702 + insert_subj_map_entry(subjmap);
63703 +
63704 + if (copy_acl_subject_label(s_tmp, userp))
63705 + return ERR_PTR(-EFAULT);
63706 +
63707 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63708 + if (err)
63709 + return ERR_PTR(err);
63710 +
63711 + if (!strcmp(s_tmp->filename, "/"))
63712 + role->root_label = s_tmp;
63713 +
63714 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63715 + return ERR_PTR(-EFAULT);
63716 +
63717 + /* copy user and group transition tables */
63718 +
63719 + if (s_tmp->user_trans_num) {
63720 + uid_t *uidlist;
63721 +
63722 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63723 + if (uidlist == NULL)
63724 + return ERR_PTR(-ENOMEM);
63725 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63726 + return ERR_PTR(-EFAULT);
63727 +
63728 + s_tmp->user_transitions = uidlist;
63729 + }
63730 +
63731 + if (s_tmp->group_trans_num) {
63732 + gid_t *gidlist;
63733 +
63734 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63735 + if (gidlist == NULL)
63736 + return ERR_PTR(-ENOMEM);
63737 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63738 + return ERR_PTR(-EFAULT);
63739 +
63740 + s_tmp->group_transitions = gidlist;
63741 + }
63742 +
63743 + /* set up object hash table */
63744 + num_objs = count_user_objs(ghash.first);
63745 +
63746 + s_tmp->obj_hash_size = num_objs;
63747 + s_tmp->obj_hash =
63748 + (struct acl_object_label **)
63749 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63750 +
63751 + if (!s_tmp->obj_hash)
63752 + return ERR_PTR(-ENOMEM);
63753 +
63754 + memset(s_tmp->obj_hash, 0,
63755 + s_tmp->obj_hash_size *
63756 + sizeof (struct acl_object_label *));
63757 +
63758 + /* add in objects */
63759 + err = copy_user_objs(ghash.first, s_tmp, role);
63760 +
63761 + if (err)
63762 + return ERR_PTR(err);
63763 +
63764 + /* set pointer for parent subject */
63765 + if (s_tmp->parent_subject) {
63766 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63767 +
63768 + if (IS_ERR(s_tmp2))
63769 + return s_tmp2;
63770 +
63771 + s_tmp->parent_subject = s_tmp2;
63772 + }
63773 +
63774 + /* add in ip acls */
63775 +
63776 + if (!s_tmp->ip_num) {
63777 + s_tmp->ips = NULL;
63778 + goto insert;
63779 + }
63780 +
63781 + i_tmp =
63782 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63783 + sizeof (struct acl_ip_label *));
63784 +
63785 + if (!i_tmp)
63786 + return ERR_PTR(-ENOMEM);
63787 +
63788 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63789 + *(i_tmp + i_num) =
63790 + (struct acl_ip_label *)
63791 + acl_alloc(sizeof (struct acl_ip_label));
63792 + if (!*(i_tmp + i_num))
63793 + return ERR_PTR(-ENOMEM);
63794 +
63795 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63796 + return ERR_PTR(-EFAULT);
63797 +
63798 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63799 + return ERR_PTR(-EFAULT);
63800 +
63801 + if ((*(i_tmp + i_num))->iface == NULL)
63802 + continue;
63803 +
63804 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63805 + if (err)
63806 + return ERR_PTR(err);
63807 + }
63808 +
63809 + s_tmp->ips = i_tmp;
63810 +
63811 +insert:
63812 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63813 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63814 + return ERR_PTR(-ENOMEM);
63815 +
63816 + return s_tmp;
63817 +}
63818 +
63819 +static int
63820 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63821 +{
63822 + struct acl_subject_label s_pre;
63823 + struct acl_subject_label * ret;
63824 + int err;
63825 +
63826 + while (userp) {
63827 + if (copy_acl_subject_label(&s_pre, userp))
63828 + return -EFAULT;
63829 +
63830 + ret = do_copy_user_subj(userp, role, NULL);
63831 +
63832 + err = PTR_ERR(ret);
63833 + if (IS_ERR(ret))
63834 + return err;
63835 +
63836 + insert_acl_subj_label(ret, role);
63837 +
63838 + userp = s_pre.prev;
63839 + }
63840 +
63841 + return 0;
63842 +}
63843 +
63844 +static int
63845 +copy_user_acl(struct gr_arg *arg)
63846 +{
63847 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63848 + struct acl_subject_label *subj_list;
63849 + struct sprole_pw *sptmp;
63850 + struct gr_hash_struct *ghash;
63851 + uid_t *domainlist;
63852 + unsigned int r_num;
63853 + int err = 0;
63854 + __u16 i;
63855 + __u32 num_subjs;
63856 +
63857 + /* we need a default and kernel role */
63858 + if (arg->role_db.num_roles < 2)
63859 + return -EINVAL;
63860 +
63861 + /* copy special role authentication info from userspace */
63862 +
63863 + num_sprole_pws = arg->num_sprole_pws;
63864 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63865 +
63866 + if (!acl_special_roles && num_sprole_pws)
63867 + return -ENOMEM;
63868 +
63869 + for (i = 0; i < num_sprole_pws; i++) {
63870 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63871 + if (!sptmp)
63872 + return -ENOMEM;
63873 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63874 + return -EFAULT;
63875 +
63876 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63877 + if (err)
63878 + return err;
63879 +
63880 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63881 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63882 +#endif
63883 +
63884 + acl_special_roles[i] = sptmp;
63885 + }
63886 +
63887 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63888 +
63889 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63890 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63891 +
63892 + if (!r_tmp)
63893 + return -ENOMEM;
63894 +
63895 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63896 + return -EFAULT;
63897 +
63898 + if (copy_acl_role_label(r_tmp, r_utmp2))
63899 + return -EFAULT;
63900 +
63901 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63902 + if (err)
63903 + return err;
63904 +
63905 + if (!strcmp(r_tmp->rolename, "default")
63906 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63907 + default_role = r_tmp;
63908 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63909 + kernel_role = r_tmp;
63910 + }
63911 +
63912 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63913 + return -ENOMEM;
63914 +
63915 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63916 + return -EFAULT;
63917 +
63918 + r_tmp->hash = ghash;
63919 +
63920 + num_subjs = count_user_subjs(r_tmp->hash->first);
63921 +
63922 + r_tmp->subj_hash_size = num_subjs;
63923 + r_tmp->subj_hash =
63924 + (struct acl_subject_label **)
63925 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63926 +
63927 + if (!r_tmp->subj_hash)
63928 + return -ENOMEM;
63929 +
63930 + err = copy_user_allowedips(r_tmp);
63931 + if (err)
63932 + return err;
63933 +
63934 + /* copy domain info */
63935 + if (r_tmp->domain_children != NULL) {
63936 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63937 + if (domainlist == NULL)
63938 + return -ENOMEM;
63939 +
63940 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63941 + return -EFAULT;
63942 +
63943 + r_tmp->domain_children = domainlist;
63944 + }
63945 +
63946 + err = copy_user_transitions(r_tmp);
63947 + if (err)
63948 + return err;
63949 +
63950 + memset(r_tmp->subj_hash, 0,
63951 + r_tmp->subj_hash_size *
63952 + sizeof (struct acl_subject_label *));
63953 +
63954 + /* acquire the list of subjects, then NULL out
63955 + the list prior to parsing the subjects for this role,
63956 + as during this parsing the list is replaced with a list
63957 + of *nested* subjects for the role
63958 + */
63959 + subj_list = r_tmp->hash->first;
63960 +
63961 + /* set nested subject list to null */
63962 + r_tmp->hash->first = NULL;
63963 +
63964 + err = copy_user_subjs(subj_list, r_tmp);
63965 +
63966 + if (err)
63967 + return err;
63968 +
63969 + insert_acl_role_label(r_tmp);
63970 + }
63971 +
63972 + if (default_role == NULL || kernel_role == NULL)
63973 + return -EINVAL;
63974 +
63975 + return err;
63976 +}
63977 +
63978 +static int
63979 +gracl_init(struct gr_arg *args)
63980 +{
63981 + int error = 0;
63982 +
63983 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63984 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63985 +
63986 + if (init_variables(args)) {
63987 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63988 + error = -ENOMEM;
63989 + free_variables();
63990 + goto out;
63991 + }
63992 +
63993 + error = copy_user_acl(args);
63994 + free_init_variables();
63995 + if (error) {
63996 + free_variables();
63997 + goto out;
63998 + }
63999 +
64000 + if ((error = gr_set_acls(0))) {
64001 + free_variables();
64002 + goto out;
64003 + }
64004 +
64005 + pax_open_kernel();
64006 + gr_status |= GR_READY;
64007 + pax_close_kernel();
64008 +
64009 + out:
64010 + return error;
64011 +}
64012 +
64013 +/* derived from glibc fnmatch() 0: match, 1: no match*/
64014 +
64015 +static int
64016 +glob_match(const char *p, const char *n)
64017 +{
64018 + char c;
64019 +
64020 + while ((c = *p++) != '\0') {
64021 + switch (c) {
64022 + case '?':
64023 + if (*n == '\0')
64024 + return 1;
64025 + else if (*n == '/')
64026 + return 1;
64027 + break;
64028 + case '\\':
64029 + if (*n != c)
64030 + return 1;
64031 + break;
64032 + case '*':
64033 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
64034 + if (*n == '/')
64035 + return 1;
64036 + else if (c == '?') {
64037 + if (*n == '\0')
64038 + return 1;
64039 + else
64040 + ++n;
64041 + }
64042 + }
64043 + if (c == '\0') {
64044 + return 0;
64045 + } else {
64046 + const char *endp;
64047 +
64048 + if ((endp = strchr(n, '/')) == NULL)
64049 + endp = n + strlen(n);
64050 +
64051 + if (c == '[') {
64052 + for (--p; n < endp; ++n)
64053 + if (!glob_match(p, n))
64054 + return 0;
64055 + } else if (c == '/') {
64056 + while (*n != '\0' && *n != '/')
64057 + ++n;
64058 + if (*n == '/' && !glob_match(p, n + 1))
64059 + return 0;
64060 + } else {
64061 + for (--p; n < endp; ++n)
64062 + if (*n == c && !glob_match(p, n))
64063 + return 0;
64064 + }
64065 +
64066 + return 1;
64067 + }
64068 + case '[':
64069 + {
64070 + int not;
64071 + char cold;
64072 +
64073 + if (*n == '\0' || *n == '/')
64074 + return 1;
64075 +
64076 + not = (*p == '!' || *p == '^');
64077 + if (not)
64078 + ++p;
64079 +
64080 + c = *p++;
64081 + for (;;) {
64082 + unsigned char fn = (unsigned char)*n;
64083 +
64084 + if (c == '\0')
64085 + return 1;
64086 + else {
64087 + if (c == fn)
64088 + goto matched;
64089 + cold = c;
64090 + c = *p++;
64091 +
64092 + if (c == '-' && *p != ']') {
64093 + unsigned char cend = *p++;
64094 +
64095 + if (cend == '\0')
64096 + return 1;
64097 +
64098 + if (cold <= fn && fn <= cend)
64099 + goto matched;
64100 +
64101 + c = *p++;
64102 + }
64103 + }
64104 +
64105 + if (c == ']')
64106 + break;
64107 + }
64108 + if (!not)
64109 + return 1;
64110 + break;
64111 + matched:
64112 + while (c != ']') {
64113 + if (c == '\0')
64114 + return 1;
64115 +
64116 + c = *p++;
64117 + }
64118 + if (not)
64119 + return 1;
64120 + }
64121 + break;
64122 + default:
64123 + if (c != *n)
64124 + return 1;
64125 + }
64126 +
64127 + ++n;
64128 + }
64129 +
64130 + if (*n == '\0')
64131 + return 0;
64132 +
64133 + if (*n == '/')
64134 + return 0;
64135 +
64136 + return 1;
64137 +}
64138 +
64139 +static struct acl_object_label *
64140 +chk_glob_label(struct acl_object_label *globbed,
64141 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64142 +{
64143 + struct acl_object_label *tmp;
64144 +
64145 + if (*path == NULL)
64146 + *path = gr_to_filename_nolock(dentry, mnt);
64147 +
64148 + tmp = globbed;
64149 +
64150 + while (tmp) {
64151 + if (!glob_match(tmp->filename, *path))
64152 + return tmp;
64153 + tmp = tmp->next;
64154 + }
64155 +
64156 + return NULL;
64157 +}
64158 +
64159 +static struct acl_object_label *
64160 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64161 + const ino_t curr_ino, const dev_t curr_dev,
64162 + const struct acl_subject_label *subj, char **path, const int checkglob)
64163 +{
64164 + struct acl_subject_label *tmpsubj;
64165 + struct acl_object_label *retval;
64166 + struct acl_object_label *retval2;
64167 +
64168 + tmpsubj = (struct acl_subject_label *) subj;
64169 + read_lock(&gr_inode_lock);
64170 + do {
64171 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64172 + if (retval) {
64173 + if (checkglob && retval->globbed) {
64174 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64175 + if (retval2)
64176 + retval = retval2;
64177 + }
64178 + break;
64179 + }
64180 + } while ((tmpsubj = tmpsubj->parent_subject));
64181 + read_unlock(&gr_inode_lock);
64182 +
64183 + return retval;
64184 +}
64185 +
64186 +static __inline__ struct acl_object_label *
64187 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64188 + struct dentry *curr_dentry,
64189 + const struct acl_subject_label *subj, char **path, const int checkglob)
64190 +{
64191 + int newglob = checkglob;
64192 + ino_t inode;
64193 + dev_t device;
64194 +
64195 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64196 + as we don't want a / * rule to match instead of the / object
64197 + don't do this for create lookups that call this function though, since they're looking up
64198 + on the parent and thus need globbing checks on all paths
64199 + */
64200 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64201 + newglob = GR_NO_GLOB;
64202 +
64203 + spin_lock(&curr_dentry->d_lock);
64204 + inode = curr_dentry->d_inode->i_ino;
64205 + device = __get_dev(curr_dentry);
64206 + spin_unlock(&curr_dentry->d_lock);
64207 +
64208 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64209 +}
64210 +
64211 +#ifdef CONFIG_HUGETLBFS
64212 +static inline bool
64213 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64214 +{
64215 + int i;
64216 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64217 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64218 + return true;
64219 + }
64220 +
64221 + return false;
64222 +}
64223 +#endif
64224 +
64225 +static struct acl_object_label *
64226 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64227 + const struct acl_subject_label *subj, char *path, const int checkglob)
64228 +{
64229 + struct dentry *dentry = (struct dentry *) l_dentry;
64230 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64231 + struct mount *real_mnt = real_mount(mnt);
64232 + struct acl_object_label *retval;
64233 + struct dentry *parent;
64234 +
64235 + br_read_lock(&vfsmount_lock);
64236 + write_seqlock(&rename_lock);
64237 +
64238 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64239 +#ifdef CONFIG_NET
64240 + mnt == sock_mnt ||
64241 +#endif
64242 +#ifdef CONFIG_HUGETLBFS
64243 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64244 +#endif
64245 + /* ignore Eric Biederman */
64246 + IS_PRIVATE(l_dentry->d_inode))) {
64247 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64248 + goto out;
64249 + }
64250 +
64251 + for (;;) {
64252 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64253 + break;
64254 +
64255 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64256 + if (!mnt_has_parent(real_mnt))
64257 + break;
64258 +
64259 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64260 + if (retval != NULL)
64261 + goto out;
64262 +
64263 + dentry = real_mnt->mnt_mountpoint;
64264 + real_mnt = real_mnt->mnt_parent;
64265 + mnt = &real_mnt->mnt;
64266 + continue;
64267 + }
64268 +
64269 + parent = dentry->d_parent;
64270 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64271 + if (retval != NULL)
64272 + goto out;
64273 +
64274 + dentry = parent;
64275 + }
64276 +
64277 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64278 +
64279 + /* real_root is pinned so we don't have to hold a reference */
64280 + if (retval == NULL)
64281 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64282 +out:
64283 + write_sequnlock(&rename_lock);
64284 + br_read_unlock(&vfsmount_lock);
64285 +
64286 + BUG_ON(retval == NULL);
64287 +
64288 + return retval;
64289 +}
64290 +
64291 +static __inline__ struct acl_object_label *
64292 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64293 + const struct acl_subject_label *subj)
64294 +{
64295 + char *path = NULL;
64296 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64297 +}
64298 +
64299 +static __inline__ struct acl_object_label *
64300 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64301 + const struct acl_subject_label *subj)
64302 +{
64303 + char *path = NULL;
64304 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64305 +}
64306 +
64307 +static __inline__ struct acl_object_label *
64308 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64309 + const struct acl_subject_label *subj, char *path)
64310 +{
64311 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64312 +}
64313 +
64314 +static struct acl_subject_label *
64315 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64316 + const struct acl_role_label *role)
64317 +{
64318 + struct dentry *dentry = (struct dentry *) l_dentry;
64319 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64320 + struct mount *real_mnt = real_mount(mnt);
64321 + struct acl_subject_label *retval;
64322 + struct dentry *parent;
64323 +
64324 + br_read_lock(&vfsmount_lock);
64325 + write_seqlock(&rename_lock);
64326 +
64327 + for (;;) {
64328 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64329 + break;
64330 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64331 + if (!mnt_has_parent(real_mnt))
64332 + break;
64333 +
64334 + spin_lock(&dentry->d_lock);
64335 + read_lock(&gr_inode_lock);
64336 + retval =
64337 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64338 + __get_dev(dentry), role);
64339 + read_unlock(&gr_inode_lock);
64340 + spin_unlock(&dentry->d_lock);
64341 + if (retval != NULL)
64342 + goto out;
64343 +
64344 + dentry = real_mnt->mnt_mountpoint;
64345 + real_mnt = real_mnt->mnt_parent;
64346 + mnt = &real_mnt->mnt;
64347 + continue;
64348 + }
64349 +
64350 + spin_lock(&dentry->d_lock);
64351 + read_lock(&gr_inode_lock);
64352 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64353 + __get_dev(dentry), role);
64354 + read_unlock(&gr_inode_lock);
64355 + parent = dentry->d_parent;
64356 + spin_unlock(&dentry->d_lock);
64357 +
64358 + if (retval != NULL)
64359 + goto out;
64360 +
64361 + dentry = parent;
64362 + }
64363 +
64364 + spin_lock(&dentry->d_lock);
64365 + read_lock(&gr_inode_lock);
64366 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64367 + __get_dev(dentry), role);
64368 + read_unlock(&gr_inode_lock);
64369 + spin_unlock(&dentry->d_lock);
64370 +
64371 + if (unlikely(retval == NULL)) {
64372 + /* real_root is pinned, we don't need to hold a reference */
64373 + read_lock(&gr_inode_lock);
64374 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64375 + __get_dev(real_root.dentry), role);
64376 + read_unlock(&gr_inode_lock);
64377 + }
64378 +out:
64379 + write_sequnlock(&rename_lock);
64380 + br_read_unlock(&vfsmount_lock);
64381 +
64382 + BUG_ON(retval == NULL);
64383 +
64384 + return retval;
64385 +}
64386 +
64387 +static void
64388 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64389 +{
64390 + struct task_struct *task = current;
64391 + const struct cred *cred = current_cred();
64392 +
64393 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64394 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64395 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64396 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64397 +
64398 + return;
64399 +}
64400 +
64401 +static void
64402 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64403 +{
64404 + struct task_struct *task = current;
64405 + const struct cred *cred = current_cred();
64406 +
64407 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64408 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64409 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64410 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64411 +
64412 + return;
64413 +}
64414 +
64415 +static void
64416 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64417 +{
64418 + struct task_struct *task = current;
64419 + const struct cred *cred = current_cred();
64420 +
64421 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64422 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64423 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64424 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64425 +
64426 + return;
64427 +}
64428 +
64429 +__u32
64430 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64431 + const struct vfsmount * mnt)
64432 +{
64433 + __u32 retval = mode;
64434 + struct acl_subject_label *curracl;
64435 + struct acl_object_label *currobj;
64436 +
64437 + if (unlikely(!(gr_status & GR_READY)))
64438 + return (mode & ~GR_AUDITS);
64439 +
64440 + curracl = current->acl;
64441 +
64442 + currobj = chk_obj_label(dentry, mnt, curracl);
64443 + retval = currobj->mode & mode;
64444 +
64445 + /* if we're opening a specified transfer file for writing
64446 + (e.g. /dev/initctl), then transfer our role to init
64447 + */
64448 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64449 + current->role->roletype & GR_ROLE_PERSIST)) {
64450 + struct task_struct *task = init_pid_ns.child_reaper;
64451 +
64452 + if (task->role != current->role) {
64453 + task->acl_sp_role = 0;
64454 + task->acl_role_id = current->acl_role_id;
64455 + task->role = current->role;
64456 + rcu_read_lock();
64457 + read_lock(&grsec_exec_file_lock);
64458 + gr_apply_subject_to_task(task);
64459 + read_unlock(&grsec_exec_file_lock);
64460 + rcu_read_unlock();
64461 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64462 + }
64463 + }
64464 +
64465 + if (unlikely
64466 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64467 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64468 + __u32 new_mode = mode;
64469 +
64470 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64471 +
64472 + retval = new_mode;
64473 +
64474 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64475 + new_mode |= GR_INHERIT;
64476 +
64477 + if (!(mode & GR_NOLEARN))
64478 + gr_log_learn(dentry, mnt, new_mode);
64479 + }
64480 +
64481 + return retval;
64482 +}
64483 +
64484 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64485 + const struct dentry *parent,
64486 + const struct vfsmount *mnt)
64487 +{
64488 + struct name_entry *match;
64489 + struct acl_object_label *matchpo;
64490 + struct acl_subject_label *curracl;
64491 + char *path;
64492 +
64493 + if (unlikely(!(gr_status & GR_READY)))
64494 + return NULL;
64495 +
64496 + preempt_disable();
64497 + path = gr_to_filename_rbac(new_dentry, mnt);
64498 + match = lookup_name_entry_create(path);
64499 +
64500 + curracl = current->acl;
64501 +
64502 + if (match) {
64503 + read_lock(&gr_inode_lock);
64504 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64505 + read_unlock(&gr_inode_lock);
64506 +
64507 + if (matchpo) {
64508 + preempt_enable();
64509 + return matchpo;
64510 + }
64511 + }
64512 +
64513 + // lookup parent
64514 +
64515 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64516 +
64517 + preempt_enable();
64518 + return matchpo;
64519 +}
64520 +
64521 +__u32
64522 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64523 + const struct vfsmount * mnt, const __u32 mode)
64524 +{
64525 + struct acl_object_label *matchpo;
64526 + __u32 retval;
64527 +
64528 + if (unlikely(!(gr_status & GR_READY)))
64529 + return (mode & ~GR_AUDITS);
64530 +
64531 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64532 +
64533 + retval = matchpo->mode & mode;
64534 +
64535 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64536 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64537 + __u32 new_mode = mode;
64538 +
64539 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64540 +
64541 + gr_log_learn(new_dentry, mnt, new_mode);
64542 + return new_mode;
64543 + }
64544 +
64545 + return retval;
64546 +}
64547 +
64548 +__u32
64549 +gr_check_link(const struct dentry * new_dentry,
64550 + const struct dentry * parent_dentry,
64551 + const struct vfsmount * parent_mnt,
64552 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64553 +{
64554 + struct acl_object_label *obj;
64555 + __u32 oldmode, newmode;
64556 + __u32 needmode;
64557 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64558 + GR_DELETE | GR_INHERIT;
64559 +
64560 + if (unlikely(!(gr_status & GR_READY)))
64561 + return (GR_CREATE | GR_LINK);
64562 +
64563 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64564 + oldmode = obj->mode;
64565 +
64566 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64567 + newmode = obj->mode;
64568 +
64569 + needmode = newmode & checkmodes;
64570 +
64571 + // old name for hardlink must have at least the permissions of the new name
64572 + if ((oldmode & needmode) != needmode)
64573 + goto bad;
64574 +
64575 + // if old name had restrictions/auditing, make sure the new name does as well
64576 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64577 +
64578 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64579 + if (is_privileged_binary(old_dentry))
64580 + needmode |= GR_SETID;
64581 +
64582 + if ((newmode & needmode) != needmode)
64583 + goto bad;
64584 +
64585 + // enforce minimum permissions
64586 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64587 + return newmode;
64588 +bad:
64589 + needmode = oldmode;
64590 + if (is_privileged_binary(old_dentry))
64591 + needmode |= GR_SETID;
64592 +
64593 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64594 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64595 + return (GR_CREATE | GR_LINK);
64596 + } else if (newmode & GR_SUPPRESS)
64597 + return GR_SUPPRESS;
64598 + else
64599 + return 0;
64600 +}
64601 +
64602 +int
64603 +gr_check_hidden_task(const struct task_struct *task)
64604 +{
64605 + if (unlikely(!(gr_status & GR_READY)))
64606 + return 0;
64607 +
64608 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64609 + return 1;
64610 +
64611 + return 0;
64612 +}
64613 +
64614 +int
64615 +gr_check_protected_task(const struct task_struct *task)
64616 +{
64617 + if (unlikely(!(gr_status & GR_READY) || !task))
64618 + return 0;
64619 +
64620 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64621 + task->acl != current->acl)
64622 + return 1;
64623 +
64624 + return 0;
64625 +}
64626 +
64627 +int
64628 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64629 +{
64630 + struct task_struct *p;
64631 + int ret = 0;
64632 +
64633 + if (unlikely(!(gr_status & GR_READY) || !pid))
64634 + return ret;
64635 +
64636 + read_lock(&tasklist_lock);
64637 + do_each_pid_task(pid, type, p) {
64638 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64639 + p->acl != current->acl) {
64640 + ret = 1;
64641 + goto out;
64642 + }
64643 + } while_each_pid_task(pid, type, p);
64644 +out:
64645 + read_unlock(&tasklist_lock);
64646 +
64647 + return ret;
64648 +}
64649 +
64650 +void
64651 +gr_copy_label(struct task_struct *tsk)
64652 +{
64653 + tsk->signal->used_accept = 0;
64654 + tsk->acl_sp_role = 0;
64655 + tsk->acl_role_id = current->acl_role_id;
64656 + tsk->acl = current->acl;
64657 + tsk->role = current->role;
64658 + tsk->signal->curr_ip = current->signal->curr_ip;
64659 + tsk->signal->saved_ip = current->signal->saved_ip;
64660 + if (current->exec_file)
64661 + get_file(current->exec_file);
64662 + tsk->exec_file = current->exec_file;
64663 + tsk->is_writable = current->is_writable;
64664 + if (unlikely(current->signal->used_accept)) {
64665 + current->signal->curr_ip = 0;
64666 + current->signal->saved_ip = 0;
64667 + }
64668 +
64669 + return;
64670 +}
64671 +
64672 +static void
64673 +gr_set_proc_res(struct task_struct *task)
64674 +{
64675 + struct acl_subject_label *proc;
64676 + unsigned short i;
64677 +
64678 + proc = task->acl;
64679 +
64680 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64681 + return;
64682 +
64683 + for (i = 0; i < RLIM_NLIMITS; i++) {
64684 + if (!(proc->resmask & (1U << i)))
64685 + continue;
64686 +
64687 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64688 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64689 +
64690 + if (i == RLIMIT_CPU)
64691 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64692 + }
64693 +
64694 + return;
64695 +}
64696 +
64697 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64698 +
64699 +int
64700 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64701 +{
64702 + unsigned int i;
64703 + __u16 num;
64704 + uid_t *uidlist;
64705 + uid_t curuid;
64706 + int realok = 0;
64707 + int effectiveok = 0;
64708 + int fsok = 0;
64709 + uid_t globalreal, globaleffective, globalfs;
64710 +
64711 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64712 + struct user_struct *user;
64713 +
64714 + if (!uid_valid(real))
64715 + goto skipit;
64716 +
64717 + /* find user based on global namespace */
64718 +
64719 + globalreal = GR_GLOBAL_UID(real);
64720 +
64721 + user = find_user(make_kuid(&init_user_ns, globalreal));
64722 + if (user == NULL)
64723 + goto skipit;
64724 +
64725 + if (gr_process_kernel_setuid_ban(user)) {
64726 + /* for find_user */
64727 + free_uid(user);
64728 + return 1;
64729 + }
64730 +
64731 + /* for find_user */
64732 + free_uid(user);
64733 +
64734 +skipit:
64735 +#endif
64736 +
64737 + if (unlikely(!(gr_status & GR_READY)))
64738 + return 0;
64739 +
64740 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64741 + gr_log_learn_uid_change(real, effective, fs);
64742 +
64743 + num = current->acl->user_trans_num;
64744 + uidlist = current->acl->user_transitions;
64745 +
64746 + if (uidlist == NULL)
64747 + return 0;
64748 +
64749 + if (!uid_valid(real)) {
64750 + realok = 1;
64751 + globalreal = (uid_t)-1;
64752 + } else {
64753 + globalreal = GR_GLOBAL_UID(real);
64754 + }
64755 + if (!uid_valid(effective)) {
64756 + effectiveok = 1;
64757 + globaleffective = (uid_t)-1;
64758 + } else {
64759 + globaleffective = GR_GLOBAL_UID(effective);
64760 + }
64761 + if (!uid_valid(fs)) {
64762 + fsok = 1;
64763 + globalfs = (uid_t)-1;
64764 + } else {
64765 + globalfs = GR_GLOBAL_UID(fs);
64766 + }
64767 +
64768 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64769 + for (i = 0; i < num; i++) {
64770 + curuid = uidlist[i];
64771 + if (globalreal == curuid)
64772 + realok = 1;
64773 + if (globaleffective == curuid)
64774 + effectiveok = 1;
64775 + if (globalfs == curuid)
64776 + fsok = 1;
64777 + }
64778 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64779 + for (i = 0; i < num; i++) {
64780 + curuid = uidlist[i];
64781 + if (globalreal == curuid)
64782 + break;
64783 + if (globaleffective == curuid)
64784 + break;
64785 + if (globalfs == curuid)
64786 + break;
64787 + }
64788 + /* not in deny list */
64789 + if (i == num) {
64790 + realok = 1;
64791 + effectiveok = 1;
64792 + fsok = 1;
64793 + }
64794 + }
64795 +
64796 + if (realok && effectiveok && fsok)
64797 + return 0;
64798 + else {
64799 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64800 + return 1;
64801 + }
64802 +}
64803 +
64804 +int
64805 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64806 +{
64807 + unsigned int i;
64808 + __u16 num;
64809 + gid_t *gidlist;
64810 + gid_t curgid;
64811 + int realok = 0;
64812 + int effectiveok = 0;
64813 + int fsok = 0;
64814 + gid_t globalreal, globaleffective, globalfs;
64815 +
64816 + if (unlikely(!(gr_status & GR_READY)))
64817 + return 0;
64818 +
64819 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64820 + gr_log_learn_gid_change(real, effective, fs);
64821 +
64822 + num = current->acl->group_trans_num;
64823 + gidlist = current->acl->group_transitions;
64824 +
64825 + if (gidlist == NULL)
64826 + return 0;
64827 +
64828 + if (!gid_valid(real)) {
64829 + realok = 1;
64830 + globalreal = (gid_t)-1;
64831 + } else {
64832 + globalreal = GR_GLOBAL_GID(real);
64833 + }
64834 + if (!gid_valid(effective)) {
64835 + effectiveok = 1;
64836 + globaleffective = (gid_t)-1;
64837 + } else {
64838 + globaleffective = GR_GLOBAL_GID(effective);
64839 + }
64840 + if (!gid_valid(fs)) {
64841 + fsok = 1;
64842 + globalfs = (gid_t)-1;
64843 + } else {
64844 + globalfs = GR_GLOBAL_GID(fs);
64845 + }
64846 +
64847 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64848 + for (i = 0; i < num; i++) {
64849 + curgid = gidlist[i];
64850 + if (globalreal == curgid)
64851 + realok = 1;
64852 + if (globaleffective == curgid)
64853 + effectiveok = 1;
64854 + if (globalfs == curgid)
64855 + fsok = 1;
64856 + }
64857 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64858 + for (i = 0; i < num; i++) {
64859 + curgid = gidlist[i];
64860 + if (globalreal == curgid)
64861 + break;
64862 + if (globaleffective == curgid)
64863 + break;
64864 + if (globalfs == curgid)
64865 + break;
64866 + }
64867 + /* not in deny list */
64868 + if (i == num) {
64869 + realok = 1;
64870 + effectiveok = 1;
64871 + fsok = 1;
64872 + }
64873 + }
64874 +
64875 + if (realok && effectiveok && fsok)
64876 + return 0;
64877 + else {
64878 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64879 + return 1;
64880 + }
64881 +}
64882 +
64883 +extern int gr_acl_is_capable(const int cap);
64884 +
64885 +void
64886 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64887 +{
64888 + struct acl_role_label *role = task->role;
64889 + struct acl_subject_label *subj = NULL;
64890 + struct acl_object_label *obj;
64891 + struct file *filp;
64892 + uid_t uid;
64893 + gid_t gid;
64894 +
64895 + if (unlikely(!(gr_status & GR_READY)))
64896 + return;
64897 +
64898 + uid = GR_GLOBAL_UID(kuid);
64899 + gid = GR_GLOBAL_GID(kgid);
64900 +
64901 + filp = task->exec_file;
64902 +
64903 + /* kernel process, we'll give them the kernel role */
64904 + if (unlikely(!filp)) {
64905 + task->role = kernel_role;
64906 + task->acl = kernel_role->root_label;
64907 + return;
64908 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64909 + role = lookup_acl_role_label(task, uid, gid);
64910 +
64911 + /* don't change the role if we're not a privileged process */
64912 + if (role && task->role != role &&
64913 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64914 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64915 + return;
64916 +
64917 + /* perform subject lookup in possibly new role
64918 + we can use this result below in the case where role == task->role
64919 + */
64920 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64921 +
64922 + /* if we changed uid/gid, but result in the same role
64923 + and are using inheritance, don't lose the inherited subject
64924 + if current subject is other than what normal lookup
64925 + would result in, we arrived via inheritance, don't
64926 + lose subject
64927 + */
64928 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64929 + (subj == task->acl)))
64930 + task->acl = subj;
64931 +
64932 + task->role = role;
64933 +
64934 + task->is_writable = 0;
64935 +
64936 + /* ignore additional mmap checks for processes that are writable
64937 + by the default ACL */
64938 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64939 + if (unlikely(obj->mode & GR_WRITE))
64940 + task->is_writable = 1;
64941 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64942 + if (unlikely(obj->mode & GR_WRITE))
64943 + task->is_writable = 1;
64944 +
64945 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64946 + 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);
64947 +#endif
64948 +
64949 + gr_set_proc_res(task);
64950 +
64951 + return;
64952 +}
64953 +
64954 +int
64955 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64956 + const int unsafe_flags)
64957 +{
64958 + struct task_struct *task = current;
64959 + struct acl_subject_label *newacl;
64960 + struct acl_object_label *obj;
64961 + __u32 retmode;
64962 +
64963 + if (unlikely(!(gr_status & GR_READY)))
64964 + return 0;
64965 +
64966 + newacl = chk_subj_label(dentry, mnt, task->role);
64967 +
64968 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64969 + did an exec
64970 + */
64971 + rcu_read_lock();
64972 + read_lock(&tasklist_lock);
64973 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64974 + (task->parent->acl->mode & GR_POVERRIDE))) {
64975 + read_unlock(&tasklist_lock);
64976 + rcu_read_unlock();
64977 + goto skip_check;
64978 + }
64979 + read_unlock(&tasklist_lock);
64980 + rcu_read_unlock();
64981 +
64982 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64983 + !(task->role->roletype & GR_ROLE_GOD) &&
64984 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64985 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64986 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64987 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64988 + else
64989 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64990 + return -EACCES;
64991 + }
64992 +
64993 +skip_check:
64994 +
64995 + obj = chk_obj_label(dentry, mnt, task->acl);
64996 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64997 +
64998 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64999 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
65000 + if (obj->nested)
65001 + task->acl = obj->nested;
65002 + else
65003 + task->acl = newacl;
65004 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
65005 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
65006 +
65007 + task->is_writable = 0;
65008 +
65009 + /* ignore additional mmap checks for processes that are writable
65010 + by the default ACL */
65011 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
65012 + if (unlikely(obj->mode & GR_WRITE))
65013 + task->is_writable = 1;
65014 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
65015 + if (unlikely(obj->mode & GR_WRITE))
65016 + task->is_writable = 1;
65017 +
65018 + gr_set_proc_res(task);
65019 +
65020 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65021 + 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);
65022 +#endif
65023 + return 0;
65024 +}
65025 +
65026 +/* always called with valid inodev ptr */
65027 +static void
65028 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
65029 +{
65030 + struct acl_object_label *matchpo;
65031 + struct acl_subject_label *matchps;
65032 + struct acl_subject_label *subj;
65033 + struct acl_role_label *role;
65034 + unsigned int x;
65035 +
65036 + FOR_EACH_ROLE_START(role)
65037 + FOR_EACH_SUBJECT_START(role, subj, x)
65038 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65039 + matchpo->mode |= GR_DELETED;
65040 + FOR_EACH_SUBJECT_END(subj,x)
65041 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65042 + /* nested subjects aren't in the role's subj_hash table */
65043 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65044 + matchpo->mode |= GR_DELETED;
65045 + FOR_EACH_NESTED_SUBJECT_END(subj)
65046 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
65047 + matchps->mode |= GR_DELETED;
65048 + FOR_EACH_ROLE_END(role)
65049 +
65050 + inodev->nentry->deleted = 1;
65051 +
65052 + return;
65053 +}
65054 +
65055 +void
65056 +gr_handle_delete(const ino_t ino, const dev_t dev)
65057 +{
65058 + struct inodev_entry *inodev;
65059 +
65060 + if (unlikely(!(gr_status & GR_READY)))
65061 + return;
65062 +
65063 + write_lock(&gr_inode_lock);
65064 + inodev = lookup_inodev_entry(ino, dev);
65065 + if (inodev != NULL)
65066 + do_handle_delete(inodev, ino, dev);
65067 + write_unlock(&gr_inode_lock);
65068 +
65069 + return;
65070 +}
65071 +
65072 +static void
65073 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65074 + const ino_t newinode, const dev_t newdevice,
65075 + struct acl_subject_label *subj)
65076 +{
65077 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65078 + struct acl_object_label *match;
65079 +
65080 + match = subj->obj_hash[index];
65081 +
65082 + while (match && (match->inode != oldinode ||
65083 + match->device != olddevice ||
65084 + !(match->mode & GR_DELETED)))
65085 + match = match->next;
65086 +
65087 + if (match && (match->inode == oldinode)
65088 + && (match->device == olddevice)
65089 + && (match->mode & GR_DELETED)) {
65090 + if (match->prev == NULL) {
65091 + subj->obj_hash[index] = match->next;
65092 + if (match->next != NULL)
65093 + match->next->prev = NULL;
65094 + } else {
65095 + match->prev->next = match->next;
65096 + if (match->next != NULL)
65097 + match->next->prev = match->prev;
65098 + }
65099 + match->prev = NULL;
65100 + match->next = NULL;
65101 + match->inode = newinode;
65102 + match->device = newdevice;
65103 + match->mode &= ~GR_DELETED;
65104 +
65105 + insert_acl_obj_label(match, subj);
65106 + }
65107 +
65108 + return;
65109 +}
65110 +
65111 +static void
65112 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65113 + const ino_t newinode, const dev_t newdevice,
65114 + struct acl_role_label *role)
65115 +{
65116 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65117 + struct acl_subject_label *match;
65118 +
65119 + match = role->subj_hash[index];
65120 +
65121 + while (match && (match->inode != oldinode ||
65122 + match->device != olddevice ||
65123 + !(match->mode & GR_DELETED)))
65124 + match = match->next;
65125 +
65126 + if (match && (match->inode == oldinode)
65127 + && (match->device == olddevice)
65128 + && (match->mode & GR_DELETED)) {
65129 + if (match->prev == NULL) {
65130 + role->subj_hash[index] = match->next;
65131 + if (match->next != NULL)
65132 + match->next->prev = NULL;
65133 + } else {
65134 + match->prev->next = match->next;
65135 + if (match->next != NULL)
65136 + match->next->prev = match->prev;
65137 + }
65138 + match->prev = NULL;
65139 + match->next = NULL;
65140 + match->inode = newinode;
65141 + match->device = newdevice;
65142 + match->mode &= ~GR_DELETED;
65143 +
65144 + insert_acl_subj_label(match, role);
65145 + }
65146 +
65147 + return;
65148 +}
65149 +
65150 +static void
65151 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65152 + const ino_t newinode, const dev_t newdevice)
65153 +{
65154 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65155 + struct inodev_entry *match;
65156 +
65157 + match = inodev_set.i_hash[index];
65158 +
65159 + while (match && (match->nentry->inode != oldinode ||
65160 + match->nentry->device != olddevice || !match->nentry->deleted))
65161 + match = match->next;
65162 +
65163 + if (match && (match->nentry->inode == oldinode)
65164 + && (match->nentry->device == olddevice) &&
65165 + match->nentry->deleted) {
65166 + if (match->prev == NULL) {
65167 + inodev_set.i_hash[index] = match->next;
65168 + if (match->next != NULL)
65169 + match->next->prev = NULL;
65170 + } else {
65171 + match->prev->next = match->next;
65172 + if (match->next != NULL)
65173 + match->next->prev = match->prev;
65174 + }
65175 + match->prev = NULL;
65176 + match->next = NULL;
65177 + match->nentry->inode = newinode;
65178 + match->nentry->device = newdevice;
65179 + match->nentry->deleted = 0;
65180 +
65181 + insert_inodev_entry(match);
65182 + }
65183 +
65184 + return;
65185 +}
65186 +
65187 +static void
65188 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65189 +{
65190 + struct acl_subject_label *subj;
65191 + struct acl_role_label *role;
65192 + unsigned int x;
65193 +
65194 + FOR_EACH_ROLE_START(role)
65195 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65196 +
65197 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65198 + if ((subj->inode == ino) && (subj->device == dev)) {
65199 + subj->inode = ino;
65200 + subj->device = dev;
65201 + }
65202 + /* nested subjects aren't in the role's subj_hash table */
65203 + update_acl_obj_label(matchn->inode, matchn->device,
65204 + ino, dev, subj);
65205 + FOR_EACH_NESTED_SUBJECT_END(subj)
65206 + FOR_EACH_SUBJECT_START(role, subj, x)
65207 + update_acl_obj_label(matchn->inode, matchn->device,
65208 + ino, dev, subj);
65209 + FOR_EACH_SUBJECT_END(subj,x)
65210 + FOR_EACH_ROLE_END(role)
65211 +
65212 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65213 +
65214 + return;
65215 +}
65216 +
65217 +static void
65218 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65219 + const struct vfsmount *mnt)
65220 +{
65221 + ino_t ino = dentry->d_inode->i_ino;
65222 + dev_t dev = __get_dev(dentry);
65223 +
65224 + __do_handle_create(matchn, ino, dev);
65225 +
65226 + return;
65227 +}
65228 +
65229 +void
65230 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65231 +{
65232 + struct name_entry *matchn;
65233 +
65234 + if (unlikely(!(gr_status & GR_READY)))
65235 + return;
65236 +
65237 + preempt_disable();
65238 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65239 +
65240 + if (unlikely((unsigned long)matchn)) {
65241 + write_lock(&gr_inode_lock);
65242 + do_handle_create(matchn, dentry, mnt);
65243 + write_unlock(&gr_inode_lock);
65244 + }
65245 + preempt_enable();
65246 +
65247 + return;
65248 +}
65249 +
65250 +void
65251 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65252 +{
65253 + struct name_entry *matchn;
65254 +
65255 + if (unlikely(!(gr_status & GR_READY)))
65256 + return;
65257 +
65258 + preempt_disable();
65259 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65260 +
65261 + if (unlikely((unsigned long)matchn)) {
65262 + write_lock(&gr_inode_lock);
65263 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65264 + write_unlock(&gr_inode_lock);
65265 + }
65266 + preempt_enable();
65267 +
65268 + return;
65269 +}
65270 +
65271 +void
65272 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65273 + struct dentry *old_dentry,
65274 + struct dentry *new_dentry,
65275 + struct vfsmount *mnt, const __u8 replace)
65276 +{
65277 + struct name_entry *matchn;
65278 + struct inodev_entry *inodev;
65279 + struct inode *inode = new_dentry->d_inode;
65280 + ino_t old_ino = old_dentry->d_inode->i_ino;
65281 + dev_t old_dev = __get_dev(old_dentry);
65282 +
65283 + /* vfs_rename swaps the name and parent link for old_dentry and
65284 + new_dentry
65285 + at this point, old_dentry has the new name, parent link, and inode
65286 + for the renamed file
65287 + if a file is being replaced by a rename, new_dentry has the inode
65288 + and name for the replaced file
65289 + */
65290 +
65291 + if (unlikely(!(gr_status & GR_READY)))
65292 + return;
65293 +
65294 + preempt_disable();
65295 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65296 +
65297 + /* we wouldn't have to check d_inode if it weren't for
65298 + NFS silly-renaming
65299 + */
65300 +
65301 + write_lock(&gr_inode_lock);
65302 + if (unlikely(replace && inode)) {
65303 + ino_t new_ino = inode->i_ino;
65304 + dev_t new_dev = __get_dev(new_dentry);
65305 +
65306 + inodev = lookup_inodev_entry(new_ino, new_dev);
65307 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65308 + do_handle_delete(inodev, new_ino, new_dev);
65309 + }
65310 +
65311 + inodev = lookup_inodev_entry(old_ino, old_dev);
65312 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65313 + do_handle_delete(inodev, old_ino, old_dev);
65314 +
65315 + if (unlikely((unsigned long)matchn))
65316 + do_handle_create(matchn, old_dentry, mnt);
65317 +
65318 + write_unlock(&gr_inode_lock);
65319 + preempt_enable();
65320 +
65321 + return;
65322 +}
65323 +
65324 +static int
65325 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65326 + unsigned char **sum)
65327 +{
65328 + struct acl_role_label *r;
65329 + struct role_allowed_ip *ipp;
65330 + struct role_transition *trans;
65331 + unsigned int i;
65332 + int found = 0;
65333 + u32 curr_ip = current->signal->curr_ip;
65334 +
65335 + current->signal->saved_ip = curr_ip;
65336 +
65337 + /* check transition table */
65338 +
65339 + for (trans = current->role->transitions; trans; trans = trans->next) {
65340 + if (!strcmp(rolename, trans->rolename)) {
65341 + found = 1;
65342 + break;
65343 + }
65344 + }
65345 +
65346 + if (!found)
65347 + return 0;
65348 +
65349 + /* handle special roles that do not require authentication
65350 + and check ip */
65351 +
65352 + FOR_EACH_ROLE_START(r)
65353 + if (!strcmp(rolename, r->rolename) &&
65354 + (r->roletype & GR_ROLE_SPECIAL)) {
65355 + found = 0;
65356 + if (r->allowed_ips != NULL) {
65357 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65358 + if ((ntohl(curr_ip) & ipp->netmask) ==
65359 + (ntohl(ipp->addr) & ipp->netmask))
65360 + found = 1;
65361 + }
65362 + } else
65363 + found = 2;
65364 + if (!found)
65365 + return 0;
65366 +
65367 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65368 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65369 + *salt = NULL;
65370 + *sum = NULL;
65371 + return 1;
65372 + }
65373 + }
65374 + FOR_EACH_ROLE_END(r)
65375 +
65376 + for (i = 0; i < num_sprole_pws; i++) {
65377 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65378 + *salt = acl_special_roles[i]->salt;
65379 + *sum = acl_special_roles[i]->sum;
65380 + return 1;
65381 + }
65382 + }
65383 +
65384 + return 0;
65385 +}
65386 +
65387 +static void
65388 +assign_special_role(char *rolename)
65389 +{
65390 + struct acl_object_label *obj;
65391 + struct acl_role_label *r;
65392 + struct acl_role_label *assigned = NULL;
65393 + struct task_struct *tsk;
65394 + struct file *filp;
65395 +
65396 + FOR_EACH_ROLE_START(r)
65397 + if (!strcmp(rolename, r->rolename) &&
65398 + (r->roletype & GR_ROLE_SPECIAL)) {
65399 + assigned = r;
65400 + break;
65401 + }
65402 + FOR_EACH_ROLE_END(r)
65403 +
65404 + if (!assigned)
65405 + return;
65406 +
65407 + read_lock(&tasklist_lock);
65408 + read_lock(&grsec_exec_file_lock);
65409 +
65410 + tsk = current->real_parent;
65411 + if (tsk == NULL)
65412 + goto out_unlock;
65413 +
65414 + filp = tsk->exec_file;
65415 + if (filp == NULL)
65416 + goto out_unlock;
65417 +
65418 + tsk->is_writable = 0;
65419 +
65420 + tsk->acl_sp_role = 1;
65421 + tsk->acl_role_id = ++acl_sp_role_value;
65422 + tsk->role = assigned;
65423 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65424 +
65425 + /* ignore additional mmap checks for processes that are writable
65426 + by the default ACL */
65427 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65428 + if (unlikely(obj->mode & GR_WRITE))
65429 + tsk->is_writable = 1;
65430 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65431 + if (unlikely(obj->mode & GR_WRITE))
65432 + tsk->is_writable = 1;
65433 +
65434 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65435 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename, tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
65436 +#endif
65437 +
65438 +out_unlock:
65439 + read_unlock(&grsec_exec_file_lock);
65440 + read_unlock(&tasklist_lock);
65441 + return;
65442 +}
65443 +
65444 +int gr_check_secure_terminal(struct task_struct *task)
65445 +{
65446 + struct task_struct *p, *p2, *p3;
65447 + struct files_struct *files;
65448 + struct fdtable *fdt;
65449 + struct file *our_file = NULL, *file;
65450 + int i;
65451 +
65452 + if (task->signal->tty == NULL)
65453 + return 1;
65454 +
65455 + files = get_files_struct(task);
65456 + if (files != NULL) {
65457 + rcu_read_lock();
65458 + fdt = files_fdtable(files);
65459 + for (i=0; i < fdt->max_fds; i++) {
65460 + file = fcheck_files(files, i);
65461 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65462 + get_file(file);
65463 + our_file = file;
65464 + }
65465 + }
65466 + rcu_read_unlock();
65467 + put_files_struct(files);
65468 + }
65469 +
65470 + if (our_file == NULL)
65471 + return 1;
65472 +
65473 + read_lock(&tasklist_lock);
65474 + do_each_thread(p2, p) {
65475 + files = get_files_struct(p);
65476 + if (files == NULL ||
65477 + (p->signal && p->signal->tty == task->signal->tty)) {
65478 + if (files != NULL)
65479 + put_files_struct(files);
65480 + continue;
65481 + }
65482 + rcu_read_lock();
65483 + fdt = files_fdtable(files);
65484 + for (i=0; i < fdt->max_fds; i++) {
65485 + file = fcheck_files(files, i);
65486 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65487 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65488 + p3 = task;
65489 + while (task_pid_nr(p3) > 0) {
65490 + if (p3 == p)
65491 + break;
65492 + p3 = p3->real_parent;
65493 + }
65494 + if (p3 == p)
65495 + break;
65496 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65497 + gr_handle_alertkill(p);
65498 + rcu_read_unlock();
65499 + put_files_struct(files);
65500 + read_unlock(&tasklist_lock);
65501 + fput(our_file);
65502 + return 0;
65503 + }
65504 + }
65505 + rcu_read_unlock();
65506 + put_files_struct(files);
65507 + } while_each_thread(p2, p);
65508 + read_unlock(&tasklist_lock);
65509 +
65510 + fput(our_file);
65511 + return 1;
65512 +}
65513 +
65514 +static int gr_rbac_disable(void *unused)
65515 +{
65516 + pax_open_kernel();
65517 + gr_status &= ~GR_READY;
65518 + pax_close_kernel();
65519 +
65520 + return 0;
65521 +}
65522 +
65523 +ssize_t
65524 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65525 +{
65526 + struct gr_arg_wrapper uwrap;
65527 + unsigned char *sprole_salt = NULL;
65528 + unsigned char *sprole_sum = NULL;
65529 + int error = 0;
65530 + int error2 = 0;
65531 + size_t req_count = 0;
65532 +
65533 + mutex_lock(&gr_dev_mutex);
65534 +
65535 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65536 + error = -EPERM;
65537 + goto out;
65538 + }
65539 +
65540 +#ifdef CONFIG_COMPAT
65541 + pax_open_kernel();
65542 + if (is_compat_task()) {
65543 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65544 + copy_gr_arg = &copy_gr_arg_compat;
65545 + copy_acl_object_label = &copy_acl_object_label_compat;
65546 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65547 + copy_acl_role_label = &copy_acl_role_label_compat;
65548 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65549 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65550 + copy_role_transition = &copy_role_transition_compat;
65551 + copy_sprole_pw = &copy_sprole_pw_compat;
65552 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65553 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65554 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65555 + } else {
65556 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65557 + copy_gr_arg = &copy_gr_arg_normal;
65558 + copy_acl_object_label = &copy_acl_object_label_normal;
65559 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65560 + copy_acl_role_label = &copy_acl_role_label_normal;
65561 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65562 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65563 + copy_role_transition = &copy_role_transition_normal;
65564 + copy_sprole_pw = &copy_sprole_pw_normal;
65565 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65566 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65567 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65568 + }
65569 + pax_close_kernel();
65570 +#endif
65571 +
65572 + req_count = get_gr_arg_wrapper_size();
65573 +
65574 + if (count != req_count) {
65575 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65576 + error = -EINVAL;
65577 + goto out;
65578 + }
65579 +
65580 +
65581 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65582 + gr_auth_expires = 0;
65583 + gr_auth_attempts = 0;
65584 + }
65585 +
65586 + error = copy_gr_arg_wrapper(buf, &uwrap);
65587 + if (error)
65588 + goto out;
65589 +
65590 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65591 + if (error)
65592 + goto out;
65593 +
65594 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65595 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65596 + time_after(gr_auth_expires, get_seconds())) {
65597 + error = -EBUSY;
65598 + goto out;
65599 + }
65600 +
65601 + /* if non-root trying to do anything other than use a special role,
65602 + do not attempt authentication, do not count towards authentication
65603 + locking
65604 + */
65605 +
65606 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65607 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65608 + gr_is_global_nonroot(current_uid())) {
65609 + error = -EPERM;
65610 + goto out;
65611 + }
65612 +
65613 + /* ensure pw and special role name are null terminated */
65614 +
65615 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65616 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65617 +
65618 + /* Okay.
65619 + * We have our enough of the argument structure..(we have yet
65620 + * to copy_from_user the tables themselves) . Copy the tables
65621 + * only if we need them, i.e. for loading operations. */
65622 +
65623 + switch (gr_usermode->mode) {
65624 + case GR_STATUS:
65625 + if (gr_status & GR_READY) {
65626 + error = 1;
65627 + if (!gr_check_secure_terminal(current))
65628 + error = 3;
65629 + } else
65630 + error = 2;
65631 + goto out;
65632 + case GR_SHUTDOWN:
65633 + if ((gr_status & GR_READY)
65634 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65635 + stop_machine(gr_rbac_disable, NULL, NULL);
65636 + free_variables();
65637 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65638 + memset(gr_system_salt, 0, GR_SALT_LEN);
65639 + memset(gr_system_sum, 0, GR_SHA_LEN);
65640 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65641 + } else if (gr_status & GR_READY) {
65642 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65643 + error = -EPERM;
65644 + } else {
65645 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65646 + error = -EAGAIN;
65647 + }
65648 + break;
65649 + case GR_ENABLE:
65650 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65651 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65652 + else {
65653 + if (gr_status & GR_READY)
65654 + error = -EAGAIN;
65655 + else
65656 + error = error2;
65657 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65658 + }
65659 + break;
65660 + case GR_RELOAD:
65661 + if (!(gr_status & GR_READY)) {
65662 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65663 + error = -EAGAIN;
65664 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65665 + stop_machine(gr_rbac_disable, NULL, NULL);
65666 + free_variables();
65667 + error2 = gracl_init(gr_usermode);
65668 + if (!error2)
65669 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65670 + else {
65671 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65672 + error = error2;
65673 + }
65674 + } else {
65675 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65676 + error = -EPERM;
65677 + }
65678 + break;
65679 + case GR_SEGVMOD:
65680 + if (unlikely(!(gr_status & GR_READY))) {
65681 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65682 + error = -EAGAIN;
65683 + break;
65684 + }
65685 +
65686 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65687 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65688 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65689 + struct acl_subject_label *segvacl;
65690 + segvacl =
65691 + lookup_acl_subj_label(gr_usermode->segv_inode,
65692 + gr_usermode->segv_device,
65693 + current->role);
65694 + if (segvacl) {
65695 + segvacl->crashes = 0;
65696 + segvacl->expires = 0;
65697 + }
65698 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65699 + gr_remove_uid(gr_usermode->segv_uid);
65700 + }
65701 + } else {
65702 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65703 + error = -EPERM;
65704 + }
65705 + break;
65706 + case GR_SPROLE:
65707 + case GR_SPROLEPAM:
65708 + if (unlikely(!(gr_status & GR_READY))) {
65709 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65710 + error = -EAGAIN;
65711 + break;
65712 + }
65713 +
65714 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65715 + current->role->expires = 0;
65716 + current->role->auth_attempts = 0;
65717 + }
65718 +
65719 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65720 + time_after(current->role->expires, get_seconds())) {
65721 + error = -EBUSY;
65722 + goto out;
65723 + }
65724 +
65725 + if (lookup_special_role_auth
65726 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65727 + && ((!sprole_salt && !sprole_sum)
65728 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65729 + char *p = "";
65730 + assign_special_role(gr_usermode->sp_role);
65731 + read_lock(&tasklist_lock);
65732 + if (current->real_parent)
65733 + p = current->real_parent->role->rolename;
65734 + read_unlock(&tasklist_lock);
65735 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65736 + p, acl_sp_role_value);
65737 + } else {
65738 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65739 + error = -EPERM;
65740 + if(!(current->role->auth_attempts++))
65741 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65742 +
65743 + goto out;
65744 + }
65745 + break;
65746 + case GR_UNSPROLE:
65747 + if (unlikely(!(gr_status & GR_READY))) {
65748 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65749 + error = -EAGAIN;
65750 + break;
65751 + }
65752 +
65753 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65754 + char *p = "";
65755 + int i = 0;
65756 +
65757 + read_lock(&tasklist_lock);
65758 + if (current->real_parent) {
65759 + p = current->real_parent->role->rolename;
65760 + i = current->real_parent->acl_role_id;
65761 + }
65762 + read_unlock(&tasklist_lock);
65763 +
65764 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65765 + gr_set_acls(1);
65766 + } else {
65767 + error = -EPERM;
65768 + goto out;
65769 + }
65770 + break;
65771 + default:
65772 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65773 + error = -EINVAL;
65774 + break;
65775 + }
65776 +
65777 + if (error != -EPERM)
65778 + goto out;
65779 +
65780 + if(!(gr_auth_attempts++))
65781 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65782 +
65783 + out:
65784 + mutex_unlock(&gr_dev_mutex);
65785 +
65786 + if (!error)
65787 + error = req_count;
65788 +
65789 + return error;
65790 +}
65791 +
65792 +/* must be called with
65793 + rcu_read_lock();
65794 + read_lock(&tasklist_lock);
65795 + read_lock(&grsec_exec_file_lock);
65796 +*/
65797 +int gr_apply_subject_to_task(struct task_struct *task)
65798 +{
65799 + struct acl_object_label *obj;
65800 + char *tmpname;
65801 + struct acl_subject_label *tmpsubj;
65802 + struct file *filp;
65803 + struct name_entry *nmatch;
65804 +
65805 + filp = task->exec_file;
65806 + if (filp == NULL)
65807 + return 0;
65808 +
65809 + /* the following is to apply the correct subject
65810 + on binaries running when the RBAC system
65811 + is enabled, when the binaries have been
65812 + replaced or deleted since their execution
65813 + -----
65814 + when the RBAC system starts, the inode/dev
65815 + from exec_file will be one the RBAC system
65816 + is unaware of. It only knows the inode/dev
65817 + of the present file on disk, or the absence
65818 + of it.
65819 + */
65820 + preempt_disable();
65821 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65822 +
65823 + nmatch = lookup_name_entry(tmpname);
65824 + preempt_enable();
65825 + tmpsubj = NULL;
65826 + if (nmatch) {
65827 + if (nmatch->deleted)
65828 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65829 + else
65830 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65831 + if (tmpsubj != NULL)
65832 + task->acl = tmpsubj;
65833 + }
65834 + if (tmpsubj == NULL)
65835 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65836 + task->role);
65837 + if (task->acl) {
65838 + task->is_writable = 0;
65839 + /* ignore additional mmap checks for processes that are writable
65840 + by the default ACL */
65841 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65842 + if (unlikely(obj->mode & GR_WRITE))
65843 + task->is_writable = 1;
65844 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65845 + if (unlikely(obj->mode & GR_WRITE))
65846 + task->is_writable = 1;
65847 +
65848 + gr_set_proc_res(task);
65849 +
65850 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65851 + 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);
65852 +#endif
65853 + } else {
65854 + return 1;
65855 + }
65856 +
65857 + return 0;
65858 +}
65859 +
65860 +int
65861 +gr_set_acls(const int type)
65862 +{
65863 + struct task_struct *task, *task2;
65864 + struct acl_role_label *role = current->role;
65865 + __u16 acl_role_id = current->acl_role_id;
65866 + const struct cred *cred;
65867 + int ret;
65868 +
65869 + rcu_read_lock();
65870 + read_lock(&tasklist_lock);
65871 + read_lock(&grsec_exec_file_lock);
65872 + do_each_thread(task2, task) {
65873 + /* check to see if we're called from the exit handler,
65874 + if so, only replace ACLs that have inherited the admin
65875 + ACL */
65876 +
65877 + if (type && (task->role != role ||
65878 + task->acl_role_id != acl_role_id))
65879 + continue;
65880 +
65881 + task->acl_role_id = 0;
65882 + task->acl_sp_role = 0;
65883 +
65884 + if (task->exec_file) {
65885 + cred = __task_cred(task);
65886 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65887 + ret = gr_apply_subject_to_task(task);
65888 + if (ret) {
65889 + read_unlock(&grsec_exec_file_lock);
65890 + read_unlock(&tasklist_lock);
65891 + rcu_read_unlock();
65892 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65893 + return ret;
65894 + }
65895 + } else {
65896 + // it's a kernel process
65897 + task->role = kernel_role;
65898 + task->acl = kernel_role->root_label;
65899 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65900 + task->acl->mode &= ~GR_PROCFIND;
65901 +#endif
65902 + }
65903 + } while_each_thread(task2, task);
65904 + read_unlock(&grsec_exec_file_lock);
65905 + read_unlock(&tasklist_lock);
65906 + rcu_read_unlock();
65907 +
65908 + return 0;
65909 +}
65910 +
65911 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65912 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65913 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65914 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65915 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65916 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65917 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65918 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65919 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65920 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65921 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65922 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65923 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65924 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65925 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65926 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65927 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65928 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65929 +};
65930 +
65931 +void
65932 +gr_learn_resource(const struct task_struct *task,
65933 + const int res, const unsigned long wanted, const int gt)
65934 +{
65935 + struct acl_subject_label *acl;
65936 + const struct cred *cred;
65937 +
65938 + if (unlikely((gr_status & GR_READY) &&
65939 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65940 + goto skip_reslog;
65941 +
65942 + gr_log_resource(task, res, wanted, gt);
65943 +skip_reslog:
65944 +
65945 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65946 + return;
65947 +
65948 + acl = task->acl;
65949 +
65950 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65951 + !(acl->resmask & (1U << (unsigned short) res))))
65952 + return;
65953 +
65954 + if (wanted >= acl->res[res].rlim_cur) {
65955 + unsigned long res_add;
65956 +
65957 + res_add = wanted + res_learn_bumps[res];
65958 +
65959 + acl->res[res].rlim_cur = res_add;
65960 +
65961 + if (wanted > acl->res[res].rlim_max)
65962 + acl->res[res].rlim_max = res_add;
65963 +
65964 + /* only log the subject filename, since resource logging is supported for
65965 + single-subject learning only */
65966 + rcu_read_lock();
65967 + cred = __task_cred(task);
65968 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65969 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65970 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65971 + "", (unsigned long) res, &task->signal->saved_ip);
65972 + rcu_read_unlock();
65973 + }
65974 +
65975 + return;
65976 +}
65977 +EXPORT_SYMBOL(gr_learn_resource);
65978 +#endif
65979 +
65980 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65981 +void
65982 +pax_set_initial_flags(struct linux_binprm *bprm)
65983 +{
65984 + struct task_struct *task = current;
65985 + struct acl_subject_label *proc;
65986 + unsigned long flags;
65987 +
65988 + if (unlikely(!(gr_status & GR_READY)))
65989 + return;
65990 +
65991 + flags = pax_get_flags(task);
65992 +
65993 + proc = task->acl;
65994 +
65995 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65996 + flags &= ~MF_PAX_PAGEEXEC;
65997 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65998 + flags &= ~MF_PAX_SEGMEXEC;
65999 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
66000 + flags &= ~MF_PAX_RANDMMAP;
66001 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
66002 + flags &= ~MF_PAX_EMUTRAMP;
66003 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
66004 + flags &= ~MF_PAX_MPROTECT;
66005 +
66006 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
66007 + flags |= MF_PAX_PAGEEXEC;
66008 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
66009 + flags |= MF_PAX_SEGMEXEC;
66010 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
66011 + flags |= MF_PAX_RANDMMAP;
66012 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
66013 + flags |= MF_PAX_EMUTRAMP;
66014 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
66015 + flags |= MF_PAX_MPROTECT;
66016 +
66017 + pax_set_flags(task, flags);
66018 +
66019 + return;
66020 +}
66021 +#endif
66022 +
66023 +int
66024 +gr_handle_proc_ptrace(struct task_struct *task)
66025 +{
66026 + struct file *filp;
66027 + struct task_struct *tmp = task;
66028 + struct task_struct *curtemp = current;
66029 + __u32 retmode;
66030 +
66031 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66032 + if (unlikely(!(gr_status & GR_READY)))
66033 + return 0;
66034 +#endif
66035 +
66036 + read_lock(&tasklist_lock);
66037 + read_lock(&grsec_exec_file_lock);
66038 + filp = task->exec_file;
66039 +
66040 + while (task_pid_nr(tmp) > 0) {
66041 + if (tmp == curtemp)
66042 + break;
66043 + tmp = tmp->real_parent;
66044 + }
66045 +
66046 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66047 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
66048 + read_unlock(&grsec_exec_file_lock);
66049 + read_unlock(&tasklist_lock);
66050 + return 1;
66051 + }
66052 +
66053 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66054 + if (!(gr_status & GR_READY)) {
66055 + read_unlock(&grsec_exec_file_lock);
66056 + read_unlock(&tasklist_lock);
66057 + return 0;
66058 + }
66059 +#endif
66060 +
66061 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66062 + read_unlock(&grsec_exec_file_lock);
66063 + read_unlock(&tasklist_lock);
66064 +
66065 + if (retmode & GR_NOPTRACE)
66066 + return 1;
66067 +
66068 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66069 + && (current->acl != task->acl || (current->acl != current->role->root_label
66070 + && task_pid_nr(current) != task_pid_nr(task))))
66071 + return 1;
66072 +
66073 + return 0;
66074 +}
66075 +
66076 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66077 +{
66078 + if (unlikely(!(gr_status & GR_READY)))
66079 + return;
66080 +
66081 + if (!(current->role->roletype & GR_ROLE_GOD))
66082 + return;
66083 +
66084 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66085 + p->role->rolename, gr_task_roletype_to_char(p),
66086 + p->acl->filename);
66087 +}
66088 +
66089 +int
66090 +gr_handle_ptrace(struct task_struct *task, const long request)
66091 +{
66092 + struct task_struct *tmp = task;
66093 + struct task_struct *curtemp = current;
66094 + __u32 retmode;
66095 +
66096 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66097 + if (unlikely(!(gr_status & GR_READY)))
66098 + return 0;
66099 +#endif
66100 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66101 + read_lock(&tasklist_lock);
66102 + while (task_pid_nr(tmp) > 0) {
66103 + if (tmp == curtemp)
66104 + break;
66105 + tmp = tmp->real_parent;
66106 + }
66107 +
66108 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66109 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66110 + read_unlock(&tasklist_lock);
66111 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66112 + return 1;
66113 + }
66114 + read_unlock(&tasklist_lock);
66115 + }
66116 +
66117 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66118 + if (!(gr_status & GR_READY))
66119 + return 0;
66120 +#endif
66121 +
66122 + read_lock(&grsec_exec_file_lock);
66123 + if (unlikely(!task->exec_file)) {
66124 + read_unlock(&grsec_exec_file_lock);
66125 + return 0;
66126 + }
66127 +
66128 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66129 + read_unlock(&grsec_exec_file_lock);
66130 +
66131 + if (retmode & GR_NOPTRACE) {
66132 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66133 + return 1;
66134 + }
66135 +
66136 + if (retmode & GR_PTRACERD) {
66137 + switch (request) {
66138 + case PTRACE_SEIZE:
66139 + case PTRACE_POKETEXT:
66140 + case PTRACE_POKEDATA:
66141 + case PTRACE_POKEUSR:
66142 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66143 + case PTRACE_SETREGS:
66144 + case PTRACE_SETFPREGS:
66145 +#endif
66146 +#ifdef CONFIG_X86
66147 + case PTRACE_SETFPXREGS:
66148 +#endif
66149 +#ifdef CONFIG_ALTIVEC
66150 + case PTRACE_SETVRREGS:
66151 +#endif
66152 + return 1;
66153 + default:
66154 + return 0;
66155 + }
66156 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66157 + !(current->role->roletype & GR_ROLE_GOD) &&
66158 + (current->acl != task->acl)) {
66159 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66160 + return 1;
66161 + }
66162 +
66163 + return 0;
66164 +}
66165 +
66166 +static int is_writable_mmap(const struct file *filp)
66167 +{
66168 + struct task_struct *task = current;
66169 + struct acl_object_label *obj, *obj2;
66170 +
66171 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66172 + !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))) {
66173 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66174 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66175 + task->role->root_label);
66176 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66177 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66178 + return 1;
66179 + }
66180 + }
66181 + return 0;
66182 +}
66183 +
66184 +int
66185 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66186 +{
66187 + __u32 mode;
66188 +
66189 + if (unlikely(!file || !(prot & PROT_EXEC)))
66190 + return 1;
66191 +
66192 + if (is_writable_mmap(file))
66193 + return 0;
66194 +
66195 + mode =
66196 + gr_search_file(file->f_path.dentry,
66197 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66198 + file->f_path.mnt);
66199 +
66200 + if (!gr_tpe_allow(file))
66201 + return 0;
66202 +
66203 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66204 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66205 + return 0;
66206 + } else if (unlikely(!(mode & GR_EXEC))) {
66207 + return 0;
66208 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66209 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66210 + return 1;
66211 + }
66212 +
66213 + return 1;
66214 +}
66215 +
66216 +int
66217 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66218 +{
66219 + __u32 mode;
66220 +
66221 + if (unlikely(!file || !(prot & PROT_EXEC)))
66222 + return 1;
66223 +
66224 + if (is_writable_mmap(file))
66225 + return 0;
66226 +
66227 + mode =
66228 + gr_search_file(file->f_path.dentry,
66229 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66230 + file->f_path.mnt);
66231 +
66232 + if (!gr_tpe_allow(file))
66233 + return 0;
66234 +
66235 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66236 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66237 + return 0;
66238 + } else if (unlikely(!(mode & GR_EXEC))) {
66239 + return 0;
66240 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66241 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66242 + return 1;
66243 + }
66244 +
66245 + return 1;
66246 +}
66247 +
66248 +void
66249 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66250 +{
66251 + unsigned long runtime;
66252 + unsigned long cputime;
66253 + unsigned int wday, cday;
66254 + __u8 whr, chr;
66255 + __u8 wmin, cmin;
66256 + __u8 wsec, csec;
66257 + struct timespec timeval;
66258 +
66259 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66260 + !(task->acl->mode & GR_PROCACCT)))
66261 + return;
66262 +
66263 + do_posix_clock_monotonic_gettime(&timeval);
66264 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66265 + wday = runtime / (3600 * 24);
66266 + runtime -= wday * (3600 * 24);
66267 + whr = runtime / 3600;
66268 + runtime -= whr * 3600;
66269 + wmin = runtime / 60;
66270 + runtime -= wmin * 60;
66271 + wsec = runtime;
66272 +
66273 + cputime = (task->utime + task->stime) / HZ;
66274 + cday = cputime / (3600 * 24);
66275 + cputime -= cday * (3600 * 24);
66276 + chr = cputime / 3600;
66277 + cputime -= chr * 3600;
66278 + cmin = cputime / 60;
66279 + cputime -= cmin * 60;
66280 + csec = cputime;
66281 +
66282 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66283 +
66284 + return;
66285 +}
66286 +
66287 +void gr_set_kernel_label(struct task_struct *task)
66288 +{
66289 + if (gr_status & GR_READY) {
66290 + task->role = kernel_role;
66291 + task->acl = kernel_role->root_label;
66292 + }
66293 + return;
66294 +}
66295 +
66296 +#ifdef CONFIG_TASKSTATS
66297 +int gr_is_taskstats_denied(int pid)
66298 +{
66299 + struct task_struct *task;
66300 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66301 + const struct cred *cred;
66302 +#endif
66303 + int ret = 0;
66304 +
66305 + /* restrict taskstats viewing to un-chrooted root users
66306 + who have the 'view' subject flag if the RBAC system is enabled
66307 + */
66308 +
66309 + rcu_read_lock();
66310 + read_lock(&tasklist_lock);
66311 + task = find_task_by_vpid(pid);
66312 + if (task) {
66313 +#ifdef CONFIG_GRKERNSEC_CHROOT
66314 + if (proc_is_chrooted(task))
66315 + ret = -EACCES;
66316 +#endif
66317 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66318 + cred = __task_cred(task);
66319 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66320 + if (gr_is_global_nonroot(cred->uid))
66321 + ret = -EACCES;
66322 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66323 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66324 + ret = -EACCES;
66325 +#endif
66326 +#endif
66327 + if (gr_status & GR_READY) {
66328 + if (!(task->acl->mode & GR_VIEW))
66329 + ret = -EACCES;
66330 + }
66331 + } else
66332 + ret = -ENOENT;
66333 +
66334 + read_unlock(&tasklist_lock);
66335 + rcu_read_unlock();
66336 +
66337 + return ret;
66338 +}
66339 +#endif
66340 +
66341 +/* AUXV entries are filled via a descendant of search_binary_handler
66342 + after we've already applied the subject for the target
66343 +*/
66344 +int gr_acl_enable_at_secure(void)
66345 +{
66346 + if (unlikely(!(gr_status & GR_READY)))
66347 + return 0;
66348 +
66349 + if (current->acl->mode & GR_ATSECURE)
66350 + return 1;
66351 +
66352 + return 0;
66353 +}
66354 +
66355 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66356 +{
66357 + struct task_struct *task = current;
66358 + struct dentry *dentry = file->f_path.dentry;
66359 + struct vfsmount *mnt = file->f_path.mnt;
66360 + struct acl_object_label *obj, *tmp;
66361 + struct acl_subject_label *subj;
66362 + unsigned int bufsize;
66363 + int is_not_root;
66364 + char *path;
66365 + dev_t dev = __get_dev(dentry);
66366 +
66367 + if (unlikely(!(gr_status & GR_READY)))
66368 + return 1;
66369 +
66370 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66371 + return 1;
66372 +
66373 + /* ignore Eric Biederman */
66374 + if (IS_PRIVATE(dentry->d_inode))
66375 + return 1;
66376 +
66377 + subj = task->acl;
66378 + read_lock(&gr_inode_lock);
66379 + do {
66380 + obj = lookup_acl_obj_label(ino, dev, subj);
66381 + if (obj != NULL) {
66382 + read_unlock(&gr_inode_lock);
66383 + return (obj->mode & GR_FIND) ? 1 : 0;
66384 + }
66385 + } while ((subj = subj->parent_subject));
66386 + read_unlock(&gr_inode_lock);
66387 +
66388 + /* this is purely an optimization since we're looking for an object
66389 + for the directory we're doing a readdir on
66390 + if it's possible for any globbed object to match the entry we're
66391 + filling into the directory, then the object we find here will be
66392 + an anchor point with attached globbed objects
66393 + */
66394 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66395 + if (obj->globbed == NULL)
66396 + return (obj->mode & GR_FIND) ? 1 : 0;
66397 +
66398 + is_not_root = ((obj->filename[0] == '/') &&
66399 + (obj->filename[1] == '\0')) ? 0 : 1;
66400 + bufsize = PAGE_SIZE - namelen - is_not_root;
66401 +
66402 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66403 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66404 + return 1;
66405 +
66406 + preempt_disable();
66407 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66408 + bufsize);
66409 +
66410 + bufsize = strlen(path);
66411 +
66412 + /* if base is "/", don't append an additional slash */
66413 + if (is_not_root)
66414 + *(path + bufsize) = '/';
66415 + memcpy(path + bufsize + is_not_root, name, namelen);
66416 + *(path + bufsize + namelen + is_not_root) = '\0';
66417 +
66418 + tmp = obj->globbed;
66419 + while (tmp) {
66420 + if (!glob_match(tmp->filename, path)) {
66421 + preempt_enable();
66422 + return (tmp->mode & GR_FIND) ? 1 : 0;
66423 + }
66424 + tmp = tmp->next;
66425 + }
66426 + preempt_enable();
66427 + return (obj->mode & GR_FIND) ? 1 : 0;
66428 +}
66429 +
66430 +void gr_put_exec_file(struct task_struct *task)
66431 +{
66432 + struct file *filp;
66433 +
66434 + write_lock(&grsec_exec_file_lock);
66435 + filp = task->exec_file;
66436 + task->exec_file = NULL;
66437 + write_unlock(&grsec_exec_file_lock);
66438 +
66439 + if (filp)
66440 + fput(filp);
66441 +
66442 + return;
66443 +}
66444 +
66445 +
66446 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66447 +EXPORT_SYMBOL(gr_acl_is_enabled);
66448 +#endif
66449 +EXPORT_SYMBOL(gr_set_kernel_label);
66450 +#ifdef CONFIG_SECURITY
66451 +EXPORT_SYMBOL(gr_check_user_change);
66452 +EXPORT_SYMBOL(gr_check_group_change);
66453 +#endif
66454 +
66455 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66456 new file mode 100644
66457 index 0000000..34fefda
66458 --- /dev/null
66459 +++ b/grsecurity/gracl_alloc.c
66460 @@ -0,0 +1,105 @@
66461 +#include <linux/kernel.h>
66462 +#include <linux/mm.h>
66463 +#include <linux/slab.h>
66464 +#include <linux/vmalloc.h>
66465 +#include <linux/gracl.h>
66466 +#include <linux/grsecurity.h>
66467 +
66468 +static unsigned long alloc_stack_next = 1;
66469 +static unsigned long alloc_stack_size = 1;
66470 +static void **alloc_stack;
66471 +
66472 +static __inline__ int
66473 +alloc_pop(void)
66474 +{
66475 + if (alloc_stack_next == 1)
66476 + return 0;
66477 +
66478 + kfree(alloc_stack[alloc_stack_next - 2]);
66479 +
66480 + alloc_stack_next--;
66481 +
66482 + return 1;
66483 +}
66484 +
66485 +static __inline__ int
66486 +alloc_push(void *buf)
66487 +{
66488 + if (alloc_stack_next >= alloc_stack_size)
66489 + return 1;
66490 +
66491 + alloc_stack[alloc_stack_next - 1] = buf;
66492 +
66493 + alloc_stack_next++;
66494 +
66495 + return 0;
66496 +}
66497 +
66498 +void *
66499 +acl_alloc(unsigned long len)
66500 +{
66501 + void *ret = NULL;
66502 +
66503 + if (!len || len > PAGE_SIZE)
66504 + goto out;
66505 +
66506 + ret = kmalloc(len, GFP_KERNEL);
66507 +
66508 + if (ret) {
66509 + if (alloc_push(ret)) {
66510 + kfree(ret);
66511 + ret = NULL;
66512 + }
66513 + }
66514 +
66515 +out:
66516 + return ret;
66517 +}
66518 +
66519 +void *
66520 +acl_alloc_num(unsigned long num, unsigned long len)
66521 +{
66522 + if (!len || (num > (PAGE_SIZE / len)))
66523 + return NULL;
66524 +
66525 + return acl_alloc(num * len);
66526 +}
66527 +
66528 +void
66529 +acl_free_all(void)
66530 +{
66531 + if (gr_acl_is_enabled() || !alloc_stack)
66532 + return;
66533 +
66534 + while (alloc_pop()) ;
66535 +
66536 + if (alloc_stack) {
66537 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66538 + kfree(alloc_stack);
66539 + else
66540 + vfree(alloc_stack);
66541 + }
66542 +
66543 + alloc_stack = NULL;
66544 + alloc_stack_size = 1;
66545 + alloc_stack_next = 1;
66546 +
66547 + return;
66548 +}
66549 +
66550 +int
66551 +acl_alloc_stack_init(unsigned long size)
66552 +{
66553 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66554 + alloc_stack =
66555 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66556 + else
66557 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66558 +
66559 + alloc_stack_size = size;
66560 +
66561 + if (!alloc_stack)
66562 + return 0;
66563 + else
66564 + return 1;
66565 +}
66566 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66567 new file mode 100644
66568 index 0000000..bdd51ea
66569 --- /dev/null
66570 +++ b/grsecurity/gracl_cap.c
66571 @@ -0,0 +1,110 @@
66572 +#include <linux/kernel.h>
66573 +#include <linux/module.h>
66574 +#include <linux/sched.h>
66575 +#include <linux/gracl.h>
66576 +#include <linux/grsecurity.h>
66577 +#include <linux/grinternal.h>
66578 +
66579 +extern const char *captab_log[];
66580 +extern int captab_log_entries;
66581 +
66582 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66583 +{
66584 + struct acl_subject_label *curracl;
66585 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66586 + kernel_cap_t cap_audit = __cap_empty_set;
66587 +
66588 + if (!gr_acl_is_enabled())
66589 + return 1;
66590 +
66591 + curracl = task->acl;
66592 +
66593 + cap_drop = curracl->cap_lower;
66594 + cap_mask = curracl->cap_mask;
66595 + cap_audit = curracl->cap_invert_audit;
66596 +
66597 + while ((curracl = curracl->parent_subject)) {
66598 + /* if the cap isn't specified in the current computed mask but is specified in the
66599 + current level subject, and is lowered in the current level subject, then add
66600 + it to the set of dropped capabilities
66601 + otherwise, add the current level subject's mask to the current computed mask
66602 + */
66603 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66604 + cap_raise(cap_mask, cap);
66605 + if (cap_raised(curracl->cap_lower, cap))
66606 + cap_raise(cap_drop, cap);
66607 + if (cap_raised(curracl->cap_invert_audit, cap))
66608 + cap_raise(cap_audit, cap);
66609 + }
66610 + }
66611 +
66612 + if (!cap_raised(cap_drop, cap)) {
66613 + if (cap_raised(cap_audit, cap))
66614 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66615 + return 1;
66616 + }
66617 +
66618 + curracl = task->acl;
66619 +
66620 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66621 + && cap_raised(cred->cap_effective, cap)) {
66622 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66623 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66624 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66625 + gr_to_filename(task->exec_file->f_path.dentry,
66626 + task->exec_file->f_path.mnt) : curracl->filename,
66627 + curracl->filename, 0UL,
66628 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66629 + return 1;
66630 + }
66631 +
66632 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66633 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66634 +
66635 + return 0;
66636 +}
66637 +
66638 +int
66639 +gr_acl_is_capable(const int cap)
66640 +{
66641 + return gr_task_acl_is_capable(current, current_cred(), cap);
66642 +}
66643 +
66644 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66645 +{
66646 + struct acl_subject_label *curracl;
66647 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66648 +
66649 + if (!gr_acl_is_enabled())
66650 + return 1;
66651 +
66652 + curracl = task->acl;
66653 +
66654 + cap_drop = curracl->cap_lower;
66655 + cap_mask = curracl->cap_mask;
66656 +
66657 + while ((curracl = curracl->parent_subject)) {
66658 + /* if the cap isn't specified in the current computed mask but is specified in the
66659 + current level subject, and is lowered in the current level subject, then add
66660 + it to the set of dropped capabilities
66661 + otherwise, add the current level subject's mask to the current computed mask
66662 + */
66663 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66664 + cap_raise(cap_mask, cap);
66665 + if (cap_raised(curracl->cap_lower, cap))
66666 + cap_raise(cap_drop, cap);
66667 + }
66668 + }
66669 +
66670 + if (!cap_raised(cap_drop, cap))
66671 + return 1;
66672 +
66673 + return 0;
66674 +}
66675 +
66676 +int
66677 +gr_acl_is_capable_nolog(const int cap)
66678 +{
66679 + return gr_task_acl_is_capable_nolog(current, cap);
66680 +}
66681 +
66682 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66683 new file mode 100644
66684 index 0000000..a43dd06
66685 --- /dev/null
66686 +++ b/grsecurity/gracl_compat.c
66687 @@ -0,0 +1,269 @@
66688 +#include <linux/kernel.h>
66689 +#include <linux/gracl.h>
66690 +#include <linux/compat.h>
66691 +#include <linux/gracl_compat.h>
66692 +
66693 +#include <asm/uaccess.h>
66694 +
66695 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66696 +{
66697 + struct gr_arg_wrapper_compat uwrapcompat;
66698 +
66699 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66700 + return -EFAULT;
66701 +
66702 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66703 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66704 + return -EINVAL;
66705 +
66706 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66707 + uwrap->version = uwrapcompat.version;
66708 + uwrap->size = sizeof(struct gr_arg);
66709 +
66710 + return 0;
66711 +}
66712 +
66713 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66714 +{
66715 + struct gr_arg_compat argcompat;
66716 +
66717 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66718 + return -EFAULT;
66719 +
66720 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66721 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66722 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66723 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66724 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66725 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66726 +
66727 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66728 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66729 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66730 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66731 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66732 + arg->segv_device = argcompat.segv_device;
66733 + arg->segv_inode = argcompat.segv_inode;
66734 + arg->segv_uid = argcompat.segv_uid;
66735 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66736 + arg->mode = argcompat.mode;
66737 +
66738 + return 0;
66739 +}
66740 +
66741 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66742 +{
66743 + struct acl_object_label_compat objcompat;
66744 +
66745 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66746 + return -EFAULT;
66747 +
66748 + obj->filename = compat_ptr(objcompat.filename);
66749 + obj->inode = objcompat.inode;
66750 + obj->device = objcompat.device;
66751 + obj->mode = objcompat.mode;
66752 +
66753 + obj->nested = compat_ptr(objcompat.nested);
66754 + obj->globbed = compat_ptr(objcompat.globbed);
66755 +
66756 + obj->prev = compat_ptr(objcompat.prev);
66757 + obj->next = compat_ptr(objcompat.next);
66758 +
66759 + return 0;
66760 +}
66761 +
66762 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66763 +{
66764 + unsigned int i;
66765 + struct acl_subject_label_compat subjcompat;
66766 +
66767 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66768 + return -EFAULT;
66769 +
66770 + subj->filename = compat_ptr(subjcompat.filename);
66771 + subj->inode = subjcompat.inode;
66772 + subj->device = subjcompat.device;
66773 + subj->mode = subjcompat.mode;
66774 + subj->cap_mask = subjcompat.cap_mask;
66775 + subj->cap_lower = subjcompat.cap_lower;
66776 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66777 +
66778 + for (i = 0; i < GR_NLIMITS; i++) {
66779 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66780 + subj->res[i].rlim_cur = RLIM_INFINITY;
66781 + else
66782 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66783 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66784 + subj->res[i].rlim_max = RLIM_INFINITY;
66785 + else
66786 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66787 + }
66788 + subj->resmask = subjcompat.resmask;
66789 +
66790 + subj->user_trans_type = subjcompat.user_trans_type;
66791 + subj->group_trans_type = subjcompat.group_trans_type;
66792 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66793 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66794 + subj->user_trans_num = subjcompat.user_trans_num;
66795 + subj->group_trans_num = subjcompat.group_trans_num;
66796 +
66797 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66798 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66799 + subj->ip_type = subjcompat.ip_type;
66800 + subj->ips = compat_ptr(subjcompat.ips);
66801 + subj->ip_num = subjcompat.ip_num;
66802 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66803 +
66804 + subj->crashes = subjcompat.crashes;
66805 + subj->expires = subjcompat.expires;
66806 +
66807 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66808 + subj->hash = compat_ptr(subjcompat.hash);
66809 + subj->prev = compat_ptr(subjcompat.prev);
66810 + subj->next = compat_ptr(subjcompat.next);
66811 +
66812 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66813 + subj->obj_hash_size = subjcompat.obj_hash_size;
66814 + subj->pax_flags = subjcompat.pax_flags;
66815 +
66816 + return 0;
66817 +}
66818 +
66819 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66820 +{
66821 + struct acl_role_label_compat rolecompat;
66822 +
66823 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66824 + return -EFAULT;
66825 +
66826 + role->rolename = compat_ptr(rolecompat.rolename);
66827 + role->uidgid = rolecompat.uidgid;
66828 + role->roletype = rolecompat.roletype;
66829 +
66830 + role->auth_attempts = rolecompat.auth_attempts;
66831 + role->expires = rolecompat.expires;
66832 +
66833 + role->root_label = compat_ptr(rolecompat.root_label);
66834 + role->hash = compat_ptr(rolecompat.hash);
66835 +
66836 + role->prev = compat_ptr(rolecompat.prev);
66837 + role->next = compat_ptr(rolecompat.next);
66838 +
66839 + role->transitions = compat_ptr(rolecompat.transitions);
66840 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66841 + role->domain_children = compat_ptr(rolecompat.domain_children);
66842 + role->domain_child_num = rolecompat.domain_child_num;
66843 +
66844 + role->umask = rolecompat.umask;
66845 +
66846 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66847 + role->subj_hash_size = rolecompat.subj_hash_size;
66848 +
66849 + return 0;
66850 +}
66851 +
66852 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66853 +{
66854 + struct role_allowed_ip_compat roleip_compat;
66855 +
66856 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66857 + return -EFAULT;
66858 +
66859 + roleip->addr = roleip_compat.addr;
66860 + roleip->netmask = roleip_compat.netmask;
66861 +
66862 + roleip->prev = compat_ptr(roleip_compat.prev);
66863 + roleip->next = compat_ptr(roleip_compat.next);
66864 +
66865 + return 0;
66866 +}
66867 +
66868 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66869 +{
66870 + struct role_transition_compat trans_compat;
66871 +
66872 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66873 + return -EFAULT;
66874 +
66875 + trans->rolename = compat_ptr(trans_compat.rolename);
66876 +
66877 + trans->prev = compat_ptr(trans_compat.prev);
66878 + trans->next = compat_ptr(trans_compat.next);
66879 +
66880 + return 0;
66881 +
66882 +}
66883 +
66884 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66885 +{
66886 + struct gr_hash_struct_compat hash_compat;
66887 +
66888 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66889 + return -EFAULT;
66890 +
66891 + hash->table = compat_ptr(hash_compat.table);
66892 + hash->nametable = compat_ptr(hash_compat.nametable);
66893 + hash->first = compat_ptr(hash_compat.first);
66894 +
66895 + hash->table_size = hash_compat.table_size;
66896 + hash->used_size = hash_compat.used_size;
66897 +
66898 + hash->type = hash_compat.type;
66899 +
66900 + return 0;
66901 +}
66902 +
66903 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66904 +{
66905 + compat_uptr_t ptrcompat;
66906 +
66907 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66908 + return -EFAULT;
66909 +
66910 + *(void **)ptr = compat_ptr(ptrcompat);
66911 +
66912 + return 0;
66913 +}
66914 +
66915 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66916 +{
66917 + struct acl_ip_label_compat ip_compat;
66918 +
66919 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66920 + return -EFAULT;
66921 +
66922 + ip->iface = compat_ptr(ip_compat.iface);
66923 + ip->addr = ip_compat.addr;
66924 + ip->netmask = ip_compat.netmask;
66925 + ip->low = ip_compat.low;
66926 + ip->high = ip_compat.high;
66927 + ip->mode = ip_compat.mode;
66928 + ip->type = ip_compat.type;
66929 +
66930 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66931 +
66932 + ip->prev = compat_ptr(ip_compat.prev);
66933 + ip->next = compat_ptr(ip_compat.next);
66934 +
66935 + return 0;
66936 +}
66937 +
66938 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66939 +{
66940 + struct sprole_pw_compat pw_compat;
66941 +
66942 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66943 + return -EFAULT;
66944 +
66945 + pw->rolename = compat_ptr(pw_compat.rolename);
66946 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66947 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66948 +
66949 + return 0;
66950 +}
66951 +
66952 +size_t get_gr_arg_wrapper_size_compat(void)
66953 +{
66954 + return sizeof(struct gr_arg_wrapper_compat);
66955 +}
66956 +
66957 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66958 new file mode 100644
66959 index 0000000..a340c17
66960 --- /dev/null
66961 +++ b/grsecurity/gracl_fs.c
66962 @@ -0,0 +1,431 @@
66963 +#include <linux/kernel.h>
66964 +#include <linux/sched.h>
66965 +#include <linux/types.h>
66966 +#include <linux/fs.h>
66967 +#include <linux/file.h>
66968 +#include <linux/stat.h>
66969 +#include <linux/grsecurity.h>
66970 +#include <linux/grinternal.h>
66971 +#include <linux/gracl.h>
66972 +
66973 +umode_t
66974 +gr_acl_umask(void)
66975 +{
66976 + if (unlikely(!gr_acl_is_enabled()))
66977 + return 0;
66978 +
66979 + return current->role->umask;
66980 +}
66981 +
66982 +__u32
66983 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66984 + const struct vfsmount * mnt)
66985 +{
66986 + __u32 mode;
66987 +
66988 + if (unlikely(!dentry->d_inode))
66989 + return GR_FIND;
66990 +
66991 + mode =
66992 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66993 +
66994 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66995 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66996 + return mode;
66997 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66998 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66999 + return 0;
67000 + } else if (unlikely(!(mode & GR_FIND)))
67001 + return 0;
67002 +
67003 + return GR_FIND;
67004 +}
67005 +
67006 +__u32
67007 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
67008 + int acc_mode)
67009 +{
67010 + __u32 reqmode = GR_FIND;
67011 + __u32 mode;
67012 +
67013 + if (unlikely(!dentry->d_inode))
67014 + return reqmode;
67015 +
67016 + if (acc_mode & MAY_APPEND)
67017 + reqmode |= GR_APPEND;
67018 + else if (acc_mode & MAY_WRITE)
67019 + reqmode |= GR_WRITE;
67020 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
67021 + reqmode |= GR_READ;
67022 +
67023 + mode =
67024 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67025 + mnt);
67026 +
67027 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67028 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
67029 + reqmode & GR_READ ? " reading" : "",
67030 + reqmode & GR_WRITE ? " writing" : reqmode &
67031 + GR_APPEND ? " appending" : "");
67032 + return reqmode;
67033 + } else
67034 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67035 + {
67036 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
67037 + reqmode & GR_READ ? " reading" : "",
67038 + reqmode & GR_WRITE ? " writing" : reqmode &
67039 + GR_APPEND ? " appending" : "");
67040 + return 0;
67041 + } else if (unlikely((mode & reqmode) != reqmode))
67042 + return 0;
67043 +
67044 + return reqmode;
67045 +}
67046 +
67047 +__u32
67048 +gr_acl_handle_creat(const struct dentry * dentry,
67049 + const struct dentry * p_dentry,
67050 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
67051 + const int imode)
67052 +{
67053 + __u32 reqmode = GR_WRITE | GR_CREATE;
67054 + __u32 mode;
67055 +
67056 + if (acc_mode & MAY_APPEND)
67057 + reqmode |= GR_APPEND;
67058 + // if a directory was required or the directory already exists, then
67059 + // don't count this open as a read
67060 + if ((acc_mode & MAY_READ) &&
67061 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
67062 + reqmode |= GR_READ;
67063 + if ((open_flags & O_CREAT) &&
67064 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67065 + reqmode |= GR_SETID;
67066 +
67067 + mode =
67068 + gr_check_create(dentry, p_dentry, p_mnt,
67069 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67070 +
67071 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67072 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67073 + reqmode & GR_READ ? " reading" : "",
67074 + reqmode & GR_WRITE ? " writing" : reqmode &
67075 + GR_APPEND ? " appending" : "");
67076 + return reqmode;
67077 + } else
67078 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67079 + {
67080 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67081 + reqmode & GR_READ ? " reading" : "",
67082 + reqmode & GR_WRITE ? " writing" : reqmode &
67083 + GR_APPEND ? " appending" : "");
67084 + return 0;
67085 + } else if (unlikely((mode & reqmode) != reqmode))
67086 + return 0;
67087 +
67088 + return reqmode;
67089 +}
67090 +
67091 +__u32
67092 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67093 + const int fmode)
67094 +{
67095 + __u32 mode, reqmode = GR_FIND;
67096 +
67097 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67098 + reqmode |= GR_EXEC;
67099 + if (fmode & S_IWOTH)
67100 + reqmode |= GR_WRITE;
67101 + if (fmode & S_IROTH)
67102 + reqmode |= GR_READ;
67103 +
67104 + mode =
67105 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67106 + mnt);
67107 +
67108 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67109 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67110 + reqmode & GR_READ ? " reading" : "",
67111 + reqmode & GR_WRITE ? " writing" : "",
67112 + reqmode & GR_EXEC ? " executing" : "");
67113 + return reqmode;
67114 + } else
67115 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67116 + {
67117 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67118 + reqmode & GR_READ ? " reading" : "",
67119 + reqmode & GR_WRITE ? " writing" : "",
67120 + reqmode & GR_EXEC ? " executing" : "");
67121 + return 0;
67122 + } else if (unlikely((mode & reqmode) != reqmode))
67123 + return 0;
67124 +
67125 + return reqmode;
67126 +}
67127 +
67128 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67129 +{
67130 + __u32 mode;
67131 +
67132 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67133 +
67134 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67135 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67136 + return mode;
67137 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67138 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67139 + return 0;
67140 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67141 + return 0;
67142 +
67143 + return (reqmode);
67144 +}
67145 +
67146 +__u32
67147 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67148 +{
67149 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67150 +}
67151 +
67152 +__u32
67153 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67154 +{
67155 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67156 +}
67157 +
67158 +__u32
67159 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67160 +{
67161 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67162 +}
67163 +
67164 +__u32
67165 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67166 +{
67167 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67168 +}
67169 +
67170 +__u32
67171 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67172 + umode_t *modeptr)
67173 +{
67174 + umode_t mode;
67175 +
67176 + *modeptr &= ~gr_acl_umask();
67177 + mode = *modeptr;
67178 +
67179 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67180 + return 1;
67181 +
67182 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67183 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67184 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67185 + GR_CHMOD_ACL_MSG);
67186 + } else {
67187 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67188 + }
67189 +}
67190 +
67191 +__u32
67192 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67193 +{
67194 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67195 +}
67196 +
67197 +__u32
67198 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67199 +{
67200 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67201 +}
67202 +
67203 +__u32
67204 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67205 +{
67206 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67207 +}
67208 +
67209 +__u32
67210 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67211 +{
67212 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67213 + GR_UNIXCONNECT_ACL_MSG);
67214 +}
67215 +
67216 +/* hardlinks require at minimum create and link permission,
67217 + any additional privilege required is based on the
67218 + privilege of the file being linked to
67219 +*/
67220 +__u32
67221 +gr_acl_handle_link(const struct dentry * new_dentry,
67222 + const struct dentry * parent_dentry,
67223 + const struct vfsmount * parent_mnt,
67224 + const struct dentry * old_dentry,
67225 + const struct vfsmount * old_mnt, const struct filename *to)
67226 +{
67227 + __u32 mode;
67228 + __u32 needmode = GR_CREATE | GR_LINK;
67229 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67230 +
67231 + mode =
67232 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67233 + old_mnt);
67234 +
67235 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67236 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67237 + return mode;
67238 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67239 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67240 + return 0;
67241 + } else if (unlikely((mode & needmode) != needmode))
67242 + return 0;
67243 +
67244 + return 1;
67245 +}
67246 +
67247 +__u32
67248 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67249 + const struct dentry * parent_dentry,
67250 + const struct vfsmount * parent_mnt, const struct filename *from)
67251 +{
67252 + __u32 needmode = GR_WRITE | GR_CREATE;
67253 + __u32 mode;
67254 +
67255 + mode =
67256 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67257 + GR_CREATE | GR_AUDIT_CREATE |
67258 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67259 +
67260 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67261 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67262 + return mode;
67263 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67264 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67265 + return 0;
67266 + } else if (unlikely((mode & needmode) != needmode))
67267 + return 0;
67268 +
67269 + return (GR_WRITE | GR_CREATE);
67270 +}
67271 +
67272 +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)
67273 +{
67274 + __u32 mode;
67275 +
67276 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67277 +
67278 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67279 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67280 + return mode;
67281 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67282 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67283 + return 0;
67284 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67285 + return 0;
67286 +
67287 + return (reqmode);
67288 +}
67289 +
67290 +__u32
67291 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67292 + const struct dentry * parent_dentry,
67293 + const struct vfsmount * parent_mnt,
67294 + const int mode)
67295 +{
67296 + __u32 reqmode = GR_WRITE | GR_CREATE;
67297 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67298 + reqmode |= GR_SETID;
67299 +
67300 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67301 + reqmode, GR_MKNOD_ACL_MSG);
67302 +}
67303 +
67304 +__u32
67305 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67306 + const struct dentry *parent_dentry,
67307 + const struct vfsmount *parent_mnt)
67308 +{
67309 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67310 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67311 +}
67312 +
67313 +#define RENAME_CHECK_SUCCESS(old, new) \
67314 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67315 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67316 +
67317 +int
67318 +gr_acl_handle_rename(struct dentry *new_dentry,
67319 + struct dentry *parent_dentry,
67320 + const struct vfsmount *parent_mnt,
67321 + struct dentry *old_dentry,
67322 + struct inode *old_parent_inode,
67323 + struct vfsmount *old_mnt, const struct filename *newname)
67324 +{
67325 + __u32 comp1, comp2;
67326 + int error = 0;
67327 +
67328 + if (unlikely(!gr_acl_is_enabled()))
67329 + return 0;
67330 +
67331 + if (!new_dentry->d_inode) {
67332 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67333 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67334 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67335 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67336 + GR_DELETE | GR_AUDIT_DELETE |
67337 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67338 + GR_SUPPRESS, old_mnt);
67339 + } else {
67340 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67341 + GR_CREATE | GR_DELETE |
67342 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67343 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67344 + GR_SUPPRESS, parent_mnt);
67345 + comp2 =
67346 + gr_search_file(old_dentry,
67347 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67348 + GR_DELETE | GR_AUDIT_DELETE |
67349 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67350 + }
67351 +
67352 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67353 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67354 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67355 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67356 + && !(comp2 & GR_SUPPRESS)) {
67357 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67358 + error = -EACCES;
67359 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67360 + error = -EACCES;
67361 +
67362 + return error;
67363 +}
67364 +
67365 +void
67366 +gr_acl_handle_exit(void)
67367 +{
67368 + u16 id;
67369 + char *rolename;
67370 +
67371 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67372 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67373 + id = current->acl_role_id;
67374 + rolename = current->role->rolename;
67375 + gr_set_acls(1);
67376 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67377 + }
67378 +
67379 + gr_put_exec_file(current);
67380 + return;
67381 +}
67382 +
67383 +int
67384 +gr_acl_handle_procpidmem(const struct task_struct *task)
67385 +{
67386 + if (unlikely(!gr_acl_is_enabled()))
67387 + return 0;
67388 +
67389 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67390 + return -EACCES;
67391 +
67392 + return 0;
67393 +}
67394 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67395 new file mode 100644
67396 index 0000000..f056b81
67397 --- /dev/null
67398 +++ b/grsecurity/gracl_ip.c
67399 @@ -0,0 +1,386 @@
67400 +#include <linux/kernel.h>
67401 +#include <asm/uaccess.h>
67402 +#include <asm/errno.h>
67403 +#include <net/sock.h>
67404 +#include <linux/file.h>
67405 +#include <linux/fs.h>
67406 +#include <linux/net.h>
67407 +#include <linux/in.h>
67408 +#include <linux/skbuff.h>
67409 +#include <linux/ip.h>
67410 +#include <linux/udp.h>
67411 +#include <linux/types.h>
67412 +#include <linux/sched.h>
67413 +#include <linux/netdevice.h>
67414 +#include <linux/inetdevice.h>
67415 +#include <linux/gracl.h>
67416 +#include <linux/grsecurity.h>
67417 +#include <linux/grinternal.h>
67418 +
67419 +#define GR_BIND 0x01
67420 +#define GR_CONNECT 0x02
67421 +#define GR_INVERT 0x04
67422 +#define GR_BINDOVERRIDE 0x08
67423 +#define GR_CONNECTOVERRIDE 0x10
67424 +#define GR_SOCK_FAMILY 0x20
67425 +
67426 +static const char * gr_protocols[IPPROTO_MAX] = {
67427 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67428 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67429 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67430 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67431 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67432 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67433 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67434 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67435 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67436 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67437 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67438 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67439 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67440 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67441 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67442 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67443 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67444 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67445 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67446 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67447 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67448 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67449 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67450 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67451 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67452 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67453 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67454 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67455 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67456 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67457 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67458 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67459 + };
67460 +
67461 +static const char * gr_socktypes[SOCK_MAX] = {
67462 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67463 + "unknown:7", "unknown:8", "unknown:9", "packet"
67464 + };
67465 +
67466 +static const char * gr_sockfamilies[AF_MAX+1] = {
67467 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67468 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67469 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67470 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67471 + };
67472 +
67473 +const char *
67474 +gr_proto_to_name(unsigned char proto)
67475 +{
67476 + return gr_protocols[proto];
67477 +}
67478 +
67479 +const char *
67480 +gr_socktype_to_name(unsigned char type)
67481 +{
67482 + return gr_socktypes[type];
67483 +}
67484 +
67485 +const char *
67486 +gr_sockfamily_to_name(unsigned char family)
67487 +{
67488 + return gr_sockfamilies[family];
67489 +}
67490 +
67491 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67492 +
67493 +int
67494 +gr_search_socket(const int domain, const int type, const int protocol)
67495 +{
67496 + struct acl_subject_label *curr;
67497 + const struct cred *cred = current_cred();
67498 +
67499 + if (unlikely(!gr_acl_is_enabled()))
67500 + goto exit;
67501 +
67502 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67503 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67504 + goto exit; // let the kernel handle it
67505 +
67506 + curr = current->acl;
67507 +
67508 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67509 + /* the family is allowed, if this is PF_INET allow it only if
67510 + the extra sock type/protocol checks pass */
67511 + if (domain == PF_INET)
67512 + goto inet_check;
67513 + goto exit;
67514 + } else {
67515 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67516 + __u32 fakeip = 0;
67517 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67518 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67519 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67520 + gr_to_filename(current->exec_file->f_path.dentry,
67521 + current->exec_file->f_path.mnt) :
67522 + curr->filename, curr->filename,
67523 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67524 + &current->signal->saved_ip);
67525 + goto exit;
67526 + }
67527 + goto exit_fail;
67528 + }
67529 +
67530 +inet_check:
67531 + /* the rest of this checking is for IPv4 only */
67532 + if (!curr->ips)
67533 + goto exit;
67534 +
67535 + if ((curr->ip_type & (1U << type)) &&
67536 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67537 + goto exit;
67538 +
67539 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67540 + /* we don't place acls on raw sockets , and sometimes
67541 + dgram/ip sockets are opened for ioctl and not
67542 + bind/connect, so we'll fake a bind learn log */
67543 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67544 + __u32 fakeip = 0;
67545 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67546 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67547 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67548 + gr_to_filename(current->exec_file->f_path.dentry,
67549 + current->exec_file->f_path.mnt) :
67550 + curr->filename, curr->filename,
67551 + &fakeip, 0, type,
67552 + protocol, GR_CONNECT, &current->signal->saved_ip);
67553 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67554 + __u32 fakeip = 0;
67555 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67556 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67557 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67558 + gr_to_filename(current->exec_file->f_path.dentry,
67559 + current->exec_file->f_path.mnt) :
67560 + curr->filename, curr->filename,
67561 + &fakeip, 0, type,
67562 + protocol, GR_BIND, &current->signal->saved_ip);
67563 + }
67564 + /* we'll log when they use connect or bind */
67565 + goto exit;
67566 + }
67567 +
67568 +exit_fail:
67569 + if (domain == PF_INET)
67570 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67571 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67572 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67573 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67574 + gr_socktype_to_name(type), protocol);
67575 +
67576 + return 0;
67577 +exit:
67578 + return 1;
67579 +}
67580 +
67581 +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)
67582 +{
67583 + if ((ip->mode & mode) &&
67584 + (ip_port >= ip->low) &&
67585 + (ip_port <= ip->high) &&
67586 + ((ntohl(ip_addr) & our_netmask) ==
67587 + (ntohl(our_addr) & our_netmask))
67588 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67589 + && (ip->type & (1U << type))) {
67590 + if (ip->mode & GR_INVERT)
67591 + return 2; // specifically denied
67592 + else
67593 + return 1; // allowed
67594 + }
67595 +
67596 + return 0; // not specifically allowed, may continue parsing
67597 +}
67598 +
67599 +static int
67600 +gr_search_connectbind(const int full_mode, struct sock *sk,
67601 + struct sockaddr_in *addr, const int type)
67602 +{
67603 + char iface[IFNAMSIZ] = {0};
67604 + struct acl_subject_label *curr;
67605 + struct acl_ip_label *ip;
67606 + struct inet_sock *isk;
67607 + struct net_device *dev;
67608 + struct in_device *idev;
67609 + unsigned long i;
67610 + int ret;
67611 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67612 + __u32 ip_addr = 0;
67613 + __u32 our_addr;
67614 + __u32 our_netmask;
67615 + char *p;
67616 + __u16 ip_port = 0;
67617 + const struct cred *cred = current_cred();
67618 +
67619 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67620 + return 0;
67621 +
67622 + curr = current->acl;
67623 + isk = inet_sk(sk);
67624 +
67625 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67626 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67627 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67628 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67629 + struct sockaddr_in saddr;
67630 + int err;
67631 +
67632 + saddr.sin_family = AF_INET;
67633 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67634 + saddr.sin_port = isk->inet_sport;
67635 +
67636 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67637 + if (err)
67638 + return err;
67639 +
67640 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67641 + if (err)
67642 + return err;
67643 + }
67644 +
67645 + if (!curr->ips)
67646 + return 0;
67647 +
67648 + ip_addr = addr->sin_addr.s_addr;
67649 + ip_port = ntohs(addr->sin_port);
67650 +
67651 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67652 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67653 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67654 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67655 + gr_to_filename(current->exec_file->f_path.dentry,
67656 + current->exec_file->f_path.mnt) :
67657 + curr->filename, curr->filename,
67658 + &ip_addr, ip_port, type,
67659 + sk->sk_protocol, mode, &current->signal->saved_ip);
67660 + return 0;
67661 + }
67662 +
67663 + for (i = 0; i < curr->ip_num; i++) {
67664 + ip = *(curr->ips + i);
67665 + if (ip->iface != NULL) {
67666 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67667 + p = strchr(iface, ':');
67668 + if (p != NULL)
67669 + *p = '\0';
67670 + dev = dev_get_by_name(sock_net(sk), iface);
67671 + if (dev == NULL)
67672 + continue;
67673 + idev = in_dev_get(dev);
67674 + if (idev == NULL) {
67675 + dev_put(dev);
67676 + continue;
67677 + }
67678 + rcu_read_lock();
67679 + for_ifa(idev) {
67680 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67681 + our_addr = ifa->ifa_address;
67682 + our_netmask = 0xffffffff;
67683 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67684 + if (ret == 1) {
67685 + rcu_read_unlock();
67686 + in_dev_put(idev);
67687 + dev_put(dev);
67688 + return 0;
67689 + } else if (ret == 2) {
67690 + rcu_read_unlock();
67691 + in_dev_put(idev);
67692 + dev_put(dev);
67693 + goto denied;
67694 + }
67695 + }
67696 + } endfor_ifa(idev);
67697 + rcu_read_unlock();
67698 + in_dev_put(idev);
67699 + dev_put(dev);
67700 + } else {
67701 + our_addr = ip->addr;
67702 + our_netmask = ip->netmask;
67703 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67704 + if (ret == 1)
67705 + return 0;
67706 + else if (ret == 2)
67707 + goto denied;
67708 + }
67709 + }
67710 +
67711 +denied:
67712 + if (mode == GR_BIND)
67713 + 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));
67714 + else if (mode == GR_CONNECT)
67715 + 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));
67716 +
67717 + return -EACCES;
67718 +}
67719 +
67720 +int
67721 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67722 +{
67723 + /* always allow disconnection of dgram sockets with connect */
67724 + if (addr->sin_family == AF_UNSPEC)
67725 + return 0;
67726 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67727 +}
67728 +
67729 +int
67730 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67731 +{
67732 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67733 +}
67734 +
67735 +int gr_search_listen(struct socket *sock)
67736 +{
67737 + struct sock *sk = sock->sk;
67738 + struct sockaddr_in addr;
67739 +
67740 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67741 + addr.sin_port = inet_sk(sk)->inet_sport;
67742 +
67743 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67744 +}
67745 +
67746 +int gr_search_accept(struct socket *sock)
67747 +{
67748 + struct sock *sk = sock->sk;
67749 + struct sockaddr_in addr;
67750 +
67751 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67752 + addr.sin_port = inet_sk(sk)->inet_sport;
67753 +
67754 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67755 +}
67756 +
67757 +int
67758 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67759 +{
67760 + if (addr)
67761 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67762 + else {
67763 + struct sockaddr_in sin;
67764 + const struct inet_sock *inet = inet_sk(sk);
67765 +
67766 + sin.sin_addr.s_addr = inet->inet_daddr;
67767 + sin.sin_port = inet->inet_dport;
67768 +
67769 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67770 + }
67771 +}
67772 +
67773 +int
67774 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67775 +{
67776 + struct sockaddr_in sin;
67777 +
67778 + if (unlikely(skb->len < sizeof (struct udphdr)))
67779 + return 0; // skip this packet
67780 +
67781 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67782 + sin.sin_port = udp_hdr(skb)->source;
67783 +
67784 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67785 +}
67786 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67787 new file mode 100644
67788 index 0000000..25f54ef
67789 --- /dev/null
67790 +++ b/grsecurity/gracl_learn.c
67791 @@ -0,0 +1,207 @@
67792 +#include <linux/kernel.h>
67793 +#include <linux/mm.h>
67794 +#include <linux/sched.h>
67795 +#include <linux/poll.h>
67796 +#include <linux/string.h>
67797 +#include <linux/file.h>
67798 +#include <linux/types.h>
67799 +#include <linux/vmalloc.h>
67800 +#include <linux/grinternal.h>
67801 +
67802 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67803 + size_t count, loff_t *ppos);
67804 +extern int gr_acl_is_enabled(void);
67805 +
67806 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67807 +static int gr_learn_attached;
67808 +
67809 +/* use a 512k buffer */
67810 +#define LEARN_BUFFER_SIZE (512 * 1024)
67811 +
67812 +static DEFINE_SPINLOCK(gr_learn_lock);
67813 +static DEFINE_MUTEX(gr_learn_user_mutex);
67814 +
67815 +/* we need to maintain two buffers, so that the kernel context of grlearn
67816 + uses a semaphore around the userspace copying, and the other kernel contexts
67817 + use a spinlock when copying into the buffer, since they cannot sleep
67818 +*/
67819 +static char *learn_buffer;
67820 +static char *learn_buffer_user;
67821 +static int learn_buffer_len;
67822 +static int learn_buffer_user_len;
67823 +
67824 +static ssize_t
67825 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67826 +{
67827 + DECLARE_WAITQUEUE(wait, current);
67828 + ssize_t retval = 0;
67829 +
67830 + add_wait_queue(&learn_wait, &wait);
67831 + set_current_state(TASK_INTERRUPTIBLE);
67832 + do {
67833 + mutex_lock(&gr_learn_user_mutex);
67834 + spin_lock(&gr_learn_lock);
67835 + if (learn_buffer_len)
67836 + break;
67837 + spin_unlock(&gr_learn_lock);
67838 + mutex_unlock(&gr_learn_user_mutex);
67839 + if (file->f_flags & O_NONBLOCK) {
67840 + retval = -EAGAIN;
67841 + goto out;
67842 + }
67843 + if (signal_pending(current)) {
67844 + retval = -ERESTARTSYS;
67845 + goto out;
67846 + }
67847 +
67848 + schedule();
67849 + } while (1);
67850 +
67851 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67852 + learn_buffer_user_len = learn_buffer_len;
67853 + retval = learn_buffer_len;
67854 + learn_buffer_len = 0;
67855 +
67856 + spin_unlock(&gr_learn_lock);
67857 +
67858 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67859 + retval = -EFAULT;
67860 +
67861 + mutex_unlock(&gr_learn_user_mutex);
67862 +out:
67863 + set_current_state(TASK_RUNNING);
67864 + remove_wait_queue(&learn_wait, &wait);
67865 + return retval;
67866 +}
67867 +
67868 +static unsigned int
67869 +poll_learn(struct file * file, poll_table * wait)
67870 +{
67871 + poll_wait(file, &learn_wait, wait);
67872 +
67873 + if (learn_buffer_len)
67874 + return (POLLIN | POLLRDNORM);
67875 +
67876 + return 0;
67877 +}
67878 +
67879 +void
67880 +gr_clear_learn_entries(void)
67881 +{
67882 + char *tmp;
67883 +
67884 + mutex_lock(&gr_learn_user_mutex);
67885 + spin_lock(&gr_learn_lock);
67886 + tmp = learn_buffer;
67887 + learn_buffer = NULL;
67888 + spin_unlock(&gr_learn_lock);
67889 + if (tmp)
67890 + vfree(tmp);
67891 + if (learn_buffer_user != NULL) {
67892 + vfree(learn_buffer_user);
67893 + learn_buffer_user = NULL;
67894 + }
67895 + learn_buffer_len = 0;
67896 + mutex_unlock(&gr_learn_user_mutex);
67897 +
67898 + return;
67899 +}
67900 +
67901 +void
67902 +gr_add_learn_entry(const char *fmt, ...)
67903 +{
67904 + va_list args;
67905 + unsigned int len;
67906 +
67907 + if (!gr_learn_attached)
67908 + return;
67909 +
67910 + spin_lock(&gr_learn_lock);
67911 +
67912 + /* leave a gap at the end so we know when it's "full" but don't have to
67913 + compute the exact length of the string we're trying to append
67914 + */
67915 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67916 + spin_unlock(&gr_learn_lock);
67917 + wake_up_interruptible(&learn_wait);
67918 + return;
67919 + }
67920 + if (learn_buffer == NULL) {
67921 + spin_unlock(&gr_learn_lock);
67922 + return;
67923 + }
67924 +
67925 + va_start(args, fmt);
67926 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67927 + va_end(args);
67928 +
67929 + learn_buffer_len += len + 1;
67930 +
67931 + spin_unlock(&gr_learn_lock);
67932 + wake_up_interruptible(&learn_wait);
67933 +
67934 + return;
67935 +}
67936 +
67937 +static int
67938 +open_learn(struct inode *inode, struct file *file)
67939 +{
67940 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67941 + return -EBUSY;
67942 + if (file->f_mode & FMODE_READ) {
67943 + int retval = 0;
67944 + mutex_lock(&gr_learn_user_mutex);
67945 + if (learn_buffer == NULL)
67946 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67947 + if (learn_buffer_user == NULL)
67948 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67949 + if (learn_buffer == NULL) {
67950 + retval = -ENOMEM;
67951 + goto out_error;
67952 + }
67953 + if (learn_buffer_user == NULL) {
67954 + retval = -ENOMEM;
67955 + goto out_error;
67956 + }
67957 + learn_buffer_len = 0;
67958 + learn_buffer_user_len = 0;
67959 + gr_learn_attached = 1;
67960 +out_error:
67961 + mutex_unlock(&gr_learn_user_mutex);
67962 + return retval;
67963 + }
67964 + return 0;
67965 +}
67966 +
67967 +static int
67968 +close_learn(struct inode *inode, struct file *file)
67969 +{
67970 + if (file->f_mode & FMODE_READ) {
67971 + char *tmp = NULL;
67972 + mutex_lock(&gr_learn_user_mutex);
67973 + spin_lock(&gr_learn_lock);
67974 + tmp = learn_buffer;
67975 + learn_buffer = NULL;
67976 + spin_unlock(&gr_learn_lock);
67977 + if (tmp)
67978 + vfree(tmp);
67979 + if (learn_buffer_user != NULL) {
67980 + vfree(learn_buffer_user);
67981 + learn_buffer_user = NULL;
67982 + }
67983 + learn_buffer_len = 0;
67984 + learn_buffer_user_len = 0;
67985 + gr_learn_attached = 0;
67986 + mutex_unlock(&gr_learn_user_mutex);
67987 + }
67988 +
67989 + return 0;
67990 +}
67991 +
67992 +const struct file_operations grsec_fops = {
67993 + .read = read_learn,
67994 + .write = write_grsec_handler,
67995 + .open = open_learn,
67996 + .release = close_learn,
67997 + .poll = poll_learn,
67998 +};
67999 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68000 new file mode 100644
68001 index 0000000..39645c9
68002 --- /dev/null
68003 +++ b/grsecurity/gracl_res.c
68004 @@ -0,0 +1,68 @@
68005 +#include <linux/kernel.h>
68006 +#include <linux/sched.h>
68007 +#include <linux/gracl.h>
68008 +#include <linux/grinternal.h>
68009 +
68010 +static const char *restab_log[] = {
68011 + [RLIMIT_CPU] = "RLIMIT_CPU",
68012 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68013 + [RLIMIT_DATA] = "RLIMIT_DATA",
68014 + [RLIMIT_STACK] = "RLIMIT_STACK",
68015 + [RLIMIT_CORE] = "RLIMIT_CORE",
68016 + [RLIMIT_RSS] = "RLIMIT_RSS",
68017 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68018 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68019 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68020 + [RLIMIT_AS] = "RLIMIT_AS",
68021 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68022 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68023 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68024 + [RLIMIT_NICE] = "RLIMIT_NICE",
68025 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68026 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68027 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68028 +};
68029 +
68030 +void
68031 +gr_log_resource(const struct task_struct *task,
68032 + const int res, const unsigned long wanted, const int gt)
68033 +{
68034 + const struct cred *cred;
68035 + unsigned long rlim;
68036 +
68037 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68038 + return;
68039 +
68040 + // not yet supported resource
68041 + if (unlikely(!restab_log[res]))
68042 + return;
68043 +
68044 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68045 + rlim = task_rlimit_max(task, res);
68046 + else
68047 + rlim = task_rlimit(task, res);
68048 +
68049 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68050 + return;
68051 +
68052 + rcu_read_lock();
68053 + cred = __task_cred(task);
68054 +
68055 + if (res == RLIMIT_NPROC &&
68056 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68057 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68058 + goto out_rcu_unlock;
68059 + else if (res == RLIMIT_MEMLOCK &&
68060 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68061 + goto out_rcu_unlock;
68062 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68063 + goto out_rcu_unlock;
68064 + rcu_read_unlock();
68065 +
68066 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68067 +
68068 + return;
68069 +out_rcu_unlock:
68070 + rcu_read_unlock();
68071 + return;
68072 +}
68073 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68074 new file mode 100644
68075 index 0000000..3c38bfe
68076 --- /dev/null
68077 +++ b/grsecurity/gracl_segv.c
68078 @@ -0,0 +1,305 @@
68079 +#include <linux/kernel.h>
68080 +#include <linux/mm.h>
68081 +#include <asm/uaccess.h>
68082 +#include <asm/errno.h>
68083 +#include <asm/mman.h>
68084 +#include <net/sock.h>
68085 +#include <linux/file.h>
68086 +#include <linux/fs.h>
68087 +#include <linux/net.h>
68088 +#include <linux/in.h>
68089 +#include <linux/slab.h>
68090 +#include <linux/types.h>
68091 +#include <linux/sched.h>
68092 +#include <linux/timer.h>
68093 +#include <linux/gracl.h>
68094 +#include <linux/grsecurity.h>
68095 +#include <linux/grinternal.h>
68096 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68097 +#include <linux/magic.h>
68098 +#include <linux/pagemap.h>
68099 +#include "../fs/btrfs/async-thread.h"
68100 +#include "../fs/btrfs/ctree.h"
68101 +#include "../fs/btrfs/btrfs_inode.h"
68102 +#endif
68103 +
68104 +static struct crash_uid *uid_set;
68105 +static unsigned short uid_used;
68106 +static DEFINE_SPINLOCK(gr_uid_lock);
68107 +extern rwlock_t gr_inode_lock;
68108 +extern struct acl_subject_label *
68109 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68110 + struct acl_role_label *role);
68111 +
68112 +static inline dev_t __get_dev(const struct dentry *dentry)
68113 +{
68114 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68115 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68116 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68117 + else
68118 +#endif
68119 + return dentry->d_sb->s_dev;
68120 +}
68121 +
68122 +int
68123 +gr_init_uidset(void)
68124 +{
68125 + uid_set =
68126 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68127 + uid_used = 0;
68128 +
68129 + return uid_set ? 1 : 0;
68130 +}
68131 +
68132 +void
68133 +gr_free_uidset(void)
68134 +{
68135 + if (uid_set)
68136 + kfree(uid_set);
68137 +
68138 + return;
68139 +}
68140 +
68141 +int
68142 +gr_find_uid(const uid_t uid)
68143 +{
68144 + struct crash_uid *tmp = uid_set;
68145 + uid_t buid;
68146 + int low = 0, high = uid_used - 1, mid;
68147 +
68148 + while (high >= low) {
68149 + mid = (low + high) >> 1;
68150 + buid = tmp[mid].uid;
68151 + if (buid == uid)
68152 + return mid;
68153 + if (buid > uid)
68154 + high = mid - 1;
68155 + if (buid < uid)
68156 + low = mid + 1;
68157 + }
68158 +
68159 + return -1;
68160 +}
68161 +
68162 +static __inline__ void
68163 +gr_insertsort(void)
68164 +{
68165 + unsigned short i, j;
68166 + struct crash_uid index;
68167 +
68168 + for (i = 1; i < uid_used; i++) {
68169 + index = uid_set[i];
68170 + j = i;
68171 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68172 + uid_set[j] = uid_set[j - 1];
68173 + j--;
68174 + }
68175 + uid_set[j] = index;
68176 + }
68177 +
68178 + return;
68179 +}
68180 +
68181 +static __inline__ void
68182 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68183 +{
68184 + int loc;
68185 + uid_t uid = GR_GLOBAL_UID(kuid);
68186 +
68187 + if (uid_used == GR_UIDTABLE_MAX)
68188 + return;
68189 +
68190 + loc = gr_find_uid(uid);
68191 +
68192 + if (loc >= 0) {
68193 + uid_set[loc].expires = expires;
68194 + return;
68195 + }
68196 +
68197 + uid_set[uid_used].uid = uid;
68198 + uid_set[uid_used].expires = expires;
68199 + uid_used++;
68200 +
68201 + gr_insertsort();
68202 +
68203 + return;
68204 +}
68205 +
68206 +void
68207 +gr_remove_uid(const unsigned short loc)
68208 +{
68209 + unsigned short i;
68210 +
68211 + for (i = loc + 1; i < uid_used; i++)
68212 + uid_set[i - 1] = uid_set[i];
68213 +
68214 + uid_used--;
68215 +
68216 + return;
68217 +}
68218 +
68219 +int
68220 +gr_check_crash_uid(const kuid_t kuid)
68221 +{
68222 + int loc;
68223 + int ret = 0;
68224 + uid_t uid;
68225 +
68226 + if (unlikely(!gr_acl_is_enabled()))
68227 + return 0;
68228 +
68229 + uid = GR_GLOBAL_UID(kuid);
68230 +
68231 + spin_lock(&gr_uid_lock);
68232 + loc = gr_find_uid(uid);
68233 +
68234 + if (loc < 0)
68235 + goto out_unlock;
68236 +
68237 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68238 + gr_remove_uid(loc);
68239 + else
68240 + ret = 1;
68241 +
68242 +out_unlock:
68243 + spin_unlock(&gr_uid_lock);
68244 + return ret;
68245 +}
68246 +
68247 +static __inline__ int
68248 +proc_is_setxid(const struct cred *cred)
68249 +{
68250 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68251 + !uid_eq(cred->uid, cred->fsuid))
68252 + return 1;
68253 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68254 + !gid_eq(cred->gid, cred->fsgid))
68255 + return 1;
68256 +
68257 + return 0;
68258 +}
68259 +
68260 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68261 +
68262 +void
68263 +gr_handle_crash(struct task_struct *task, const int sig)
68264 +{
68265 + struct acl_subject_label *curr;
68266 + struct task_struct *tsk, *tsk2;
68267 + const struct cred *cred;
68268 + const struct cred *cred2;
68269 +
68270 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68271 + return;
68272 +
68273 + if (unlikely(!gr_acl_is_enabled()))
68274 + return;
68275 +
68276 + curr = task->acl;
68277 +
68278 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68279 + return;
68280 +
68281 + if (time_before_eq(curr->expires, get_seconds())) {
68282 + curr->expires = 0;
68283 + curr->crashes = 0;
68284 + }
68285 +
68286 + curr->crashes++;
68287 +
68288 + if (!curr->expires)
68289 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68290 +
68291 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68292 + time_after(curr->expires, get_seconds())) {
68293 + rcu_read_lock();
68294 + cred = __task_cred(task);
68295 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68296 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68297 + spin_lock(&gr_uid_lock);
68298 + gr_insert_uid(cred->uid, curr->expires);
68299 + spin_unlock(&gr_uid_lock);
68300 + curr->expires = 0;
68301 + curr->crashes = 0;
68302 + read_lock(&tasklist_lock);
68303 + do_each_thread(tsk2, tsk) {
68304 + cred2 = __task_cred(tsk);
68305 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68306 + gr_fake_force_sig(SIGKILL, tsk);
68307 + } while_each_thread(tsk2, tsk);
68308 + read_unlock(&tasklist_lock);
68309 + } else {
68310 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68311 + read_lock(&tasklist_lock);
68312 + read_lock(&grsec_exec_file_lock);
68313 + do_each_thread(tsk2, tsk) {
68314 + if (likely(tsk != task)) {
68315 + // if this thread has the same subject as the one that triggered
68316 + // RES_CRASH and it's the same binary, kill it
68317 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68318 + gr_fake_force_sig(SIGKILL, tsk);
68319 + }
68320 + } while_each_thread(tsk2, tsk);
68321 + read_unlock(&grsec_exec_file_lock);
68322 + read_unlock(&tasklist_lock);
68323 + }
68324 + rcu_read_unlock();
68325 + }
68326 +
68327 + return;
68328 +}
68329 +
68330 +int
68331 +gr_check_crash_exec(const struct file *filp)
68332 +{
68333 + struct acl_subject_label *curr;
68334 +
68335 + if (unlikely(!gr_acl_is_enabled()))
68336 + return 0;
68337 +
68338 + read_lock(&gr_inode_lock);
68339 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68340 + __get_dev(filp->f_path.dentry),
68341 + current->role);
68342 + read_unlock(&gr_inode_lock);
68343 +
68344 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68345 + (!curr->crashes && !curr->expires))
68346 + return 0;
68347 +
68348 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68349 + time_after(curr->expires, get_seconds()))
68350 + return 1;
68351 + else if (time_before_eq(curr->expires, get_seconds())) {
68352 + curr->crashes = 0;
68353 + curr->expires = 0;
68354 + }
68355 +
68356 + return 0;
68357 +}
68358 +
68359 +void
68360 +gr_handle_alertkill(struct task_struct *task)
68361 +{
68362 + struct acl_subject_label *curracl;
68363 + __u32 curr_ip;
68364 + struct task_struct *p, *p2;
68365 +
68366 + if (unlikely(!gr_acl_is_enabled()))
68367 + return;
68368 +
68369 + curracl = task->acl;
68370 + curr_ip = task->signal->curr_ip;
68371 +
68372 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68373 + read_lock(&tasklist_lock);
68374 + do_each_thread(p2, p) {
68375 + if (p->signal->curr_ip == curr_ip)
68376 + gr_fake_force_sig(SIGKILL, p);
68377 + } while_each_thread(p2, p);
68378 + read_unlock(&tasklist_lock);
68379 + } else if (curracl->mode & GR_KILLPROC)
68380 + gr_fake_force_sig(SIGKILL, task);
68381 +
68382 + return;
68383 +}
68384 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68385 new file mode 100644
68386 index 0000000..98011b0
68387 --- /dev/null
68388 +++ b/grsecurity/gracl_shm.c
68389 @@ -0,0 +1,40 @@
68390 +#include <linux/kernel.h>
68391 +#include <linux/mm.h>
68392 +#include <linux/sched.h>
68393 +#include <linux/file.h>
68394 +#include <linux/ipc.h>
68395 +#include <linux/gracl.h>
68396 +#include <linux/grsecurity.h>
68397 +#include <linux/grinternal.h>
68398 +
68399 +int
68400 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68401 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68402 +{
68403 + struct task_struct *task;
68404 +
68405 + if (!gr_acl_is_enabled())
68406 + return 1;
68407 +
68408 + rcu_read_lock();
68409 + read_lock(&tasklist_lock);
68410 +
68411 + task = find_task_by_vpid(shm_cprid);
68412 +
68413 + if (unlikely(!task))
68414 + task = find_task_by_vpid(shm_lapid);
68415 +
68416 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68417 + (task_pid_nr(task) == shm_lapid)) &&
68418 + (task->acl->mode & GR_PROTSHM) &&
68419 + (task->acl != current->acl))) {
68420 + read_unlock(&tasklist_lock);
68421 + rcu_read_unlock();
68422 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68423 + return 0;
68424 + }
68425 + read_unlock(&tasklist_lock);
68426 + rcu_read_unlock();
68427 +
68428 + return 1;
68429 +}
68430 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68431 new file mode 100644
68432 index 0000000..bc0be01
68433 --- /dev/null
68434 +++ b/grsecurity/grsec_chdir.c
68435 @@ -0,0 +1,19 @@
68436 +#include <linux/kernel.h>
68437 +#include <linux/sched.h>
68438 +#include <linux/fs.h>
68439 +#include <linux/file.h>
68440 +#include <linux/grsecurity.h>
68441 +#include <linux/grinternal.h>
68442 +
68443 +void
68444 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68445 +{
68446 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68447 + if ((grsec_enable_chdir && grsec_enable_group &&
68448 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68449 + !grsec_enable_group)) {
68450 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68451 + }
68452 +#endif
68453 + return;
68454 +}
68455 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68456 new file mode 100644
68457 index 0000000..bd6e105
68458 --- /dev/null
68459 +++ b/grsecurity/grsec_chroot.c
68460 @@ -0,0 +1,370 @@
68461 +#include <linux/kernel.h>
68462 +#include <linux/module.h>
68463 +#include <linux/sched.h>
68464 +#include <linux/file.h>
68465 +#include <linux/fs.h>
68466 +#include <linux/mount.h>
68467 +#include <linux/types.h>
68468 +#include "../fs/mount.h"
68469 +#include <linux/grsecurity.h>
68470 +#include <linux/grinternal.h>
68471 +
68472 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68473 +static int gr_init_ran;
68474 +#endif
68475 +
68476 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68477 +{
68478 +#ifdef CONFIG_GRKERNSEC
68479 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68480 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68481 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68482 + && gr_init_ran
68483 +#endif
68484 + )
68485 + task->gr_is_chrooted = 1;
68486 + else {
68487 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68488 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68489 + gr_init_ran = 1;
68490 +#endif
68491 + task->gr_is_chrooted = 0;
68492 + }
68493 +
68494 + task->gr_chroot_dentry = path->dentry;
68495 +#endif
68496 + return;
68497 +}
68498 +
68499 +void gr_clear_chroot_entries(struct task_struct *task)
68500 +{
68501 +#ifdef CONFIG_GRKERNSEC
68502 + task->gr_is_chrooted = 0;
68503 + task->gr_chroot_dentry = NULL;
68504 +#endif
68505 + return;
68506 +}
68507 +
68508 +int
68509 +gr_handle_chroot_unix(const pid_t pid)
68510 +{
68511 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68512 + struct task_struct *p;
68513 +
68514 + if (unlikely(!grsec_enable_chroot_unix))
68515 + return 1;
68516 +
68517 + if (likely(!proc_is_chrooted(current)))
68518 + return 1;
68519 +
68520 + rcu_read_lock();
68521 + read_lock(&tasklist_lock);
68522 + p = find_task_by_vpid_unrestricted(pid);
68523 + if (unlikely(p && !have_same_root(current, p))) {
68524 + read_unlock(&tasklist_lock);
68525 + rcu_read_unlock();
68526 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68527 + return 0;
68528 + }
68529 + read_unlock(&tasklist_lock);
68530 + rcu_read_unlock();
68531 +#endif
68532 + return 1;
68533 +}
68534 +
68535 +int
68536 +gr_handle_chroot_nice(void)
68537 +{
68538 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68539 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68540 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68541 + return -EPERM;
68542 + }
68543 +#endif
68544 + return 0;
68545 +}
68546 +
68547 +int
68548 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68549 +{
68550 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68551 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68552 + && proc_is_chrooted(current)) {
68553 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68554 + return -EACCES;
68555 + }
68556 +#endif
68557 + return 0;
68558 +}
68559 +
68560 +int
68561 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68562 +{
68563 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68564 + struct task_struct *p;
68565 + int ret = 0;
68566 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68567 + return ret;
68568 +
68569 + read_lock(&tasklist_lock);
68570 + do_each_pid_task(pid, type, p) {
68571 + if (!have_same_root(current, p)) {
68572 + ret = 1;
68573 + goto out;
68574 + }
68575 + } while_each_pid_task(pid, type, p);
68576 +out:
68577 + read_unlock(&tasklist_lock);
68578 + return ret;
68579 +#endif
68580 + return 0;
68581 +}
68582 +
68583 +int
68584 +gr_pid_is_chrooted(struct task_struct *p)
68585 +{
68586 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68587 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68588 + return 0;
68589 +
68590 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68591 + !have_same_root(current, p)) {
68592 + return 1;
68593 + }
68594 +#endif
68595 + return 0;
68596 +}
68597 +
68598 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68599 +
68600 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68601 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68602 +{
68603 + struct path path, currentroot;
68604 + int ret = 0;
68605 +
68606 + path.dentry = (struct dentry *)u_dentry;
68607 + path.mnt = (struct vfsmount *)u_mnt;
68608 + get_fs_root(current->fs, &currentroot);
68609 + if (path_is_under(&path, &currentroot))
68610 + ret = 1;
68611 + path_put(&currentroot);
68612 +
68613 + return ret;
68614 +}
68615 +#endif
68616 +
68617 +int
68618 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68619 +{
68620 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68621 + if (!grsec_enable_chroot_fchdir)
68622 + return 1;
68623 +
68624 + if (!proc_is_chrooted(current))
68625 + return 1;
68626 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68627 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68628 + return 0;
68629 + }
68630 +#endif
68631 + return 1;
68632 +}
68633 +
68634 +int
68635 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68636 + const time_t shm_createtime)
68637 +{
68638 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68639 + struct task_struct *p;
68640 + time_t starttime;
68641 +
68642 + if (unlikely(!grsec_enable_chroot_shmat))
68643 + return 1;
68644 +
68645 + if (likely(!proc_is_chrooted(current)))
68646 + return 1;
68647 +
68648 + rcu_read_lock();
68649 + read_lock(&tasklist_lock);
68650 +
68651 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68652 + starttime = p->start_time.tv_sec;
68653 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68654 + if (have_same_root(current, p)) {
68655 + goto allow;
68656 + } else {
68657 + read_unlock(&tasklist_lock);
68658 + rcu_read_unlock();
68659 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68660 + return 0;
68661 + }
68662 + }
68663 + /* creator exited, pid reuse, fall through to next check */
68664 + }
68665 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68666 + if (unlikely(!have_same_root(current, p))) {
68667 + read_unlock(&tasklist_lock);
68668 + rcu_read_unlock();
68669 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68670 + return 0;
68671 + }
68672 + }
68673 +
68674 +allow:
68675 + read_unlock(&tasklist_lock);
68676 + rcu_read_unlock();
68677 +#endif
68678 + return 1;
68679 +}
68680 +
68681 +void
68682 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68683 +{
68684 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68685 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68686 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68687 +#endif
68688 + return;
68689 +}
68690 +
68691 +int
68692 +gr_handle_chroot_mknod(const struct dentry *dentry,
68693 + const struct vfsmount *mnt, const int mode)
68694 +{
68695 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68696 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68697 + proc_is_chrooted(current)) {
68698 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68699 + return -EPERM;
68700 + }
68701 +#endif
68702 + return 0;
68703 +}
68704 +
68705 +int
68706 +gr_handle_chroot_mount(const struct dentry *dentry,
68707 + const struct vfsmount *mnt, const char *dev_name)
68708 +{
68709 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68710 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68711 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68712 + return -EPERM;
68713 + }
68714 +#endif
68715 + return 0;
68716 +}
68717 +
68718 +int
68719 +gr_handle_chroot_pivot(void)
68720 +{
68721 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68722 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68723 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68724 + return -EPERM;
68725 + }
68726 +#endif
68727 + return 0;
68728 +}
68729 +
68730 +int
68731 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68732 +{
68733 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68734 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68735 + !gr_is_outside_chroot(dentry, mnt)) {
68736 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68737 + return -EPERM;
68738 + }
68739 +#endif
68740 + return 0;
68741 +}
68742 +
68743 +extern const char *captab_log[];
68744 +extern int captab_log_entries;
68745 +
68746 +int
68747 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68748 +{
68749 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68750 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68751 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68752 + if (cap_raised(chroot_caps, cap)) {
68753 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68754 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68755 + }
68756 + return 0;
68757 + }
68758 + }
68759 +#endif
68760 + return 1;
68761 +}
68762 +
68763 +int
68764 +gr_chroot_is_capable(const int cap)
68765 +{
68766 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68767 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68768 +#endif
68769 + return 1;
68770 +}
68771 +
68772 +int
68773 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68774 +{
68775 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68776 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68777 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68778 + if (cap_raised(chroot_caps, cap)) {
68779 + return 0;
68780 + }
68781 + }
68782 +#endif
68783 + return 1;
68784 +}
68785 +
68786 +int
68787 +gr_chroot_is_capable_nolog(const int cap)
68788 +{
68789 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68790 + return gr_task_chroot_is_capable_nolog(current, cap);
68791 +#endif
68792 + return 1;
68793 +}
68794 +
68795 +int
68796 +gr_handle_chroot_sysctl(const int op)
68797 +{
68798 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68799 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68800 + proc_is_chrooted(current))
68801 + return -EACCES;
68802 +#endif
68803 + return 0;
68804 +}
68805 +
68806 +void
68807 +gr_handle_chroot_chdir(const struct path *path)
68808 +{
68809 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68810 + if (grsec_enable_chroot_chdir)
68811 + set_fs_pwd(current->fs, path);
68812 +#endif
68813 + return;
68814 +}
68815 +
68816 +int
68817 +gr_handle_chroot_chmod(const struct dentry *dentry,
68818 + const struct vfsmount *mnt, const int mode)
68819 +{
68820 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68821 + /* allow chmod +s on directories, but not files */
68822 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68823 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68824 + proc_is_chrooted(current)) {
68825 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68826 + return -EPERM;
68827 + }
68828 +#endif
68829 + return 0;
68830 +}
68831 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68832 new file mode 100644
68833 index 0000000..ce65ceb
68834 --- /dev/null
68835 +++ b/grsecurity/grsec_disabled.c
68836 @@ -0,0 +1,434 @@
68837 +#include <linux/kernel.h>
68838 +#include <linux/module.h>
68839 +#include <linux/sched.h>
68840 +#include <linux/file.h>
68841 +#include <linux/fs.h>
68842 +#include <linux/kdev_t.h>
68843 +#include <linux/net.h>
68844 +#include <linux/in.h>
68845 +#include <linux/ip.h>
68846 +#include <linux/skbuff.h>
68847 +#include <linux/sysctl.h>
68848 +
68849 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68850 +void
68851 +pax_set_initial_flags(struct linux_binprm *bprm)
68852 +{
68853 + return;
68854 +}
68855 +#endif
68856 +
68857 +#ifdef CONFIG_SYSCTL
68858 +__u32
68859 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68860 +{
68861 + return 0;
68862 +}
68863 +#endif
68864 +
68865 +#ifdef CONFIG_TASKSTATS
68866 +int gr_is_taskstats_denied(int pid)
68867 +{
68868 + return 0;
68869 +}
68870 +#endif
68871 +
68872 +int
68873 +gr_acl_is_enabled(void)
68874 +{
68875 + return 0;
68876 +}
68877 +
68878 +void
68879 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68880 +{
68881 + return;
68882 +}
68883 +
68884 +int
68885 +gr_handle_rawio(const struct inode *inode)
68886 +{
68887 + return 0;
68888 +}
68889 +
68890 +void
68891 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68892 +{
68893 + return;
68894 +}
68895 +
68896 +int
68897 +gr_handle_ptrace(struct task_struct *task, const long request)
68898 +{
68899 + return 0;
68900 +}
68901 +
68902 +int
68903 +gr_handle_proc_ptrace(struct task_struct *task)
68904 +{
68905 + return 0;
68906 +}
68907 +
68908 +int
68909 +gr_set_acls(const int type)
68910 +{
68911 + return 0;
68912 +}
68913 +
68914 +int
68915 +gr_check_hidden_task(const struct task_struct *tsk)
68916 +{
68917 + return 0;
68918 +}
68919 +
68920 +int
68921 +gr_check_protected_task(const struct task_struct *task)
68922 +{
68923 + return 0;
68924 +}
68925 +
68926 +int
68927 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68928 +{
68929 + return 0;
68930 +}
68931 +
68932 +void
68933 +gr_copy_label(struct task_struct *tsk)
68934 +{
68935 + return;
68936 +}
68937 +
68938 +void
68939 +gr_set_pax_flags(struct task_struct *task)
68940 +{
68941 + return;
68942 +}
68943 +
68944 +int
68945 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68946 + const int unsafe_share)
68947 +{
68948 + return 0;
68949 +}
68950 +
68951 +void
68952 +gr_handle_delete(const ino_t ino, const dev_t dev)
68953 +{
68954 + return;
68955 +}
68956 +
68957 +void
68958 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68959 +{
68960 + return;
68961 +}
68962 +
68963 +void
68964 +gr_handle_crash(struct task_struct *task, const int sig)
68965 +{
68966 + return;
68967 +}
68968 +
68969 +int
68970 +gr_check_crash_exec(const struct file *filp)
68971 +{
68972 + return 0;
68973 +}
68974 +
68975 +int
68976 +gr_check_crash_uid(const kuid_t uid)
68977 +{
68978 + return 0;
68979 +}
68980 +
68981 +void
68982 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68983 + struct dentry *old_dentry,
68984 + struct dentry *new_dentry,
68985 + struct vfsmount *mnt, const __u8 replace)
68986 +{
68987 + return;
68988 +}
68989 +
68990 +int
68991 +gr_search_socket(const int family, const int type, const int protocol)
68992 +{
68993 + return 1;
68994 +}
68995 +
68996 +int
68997 +gr_search_connectbind(const int mode, const struct socket *sock,
68998 + const struct sockaddr_in *addr)
68999 +{
69000 + return 0;
69001 +}
69002 +
69003 +void
69004 +gr_handle_alertkill(struct task_struct *task)
69005 +{
69006 + return;
69007 +}
69008 +
69009 +__u32
69010 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69011 +{
69012 + return 1;
69013 +}
69014 +
69015 +__u32
69016 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69017 + const struct vfsmount * mnt)
69018 +{
69019 + return 1;
69020 +}
69021 +
69022 +__u32
69023 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69024 + int acc_mode)
69025 +{
69026 + return 1;
69027 +}
69028 +
69029 +__u32
69030 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69031 +{
69032 + return 1;
69033 +}
69034 +
69035 +__u32
69036 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69037 +{
69038 + return 1;
69039 +}
69040 +
69041 +int
69042 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69043 + unsigned int *vm_flags)
69044 +{
69045 + return 1;
69046 +}
69047 +
69048 +__u32
69049 +gr_acl_handle_truncate(const struct dentry * dentry,
69050 + const struct vfsmount * mnt)
69051 +{
69052 + return 1;
69053 +}
69054 +
69055 +__u32
69056 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69057 +{
69058 + return 1;
69059 +}
69060 +
69061 +__u32
69062 +gr_acl_handle_access(const struct dentry * dentry,
69063 + const struct vfsmount * mnt, const int fmode)
69064 +{
69065 + return 1;
69066 +}
69067 +
69068 +__u32
69069 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69070 + umode_t *mode)
69071 +{
69072 + return 1;
69073 +}
69074 +
69075 +__u32
69076 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69077 +{
69078 + return 1;
69079 +}
69080 +
69081 +__u32
69082 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69083 +{
69084 + return 1;
69085 +}
69086 +
69087 +void
69088 +grsecurity_init(void)
69089 +{
69090 + return;
69091 +}
69092 +
69093 +umode_t gr_acl_umask(void)
69094 +{
69095 + return 0;
69096 +}
69097 +
69098 +__u32
69099 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69100 + const struct dentry * parent_dentry,
69101 + const struct vfsmount * parent_mnt,
69102 + const int mode)
69103 +{
69104 + return 1;
69105 +}
69106 +
69107 +__u32
69108 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69109 + const struct dentry * parent_dentry,
69110 + const struct vfsmount * parent_mnt)
69111 +{
69112 + return 1;
69113 +}
69114 +
69115 +__u32
69116 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69117 + const struct dentry * parent_dentry,
69118 + const struct vfsmount * parent_mnt, const struct filename *from)
69119 +{
69120 + return 1;
69121 +}
69122 +
69123 +__u32
69124 +gr_acl_handle_link(const struct dentry * new_dentry,
69125 + const struct dentry * parent_dentry,
69126 + const struct vfsmount * parent_mnt,
69127 + const struct dentry * old_dentry,
69128 + const struct vfsmount * old_mnt, const struct filename *to)
69129 +{
69130 + return 1;
69131 +}
69132 +
69133 +int
69134 +gr_acl_handle_rename(const struct dentry *new_dentry,
69135 + const struct dentry *parent_dentry,
69136 + const struct vfsmount *parent_mnt,
69137 + const struct dentry *old_dentry,
69138 + const struct inode *old_parent_inode,
69139 + const struct vfsmount *old_mnt, const struct filename *newname)
69140 +{
69141 + return 0;
69142 +}
69143 +
69144 +int
69145 +gr_acl_handle_filldir(const struct file *file, const char *name,
69146 + const int namelen, const ino_t ino)
69147 +{
69148 + return 1;
69149 +}
69150 +
69151 +int
69152 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69153 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69154 +{
69155 + return 1;
69156 +}
69157 +
69158 +int
69159 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69160 +{
69161 + return 0;
69162 +}
69163 +
69164 +int
69165 +gr_search_accept(const struct socket *sock)
69166 +{
69167 + return 0;
69168 +}
69169 +
69170 +int
69171 +gr_search_listen(const struct socket *sock)
69172 +{
69173 + return 0;
69174 +}
69175 +
69176 +int
69177 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69178 +{
69179 + return 0;
69180 +}
69181 +
69182 +__u32
69183 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69184 +{
69185 + return 1;
69186 +}
69187 +
69188 +__u32
69189 +gr_acl_handle_creat(const struct dentry * dentry,
69190 + const struct dentry * p_dentry,
69191 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69192 + const int imode)
69193 +{
69194 + return 1;
69195 +}
69196 +
69197 +void
69198 +gr_acl_handle_exit(void)
69199 +{
69200 + return;
69201 +}
69202 +
69203 +int
69204 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69205 +{
69206 + return 1;
69207 +}
69208 +
69209 +void
69210 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69211 +{
69212 + return;
69213 +}
69214 +
69215 +int
69216 +gr_acl_handle_procpidmem(const struct task_struct *task)
69217 +{
69218 + return 0;
69219 +}
69220 +
69221 +int
69222 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69223 +{
69224 + return 0;
69225 +}
69226 +
69227 +int
69228 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69229 +{
69230 + return 0;
69231 +}
69232 +
69233 +void
69234 +gr_set_kernel_label(struct task_struct *task)
69235 +{
69236 + return;
69237 +}
69238 +
69239 +int
69240 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69241 +{
69242 + return 0;
69243 +}
69244 +
69245 +int
69246 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69247 +{
69248 + return 0;
69249 +}
69250 +
69251 +int gr_acl_enable_at_secure(void)
69252 +{
69253 + return 0;
69254 +}
69255 +
69256 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69257 +{
69258 + return dentry->d_sb->s_dev;
69259 +}
69260 +
69261 +void gr_put_exec_file(struct task_struct *task)
69262 +{
69263 + return;
69264 +}
69265 +
69266 +EXPORT_SYMBOL(gr_set_kernel_label);
69267 +#ifdef CONFIG_SECURITY
69268 +EXPORT_SYMBOL(gr_check_user_change);
69269 +EXPORT_SYMBOL(gr_check_group_change);
69270 +#endif
69271 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69272 new file mode 100644
69273 index 0000000..387032b
69274 --- /dev/null
69275 +++ b/grsecurity/grsec_exec.c
69276 @@ -0,0 +1,187 @@
69277 +#include <linux/kernel.h>
69278 +#include <linux/sched.h>
69279 +#include <linux/file.h>
69280 +#include <linux/binfmts.h>
69281 +#include <linux/fs.h>
69282 +#include <linux/types.h>
69283 +#include <linux/grdefs.h>
69284 +#include <linux/grsecurity.h>
69285 +#include <linux/grinternal.h>
69286 +#include <linux/capability.h>
69287 +#include <linux/module.h>
69288 +#include <linux/compat.h>
69289 +
69290 +#include <asm/uaccess.h>
69291 +
69292 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69293 +static char gr_exec_arg_buf[132];
69294 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69295 +#endif
69296 +
69297 +struct user_arg_ptr {
69298 +#ifdef CONFIG_COMPAT
69299 + bool is_compat;
69300 +#endif
69301 + union {
69302 + const char __user *const __user *native;
69303 +#ifdef CONFIG_COMPAT
69304 + const compat_uptr_t __user *compat;
69305 +#endif
69306 + } ptr;
69307 +};
69308 +
69309 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69310 +
69311 +void
69312 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69313 +{
69314 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69315 + char *grarg = gr_exec_arg_buf;
69316 + unsigned int i, x, execlen = 0;
69317 + char c;
69318 +
69319 + if (!((grsec_enable_execlog && grsec_enable_group &&
69320 + in_group_p(grsec_audit_gid))
69321 + || (grsec_enable_execlog && !grsec_enable_group)))
69322 + return;
69323 +
69324 + mutex_lock(&gr_exec_arg_mutex);
69325 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69326 +
69327 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69328 + const char __user *p;
69329 + unsigned int len;
69330 +
69331 + p = get_user_arg_ptr(argv, i);
69332 + if (IS_ERR(p))
69333 + goto log;
69334 +
69335 + len = strnlen_user(p, 128 - execlen);
69336 + if (len > 128 - execlen)
69337 + len = 128 - execlen;
69338 + else if (len > 0)
69339 + len--;
69340 + if (copy_from_user(grarg + execlen, p, len))
69341 + goto log;
69342 +
69343 + /* rewrite unprintable characters */
69344 + for (x = 0; x < len; x++) {
69345 + c = *(grarg + execlen + x);
69346 + if (c < 32 || c > 126)
69347 + *(grarg + execlen + x) = ' ';
69348 + }
69349 +
69350 + execlen += len;
69351 + *(grarg + execlen) = ' ';
69352 + *(grarg + execlen + 1) = '\0';
69353 + execlen++;
69354 + }
69355 +
69356 + log:
69357 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69358 + bprm->file->f_path.mnt, grarg);
69359 + mutex_unlock(&gr_exec_arg_mutex);
69360 +#endif
69361 + return;
69362 +}
69363 +
69364 +#ifdef CONFIG_GRKERNSEC
69365 +extern int gr_acl_is_capable(const int cap);
69366 +extern int gr_acl_is_capable_nolog(const int cap);
69367 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69368 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69369 +extern int gr_chroot_is_capable(const int cap);
69370 +extern int gr_chroot_is_capable_nolog(const int cap);
69371 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69372 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69373 +#endif
69374 +
69375 +const char *captab_log[] = {
69376 + "CAP_CHOWN",
69377 + "CAP_DAC_OVERRIDE",
69378 + "CAP_DAC_READ_SEARCH",
69379 + "CAP_FOWNER",
69380 + "CAP_FSETID",
69381 + "CAP_KILL",
69382 + "CAP_SETGID",
69383 + "CAP_SETUID",
69384 + "CAP_SETPCAP",
69385 + "CAP_LINUX_IMMUTABLE",
69386 + "CAP_NET_BIND_SERVICE",
69387 + "CAP_NET_BROADCAST",
69388 + "CAP_NET_ADMIN",
69389 + "CAP_NET_RAW",
69390 + "CAP_IPC_LOCK",
69391 + "CAP_IPC_OWNER",
69392 + "CAP_SYS_MODULE",
69393 + "CAP_SYS_RAWIO",
69394 + "CAP_SYS_CHROOT",
69395 + "CAP_SYS_PTRACE",
69396 + "CAP_SYS_PACCT",
69397 + "CAP_SYS_ADMIN",
69398 + "CAP_SYS_BOOT",
69399 + "CAP_SYS_NICE",
69400 + "CAP_SYS_RESOURCE",
69401 + "CAP_SYS_TIME",
69402 + "CAP_SYS_TTY_CONFIG",
69403 + "CAP_MKNOD",
69404 + "CAP_LEASE",
69405 + "CAP_AUDIT_WRITE",
69406 + "CAP_AUDIT_CONTROL",
69407 + "CAP_SETFCAP",
69408 + "CAP_MAC_OVERRIDE",
69409 + "CAP_MAC_ADMIN",
69410 + "CAP_SYSLOG",
69411 + "CAP_WAKE_ALARM"
69412 +};
69413 +
69414 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69415 +
69416 +int gr_is_capable(const int cap)
69417 +{
69418 +#ifdef CONFIG_GRKERNSEC
69419 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69420 + return 1;
69421 + return 0;
69422 +#else
69423 + return 1;
69424 +#endif
69425 +}
69426 +
69427 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69428 +{
69429 +#ifdef CONFIG_GRKERNSEC
69430 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69431 + return 1;
69432 + return 0;
69433 +#else
69434 + return 1;
69435 +#endif
69436 +}
69437 +
69438 +int gr_is_capable_nolog(const int cap)
69439 +{
69440 +#ifdef CONFIG_GRKERNSEC
69441 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69442 + return 1;
69443 + return 0;
69444 +#else
69445 + return 1;
69446 +#endif
69447 +}
69448 +
69449 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69450 +{
69451 +#ifdef CONFIG_GRKERNSEC
69452 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69453 + return 1;
69454 + return 0;
69455 +#else
69456 + return 1;
69457 +#endif
69458 +}
69459 +
69460 +EXPORT_SYMBOL(gr_is_capable);
69461 +EXPORT_SYMBOL(gr_is_capable_nolog);
69462 +EXPORT_SYMBOL(gr_task_is_capable);
69463 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69464 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69465 new file mode 100644
69466 index 0000000..06cc6ea
69467 --- /dev/null
69468 +++ b/grsecurity/grsec_fifo.c
69469 @@ -0,0 +1,24 @@
69470 +#include <linux/kernel.h>
69471 +#include <linux/sched.h>
69472 +#include <linux/fs.h>
69473 +#include <linux/file.h>
69474 +#include <linux/grinternal.h>
69475 +
69476 +int
69477 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69478 + const struct dentry *dir, const int flag, const int acc_mode)
69479 +{
69480 +#ifdef CONFIG_GRKERNSEC_FIFO
69481 + const struct cred *cred = current_cred();
69482 +
69483 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69484 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69485 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69486 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69487 + if (!inode_permission(dentry->d_inode, acc_mode))
69488 + 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));
69489 + return -EACCES;
69490 + }
69491 +#endif
69492 + return 0;
69493 +}
69494 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69495 new file mode 100644
69496 index 0000000..8ca18bf
69497 --- /dev/null
69498 +++ b/grsecurity/grsec_fork.c
69499 @@ -0,0 +1,23 @@
69500 +#include <linux/kernel.h>
69501 +#include <linux/sched.h>
69502 +#include <linux/grsecurity.h>
69503 +#include <linux/grinternal.h>
69504 +#include <linux/errno.h>
69505 +
69506 +void
69507 +gr_log_forkfail(const int retval)
69508 +{
69509 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69510 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69511 + switch (retval) {
69512 + case -EAGAIN:
69513 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69514 + break;
69515 + case -ENOMEM:
69516 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69517 + break;
69518 + }
69519 + }
69520 +#endif
69521 + return;
69522 +}
69523 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69524 new file mode 100644
69525 index 0000000..99a0cb9
69526 --- /dev/null
69527 +++ b/grsecurity/grsec_init.c
69528 @@ -0,0 +1,283 @@
69529 +#include <linux/kernel.h>
69530 +#include <linux/sched.h>
69531 +#include <linux/mm.h>
69532 +#include <linux/gracl.h>
69533 +#include <linux/slab.h>
69534 +#include <linux/vmalloc.h>
69535 +#include <linux/percpu.h>
69536 +#include <linux/module.h>
69537 +
69538 +int grsec_enable_ptrace_readexec;
69539 +int grsec_enable_setxid;
69540 +int grsec_enable_symlinkown;
69541 +kgid_t grsec_symlinkown_gid;
69542 +int grsec_enable_brute;
69543 +int grsec_enable_link;
69544 +int grsec_enable_dmesg;
69545 +int grsec_enable_harden_ptrace;
69546 +int grsec_enable_fifo;
69547 +int grsec_enable_execlog;
69548 +int grsec_enable_signal;
69549 +int grsec_enable_forkfail;
69550 +int grsec_enable_audit_ptrace;
69551 +int grsec_enable_time;
69552 +int grsec_enable_group;
69553 +kgid_t grsec_audit_gid;
69554 +int grsec_enable_chdir;
69555 +int grsec_enable_mount;
69556 +int grsec_enable_rofs;
69557 +int grsec_deny_new_usb;
69558 +int grsec_enable_chroot_findtask;
69559 +int grsec_enable_chroot_mount;
69560 +int grsec_enable_chroot_shmat;
69561 +int grsec_enable_chroot_fchdir;
69562 +int grsec_enable_chroot_double;
69563 +int grsec_enable_chroot_pivot;
69564 +int grsec_enable_chroot_chdir;
69565 +int grsec_enable_chroot_chmod;
69566 +int grsec_enable_chroot_mknod;
69567 +int grsec_enable_chroot_nice;
69568 +int grsec_enable_chroot_execlog;
69569 +int grsec_enable_chroot_caps;
69570 +int grsec_enable_chroot_sysctl;
69571 +int grsec_enable_chroot_unix;
69572 +int grsec_enable_tpe;
69573 +kgid_t grsec_tpe_gid;
69574 +int grsec_enable_blackhole;
69575 +#ifdef CONFIG_IPV6_MODULE
69576 +EXPORT_SYMBOL(grsec_enable_blackhole);
69577 +#endif
69578 +int grsec_lastack_retries;
69579 +int grsec_enable_tpe_all;
69580 +int grsec_enable_tpe_invert;
69581 +int grsec_enable_socket_all;
69582 +kgid_t grsec_socket_all_gid;
69583 +int grsec_enable_socket_client;
69584 +kgid_t grsec_socket_client_gid;
69585 +int grsec_enable_socket_server;
69586 +kgid_t grsec_socket_server_gid;
69587 +int grsec_resource_logging;
69588 +int grsec_disable_privio;
69589 +int grsec_enable_log_rwxmaps;
69590 +int grsec_lock;
69591 +
69592 +DEFINE_SPINLOCK(grsec_alert_lock);
69593 +unsigned long grsec_alert_wtime = 0;
69594 +unsigned long grsec_alert_fyet = 0;
69595 +
69596 +DEFINE_SPINLOCK(grsec_audit_lock);
69597 +
69598 +DEFINE_RWLOCK(grsec_exec_file_lock);
69599 +
69600 +char *gr_shared_page[4];
69601 +
69602 +char *gr_alert_log_fmt;
69603 +char *gr_audit_log_fmt;
69604 +char *gr_alert_log_buf;
69605 +char *gr_audit_log_buf;
69606 +
69607 +extern struct gr_arg *gr_usermode;
69608 +extern unsigned char *gr_system_salt;
69609 +extern unsigned char *gr_system_sum;
69610 +
69611 +void __init
69612 +grsecurity_init(void)
69613 +{
69614 + int j;
69615 + /* create the per-cpu shared pages */
69616 +
69617 +#ifdef CONFIG_X86
69618 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69619 +#endif
69620 +
69621 + for (j = 0; j < 4; j++) {
69622 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69623 + if (gr_shared_page[j] == NULL) {
69624 + panic("Unable to allocate grsecurity shared page");
69625 + return;
69626 + }
69627 + }
69628 +
69629 + /* allocate log buffers */
69630 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69631 + if (!gr_alert_log_fmt) {
69632 + panic("Unable to allocate grsecurity alert log format buffer");
69633 + return;
69634 + }
69635 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69636 + if (!gr_audit_log_fmt) {
69637 + panic("Unable to allocate grsecurity audit log format buffer");
69638 + return;
69639 + }
69640 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69641 + if (!gr_alert_log_buf) {
69642 + panic("Unable to allocate grsecurity alert log buffer");
69643 + return;
69644 + }
69645 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69646 + if (!gr_audit_log_buf) {
69647 + panic("Unable to allocate grsecurity audit log buffer");
69648 + return;
69649 + }
69650 +
69651 + /* allocate memory for authentication structure */
69652 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69653 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69654 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69655 +
69656 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69657 + panic("Unable to allocate grsecurity authentication structure");
69658 + return;
69659 + }
69660 +
69661 +
69662 +#ifdef CONFIG_GRKERNSEC_IO
69663 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69664 + grsec_disable_privio = 1;
69665 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69666 + grsec_disable_privio = 1;
69667 +#else
69668 + grsec_disable_privio = 0;
69669 +#endif
69670 +#endif
69671 +
69672 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69673 + /* for backward compatibility, tpe_invert always defaults to on if
69674 + enabled in the kernel
69675 + */
69676 + grsec_enable_tpe_invert = 1;
69677 +#endif
69678 +
69679 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69680 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69681 + grsec_lock = 1;
69682 +#endif
69683 +
69684 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69685 + grsec_enable_log_rwxmaps = 1;
69686 +#endif
69687 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69688 + grsec_enable_group = 1;
69689 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69690 +#endif
69691 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69692 + grsec_enable_ptrace_readexec = 1;
69693 +#endif
69694 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69695 + grsec_enable_chdir = 1;
69696 +#endif
69697 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69698 + grsec_enable_harden_ptrace = 1;
69699 +#endif
69700 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69701 + grsec_enable_mount = 1;
69702 +#endif
69703 +#ifdef CONFIG_GRKERNSEC_LINK
69704 + grsec_enable_link = 1;
69705 +#endif
69706 +#ifdef CONFIG_GRKERNSEC_BRUTE
69707 + grsec_enable_brute = 1;
69708 +#endif
69709 +#ifdef CONFIG_GRKERNSEC_DMESG
69710 + grsec_enable_dmesg = 1;
69711 +#endif
69712 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69713 + grsec_enable_blackhole = 1;
69714 + grsec_lastack_retries = 4;
69715 +#endif
69716 +#ifdef CONFIG_GRKERNSEC_FIFO
69717 + grsec_enable_fifo = 1;
69718 +#endif
69719 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69720 + grsec_enable_execlog = 1;
69721 +#endif
69722 +#ifdef CONFIG_GRKERNSEC_SETXID
69723 + grsec_enable_setxid = 1;
69724 +#endif
69725 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69726 + grsec_enable_signal = 1;
69727 +#endif
69728 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69729 + grsec_enable_forkfail = 1;
69730 +#endif
69731 +#ifdef CONFIG_GRKERNSEC_TIME
69732 + grsec_enable_time = 1;
69733 +#endif
69734 +#ifdef CONFIG_GRKERNSEC_RESLOG
69735 + grsec_resource_logging = 1;
69736 +#endif
69737 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69738 + grsec_enable_chroot_findtask = 1;
69739 +#endif
69740 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69741 + grsec_enable_chroot_unix = 1;
69742 +#endif
69743 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69744 + grsec_enable_chroot_mount = 1;
69745 +#endif
69746 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69747 + grsec_enable_chroot_fchdir = 1;
69748 +#endif
69749 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69750 + grsec_enable_chroot_shmat = 1;
69751 +#endif
69752 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69753 + grsec_enable_audit_ptrace = 1;
69754 +#endif
69755 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69756 + grsec_enable_chroot_double = 1;
69757 +#endif
69758 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69759 + grsec_enable_chroot_pivot = 1;
69760 +#endif
69761 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69762 + grsec_enable_chroot_chdir = 1;
69763 +#endif
69764 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69765 + grsec_enable_chroot_chmod = 1;
69766 +#endif
69767 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69768 + grsec_enable_chroot_mknod = 1;
69769 +#endif
69770 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69771 + grsec_enable_chroot_nice = 1;
69772 +#endif
69773 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69774 + grsec_enable_chroot_execlog = 1;
69775 +#endif
69776 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69777 + grsec_enable_chroot_caps = 1;
69778 +#endif
69779 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69780 + grsec_enable_chroot_sysctl = 1;
69781 +#endif
69782 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69783 + grsec_enable_symlinkown = 1;
69784 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69785 +#endif
69786 +#ifdef CONFIG_GRKERNSEC_TPE
69787 + grsec_enable_tpe = 1;
69788 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69789 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69790 + grsec_enable_tpe_all = 1;
69791 +#endif
69792 +#endif
69793 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69794 + grsec_enable_socket_all = 1;
69795 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69796 +#endif
69797 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69798 + grsec_enable_socket_client = 1;
69799 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69800 +#endif
69801 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69802 + grsec_enable_socket_server = 1;
69803 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69804 +#endif
69805 +#endif
69806 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69807 + grsec_deny_new_usb = 1;
69808 +#endif
69809 +
69810 + return;
69811 +}
69812 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69813 new file mode 100644
69814 index 0000000..5e05e20
69815 --- /dev/null
69816 +++ b/grsecurity/grsec_link.c
69817 @@ -0,0 +1,58 @@
69818 +#include <linux/kernel.h>
69819 +#include <linux/sched.h>
69820 +#include <linux/fs.h>
69821 +#include <linux/file.h>
69822 +#include <linux/grinternal.h>
69823 +
69824 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69825 +{
69826 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69827 + const struct inode *link_inode = link->dentry->d_inode;
69828 +
69829 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69830 + /* ignore root-owned links, e.g. /proc/self */
69831 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69832 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69833 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69834 + return 1;
69835 + }
69836 +#endif
69837 + return 0;
69838 +}
69839 +
69840 +int
69841 +gr_handle_follow_link(const struct inode *parent,
69842 + const struct inode *inode,
69843 + const struct dentry *dentry, const struct vfsmount *mnt)
69844 +{
69845 +#ifdef CONFIG_GRKERNSEC_LINK
69846 + const struct cred *cred = current_cred();
69847 +
69848 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69849 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69850 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69851 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69852 + return -EACCES;
69853 + }
69854 +#endif
69855 + return 0;
69856 +}
69857 +
69858 +int
69859 +gr_handle_hardlink(const struct dentry *dentry,
69860 + const struct vfsmount *mnt,
69861 + struct inode *inode, const int mode, const struct filename *to)
69862 +{
69863 +#ifdef CONFIG_GRKERNSEC_LINK
69864 + const struct cred *cred = current_cred();
69865 +
69866 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69867 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69868 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69869 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69870 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69871 + return -EPERM;
69872 + }
69873 +#endif
69874 + return 0;
69875 +}
69876 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69877 new file mode 100644
69878 index 0000000..dbe0a6b
69879 --- /dev/null
69880 +++ b/grsecurity/grsec_log.c
69881 @@ -0,0 +1,341 @@
69882 +#include <linux/kernel.h>
69883 +#include <linux/sched.h>
69884 +#include <linux/file.h>
69885 +#include <linux/tty.h>
69886 +#include <linux/fs.h>
69887 +#include <linux/mm.h>
69888 +#include <linux/grinternal.h>
69889 +
69890 +#ifdef CONFIG_TREE_PREEMPT_RCU
69891 +#define DISABLE_PREEMPT() preempt_disable()
69892 +#define ENABLE_PREEMPT() preempt_enable()
69893 +#else
69894 +#define DISABLE_PREEMPT()
69895 +#define ENABLE_PREEMPT()
69896 +#endif
69897 +
69898 +#define BEGIN_LOCKS(x) \
69899 + DISABLE_PREEMPT(); \
69900 + rcu_read_lock(); \
69901 + read_lock(&tasklist_lock); \
69902 + read_lock(&grsec_exec_file_lock); \
69903 + if (x != GR_DO_AUDIT) \
69904 + spin_lock(&grsec_alert_lock); \
69905 + else \
69906 + spin_lock(&grsec_audit_lock)
69907 +
69908 +#define END_LOCKS(x) \
69909 + if (x != GR_DO_AUDIT) \
69910 + spin_unlock(&grsec_alert_lock); \
69911 + else \
69912 + spin_unlock(&grsec_audit_lock); \
69913 + read_unlock(&grsec_exec_file_lock); \
69914 + read_unlock(&tasklist_lock); \
69915 + rcu_read_unlock(); \
69916 + ENABLE_PREEMPT(); \
69917 + if (x == GR_DONT_AUDIT) \
69918 + gr_handle_alertkill(current)
69919 +
69920 +enum {
69921 + FLOODING,
69922 + NO_FLOODING
69923 +};
69924 +
69925 +extern char *gr_alert_log_fmt;
69926 +extern char *gr_audit_log_fmt;
69927 +extern char *gr_alert_log_buf;
69928 +extern char *gr_audit_log_buf;
69929 +
69930 +static int gr_log_start(int audit)
69931 +{
69932 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69933 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69934 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69935 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69936 + unsigned long curr_secs = get_seconds();
69937 +
69938 + if (audit == GR_DO_AUDIT)
69939 + goto set_fmt;
69940 +
69941 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69942 + grsec_alert_wtime = curr_secs;
69943 + grsec_alert_fyet = 0;
69944 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69945 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69946 + grsec_alert_fyet++;
69947 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69948 + grsec_alert_wtime = curr_secs;
69949 + grsec_alert_fyet++;
69950 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69951 + return FLOODING;
69952 + }
69953 + else return FLOODING;
69954 +
69955 +set_fmt:
69956 +#endif
69957 + memset(buf, 0, PAGE_SIZE);
69958 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69959 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69960 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69961 + } else if (current->signal->curr_ip) {
69962 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69963 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69964 + } else if (gr_acl_is_enabled()) {
69965 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69966 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69967 + } else {
69968 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69969 + strcpy(buf, fmt);
69970 + }
69971 +
69972 + return NO_FLOODING;
69973 +}
69974 +
69975 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69976 + __attribute__ ((format (printf, 2, 0)));
69977 +
69978 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69979 +{
69980 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69981 + unsigned int len = strlen(buf);
69982 +
69983 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69984 +
69985 + return;
69986 +}
69987 +
69988 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69989 + __attribute__ ((format (printf, 2, 3)));
69990 +
69991 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69992 +{
69993 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69994 + unsigned int len = strlen(buf);
69995 + va_list ap;
69996 +
69997 + va_start(ap, msg);
69998 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69999 + va_end(ap);
70000 +
70001 + return;
70002 +}
70003 +
70004 +static void gr_log_end(int audit, int append_default)
70005 +{
70006 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70007 + if (append_default) {
70008 + struct task_struct *task = current;
70009 + struct task_struct *parent = task->real_parent;
70010 + const struct cred *cred = __task_cred(task);
70011 + const struct cred *pcred = __task_cred(parent);
70012 + unsigned int len = strlen(buf);
70013 +
70014 + 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));
70015 + }
70016 +
70017 + printk("%s\n", buf);
70018 +
70019 + return;
70020 +}
70021 +
70022 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70023 +{
70024 + int logtype;
70025 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70026 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70027 + void *voidptr = NULL;
70028 + int num1 = 0, num2 = 0;
70029 + unsigned long ulong1 = 0, ulong2 = 0;
70030 + struct dentry *dentry = NULL;
70031 + struct vfsmount *mnt = NULL;
70032 + struct file *file = NULL;
70033 + struct task_struct *task = NULL;
70034 + struct vm_area_struct *vma = NULL;
70035 + const struct cred *cred, *pcred;
70036 + va_list ap;
70037 +
70038 + BEGIN_LOCKS(audit);
70039 + logtype = gr_log_start(audit);
70040 + if (logtype == FLOODING) {
70041 + END_LOCKS(audit);
70042 + return;
70043 + }
70044 + va_start(ap, argtypes);
70045 + switch (argtypes) {
70046 + case GR_TTYSNIFF:
70047 + task = va_arg(ap, struct task_struct *);
70048 + 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));
70049 + break;
70050 + case GR_SYSCTL_HIDDEN:
70051 + str1 = va_arg(ap, char *);
70052 + gr_log_middle_varargs(audit, msg, result, str1);
70053 + break;
70054 + case GR_RBAC:
70055 + dentry = va_arg(ap, struct dentry *);
70056 + mnt = va_arg(ap, struct vfsmount *);
70057 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70058 + break;
70059 + case GR_RBAC_STR:
70060 + dentry = va_arg(ap, struct dentry *);
70061 + mnt = va_arg(ap, struct vfsmount *);
70062 + str1 = va_arg(ap, char *);
70063 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70064 + break;
70065 + case GR_STR_RBAC:
70066 + str1 = va_arg(ap, char *);
70067 + dentry = va_arg(ap, struct dentry *);
70068 + mnt = va_arg(ap, struct vfsmount *);
70069 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70070 + break;
70071 + case GR_RBAC_MODE2:
70072 + dentry = va_arg(ap, struct dentry *);
70073 + mnt = va_arg(ap, struct vfsmount *);
70074 + str1 = va_arg(ap, char *);
70075 + str2 = va_arg(ap, char *);
70076 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70077 + break;
70078 + case GR_RBAC_MODE3:
70079 + dentry = va_arg(ap, struct dentry *);
70080 + mnt = va_arg(ap, struct vfsmount *);
70081 + str1 = va_arg(ap, char *);
70082 + str2 = va_arg(ap, char *);
70083 + str3 = va_arg(ap, char *);
70084 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70085 + break;
70086 + case GR_FILENAME:
70087 + dentry = va_arg(ap, struct dentry *);
70088 + mnt = va_arg(ap, struct vfsmount *);
70089 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70090 + break;
70091 + case GR_STR_FILENAME:
70092 + str1 = va_arg(ap, char *);
70093 + dentry = va_arg(ap, struct dentry *);
70094 + mnt = va_arg(ap, struct vfsmount *);
70095 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70096 + break;
70097 + case GR_FILENAME_STR:
70098 + dentry = va_arg(ap, struct dentry *);
70099 + mnt = va_arg(ap, struct vfsmount *);
70100 + str1 = va_arg(ap, char *);
70101 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70102 + break;
70103 + case GR_FILENAME_TWO_INT:
70104 + dentry = va_arg(ap, struct dentry *);
70105 + mnt = va_arg(ap, struct vfsmount *);
70106 + num1 = va_arg(ap, int);
70107 + num2 = va_arg(ap, int);
70108 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70109 + break;
70110 + case GR_FILENAME_TWO_INT_STR:
70111 + dentry = va_arg(ap, struct dentry *);
70112 + mnt = va_arg(ap, struct vfsmount *);
70113 + num1 = va_arg(ap, int);
70114 + num2 = va_arg(ap, int);
70115 + str1 = va_arg(ap, char *);
70116 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70117 + break;
70118 + case GR_TEXTREL:
70119 + file = va_arg(ap, struct file *);
70120 + ulong1 = va_arg(ap, unsigned long);
70121 + ulong2 = va_arg(ap, unsigned long);
70122 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70123 + break;
70124 + case GR_PTRACE:
70125 + task = va_arg(ap, struct task_struct *);
70126 + 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));
70127 + break;
70128 + case GR_RESOURCE:
70129 + task = va_arg(ap, struct task_struct *);
70130 + cred = __task_cred(task);
70131 + pcred = __task_cred(task->real_parent);
70132 + ulong1 = va_arg(ap, unsigned long);
70133 + str1 = va_arg(ap, char *);
70134 + ulong2 = va_arg(ap, unsigned long);
70135 + 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));
70136 + break;
70137 + case GR_CAP:
70138 + task = va_arg(ap, struct task_struct *);
70139 + cred = __task_cred(task);
70140 + pcred = __task_cred(task->real_parent);
70141 + str1 = va_arg(ap, char *);
70142 + 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));
70143 + break;
70144 + case GR_SIG:
70145 + str1 = va_arg(ap, char *);
70146 + voidptr = va_arg(ap, void *);
70147 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70148 + break;
70149 + case GR_SIG2:
70150 + task = va_arg(ap, struct task_struct *);
70151 + cred = __task_cred(task);
70152 + pcred = __task_cred(task->real_parent);
70153 + num1 = va_arg(ap, int);
70154 + 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));
70155 + break;
70156 + case GR_CRASH1:
70157 + task = va_arg(ap, struct task_struct *);
70158 + cred = __task_cred(task);
70159 + pcred = __task_cred(task->real_parent);
70160 + ulong1 = va_arg(ap, unsigned long);
70161 + 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);
70162 + break;
70163 + case GR_CRASH2:
70164 + task = va_arg(ap, struct task_struct *);
70165 + cred = __task_cred(task);
70166 + pcred = __task_cred(task->real_parent);
70167 + ulong1 = va_arg(ap, unsigned long);
70168 + 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);
70169 + break;
70170 + case GR_RWXMAP:
70171 + file = va_arg(ap, struct file *);
70172 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70173 + break;
70174 + case GR_RWXMAPVMA:
70175 + vma = va_arg(ap, struct vm_area_struct *);
70176 + if (vma->vm_file)
70177 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70178 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70179 + str1 = "<stack>";
70180 + else if (vma->vm_start <= current->mm->brk &&
70181 + vma->vm_end >= current->mm->start_brk)
70182 + str1 = "<heap>";
70183 + else
70184 + str1 = "<anonymous mapping>";
70185 + gr_log_middle_varargs(audit, msg, str1);
70186 + break;
70187 + case GR_PSACCT:
70188 + {
70189 + unsigned int wday, cday;
70190 + __u8 whr, chr;
70191 + __u8 wmin, cmin;
70192 + __u8 wsec, csec;
70193 + char cur_tty[64] = { 0 };
70194 + char parent_tty[64] = { 0 };
70195 +
70196 + task = va_arg(ap, struct task_struct *);
70197 + wday = va_arg(ap, unsigned int);
70198 + cday = va_arg(ap, unsigned int);
70199 + whr = va_arg(ap, int);
70200 + chr = va_arg(ap, int);
70201 + wmin = va_arg(ap, int);
70202 + cmin = va_arg(ap, int);
70203 + wsec = va_arg(ap, int);
70204 + csec = va_arg(ap, int);
70205 + ulong1 = va_arg(ap, unsigned long);
70206 + cred = __task_cred(task);
70207 + pcred = __task_cred(task->real_parent);
70208 +
70209 + 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));
70210 + }
70211 + break;
70212 + default:
70213 + gr_log_middle(audit, msg, ap);
70214 + }
70215 + va_end(ap);
70216 + // these don't need DEFAULTSECARGS printed on the end
70217 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70218 + gr_log_end(audit, 0);
70219 + else
70220 + gr_log_end(audit, 1);
70221 + END_LOCKS(audit);
70222 +}
70223 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70224 new file mode 100644
70225 index 0000000..f536303
70226 --- /dev/null
70227 +++ b/grsecurity/grsec_mem.c
70228 @@ -0,0 +1,40 @@
70229 +#include <linux/kernel.h>
70230 +#include <linux/sched.h>
70231 +#include <linux/mm.h>
70232 +#include <linux/mman.h>
70233 +#include <linux/grinternal.h>
70234 +
70235 +void
70236 +gr_handle_ioperm(void)
70237 +{
70238 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70239 + return;
70240 +}
70241 +
70242 +void
70243 +gr_handle_iopl(void)
70244 +{
70245 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70246 + return;
70247 +}
70248 +
70249 +void
70250 +gr_handle_mem_readwrite(u64 from, u64 to)
70251 +{
70252 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70253 + return;
70254 +}
70255 +
70256 +void
70257 +gr_handle_vm86(void)
70258 +{
70259 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70260 + return;
70261 +}
70262 +
70263 +void
70264 +gr_log_badprocpid(const char *entry)
70265 +{
70266 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70267 + return;
70268 +}
70269 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70270 new file mode 100644
70271 index 0000000..2131422
70272 --- /dev/null
70273 +++ b/grsecurity/grsec_mount.c
70274 @@ -0,0 +1,62 @@
70275 +#include <linux/kernel.h>
70276 +#include <linux/sched.h>
70277 +#include <linux/mount.h>
70278 +#include <linux/grsecurity.h>
70279 +#include <linux/grinternal.h>
70280 +
70281 +void
70282 +gr_log_remount(const char *devname, const int retval)
70283 +{
70284 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70285 + if (grsec_enable_mount && (retval >= 0))
70286 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70287 +#endif
70288 + return;
70289 +}
70290 +
70291 +void
70292 +gr_log_unmount(const char *devname, const int retval)
70293 +{
70294 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70295 + if (grsec_enable_mount && (retval >= 0))
70296 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70297 +#endif
70298 + return;
70299 +}
70300 +
70301 +void
70302 +gr_log_mount(const char *from, const char *to, const int retval)
70303 +{
70304 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70305 + if (grsec_enable_mount && (retval >= 0))
70306 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70307 +#endif
70308 + return;
70309 +}
70310 +
70311 +int
70312 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70313 +{
70314 +#ifdef CONFIG_GRKERNSEC_ROFS
70315 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70316 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70317 + return -EPERM;
70318 + } else
70319 + return 0;
70320 +#endif
70321 + return 0;
70322 +}
70323 +
70324 +int
70325 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70326 +{
70327 +#ifdef CONFIG_GRKERNSEC_ROFS
70328 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70329 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70330 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70331 + return -EPERM;
70332 + } else
70333 + return 0;
70334 +#endif
70335 + return 0;
70336 +}
70337 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70338 new file mode 100644
70339 index 0000000..6ee9d50
70340 --- /dev/null
70341 +++ b/grsecurity/grsec_pax.c
70342 @@ -0,0 +1,45 @@
70343 +#include <linux/kernel.h>
70344 +#include <linux/sched.h>
70345 +#include <linux/mm.h>
70346 +#include <linux/file.h>
70347 +#include <linux/grinternal.h>
70348 +#include <linux/grsecurity.h>
70349 +
70350 +void
70351 +gr_log_textrel(struct vm_area_struct * vma)
70352 +{
70353 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70354 + if (grsec_enable_log_rwxmaps)
70355 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70356 +#endif
70357 + return;
70358 +}
70359 +
70360 +void gr_log_ptgnustack(struct file *file)
70361 +{
70362 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70363 + if (grsec_enable_log_rwxmaps)
70364 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70365 +#endif
70366 + return;
70367 +}
70368 +
70369 +void
70370 +gr_log_rwxmmap(struct file *file)
70371 +{
70372 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70373 + if (grsec_enable_log_rwxmaps)
70374 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70375 +#endif
70376 + return;
70377 +}
70378 +
70379 +void
70380 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70381 +{
70382 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70383 + if (grsec_enable_log_rwxmaps)
70384 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70385 +#endif
70386 + return;
70387 +}
70388 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70389 new file mode 100644
70390 index 0000000..f7f29aa
70391 --- /dev/null
70392 +++ b/grsecurity/grsec_ptrace.c
70393 @@ -0,0 +1,30 @@
70394 +#include <linux/kernel.h>
70395 +#include <linux/sched.h>
70396 +#include <linux/grinternal.h>
70397 +#include <linux/security.h>
70398 +
70399 +void
70400 +gr_audit_ptrace(struct task_struct *task)
70401 +{
70402 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70403 + if (grsec_enable_audit_ptrace)
70404 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70405 +#endif
70406 + return;
70407 +}
70408 +
70409 +int
70410 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70411 +{
70412 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70413 + const struct dentry *dentry = file->f_path.dentry;
70414 + const struct vfsmount *mnt = file->f_path.mnt;
70415 +
70416 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70417 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70418 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70419 + return -EACCES;
70420 + }
70421 +#endif
70422 + return 0;
70423 +}
70424 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70425 new file mode 100644
70426 index 0000000..4e29cc7
70427 --- /dev/null
70428 +++ b/grsecurity/grsec_sig.c
70429 @@ -0,0 +1,246 @@
70430 +#include <linux/kernel.h>
70431 +#include <linux/sched.h>
70432 +#include <linux/fs.h>
70433 +#include <linux/delay.h>
70434 +#include <linux/grsecurity.h>
70435 +#include <linux/grinternal.h>
70436 +#include <linux/hardirq.h>
70437 +
70438 +char *signames[] = {
70439 + [SIGSEGV] = "Segmentation fault",
70440 + [SIGILL] = "Illegal instruction",
70441 + [SIGABRT] = "Abort",
70442 + [SIGBUS] = "Invalid alignment/Bus error"
70443 +};
70444 +
70445 +void
70446 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70447 +{
70448 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70449 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70450 + (sig == SIGABRT) || (sig == SIGBUS))) {
70451 + if (task_pid_nr(t) == task_pid_nr(current)) {
70452 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70453 + } else {
70454 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70455 + }
70456 + }
70457 +#endif
70458 + return;
70459 +}
70460 +
70461 +int
70462 +gr_handle_signal(const struct task_struct *p, const int sig)
70463 +{
70464 +#ifdef CONFIG_GRKERNSEC
70465 + /* ignore the 0 signal for protected task checks */
70466 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70467 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70468 + return -EPERM;
70469 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70470 + return -EPERM;
70471 + }
70472 +#endif
70473 + return 0;
70474 +}
70475 +
70476 +#ifdef CONFIG_GRKERNSEC
70477 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70478 +
70479 +int gr_fake_force_sig(int sig, struct task_struct *t)
70480 +{
70481 + unsigned long int flags;
70482 + int ret, blocked, ignored;
70483 + struct k_sigaction *action;
70484 +
70485 + spin_lock_irqsave(&t->sighand->siglock, flags);
70486 + action = &t->sighand->action[sig-1];
70487 + ignored = action->sa.sa_handler == SIG_IGN;
70488 + blocked = sigismember(&t->blocked, sig);
70489 + if (blocked || ignored) {
70490 + action->sa.sa_handler = SIG_DFL;
70491 + if (blocked) {
70492 + sigdelset(&t->blocked, sig);
70493 + recalc_sigpending_and_wake(t);
70494 + }
70495 + }
70496 + if (action->sa.sa_handler == SIG_DFL)
70497 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70498 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70499 +
70500 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70501 +
70502 + return ret;
70503 +}
70504 +#endif
70505 +
70506 +#ifdef CONFIG_GRKERNSEC_BRUTE
70507 +#define GR_USER_BAN_TIME (15 * 60)
70508 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70509 +
70510 +static int __get_dumpable(unsigned long mm_flags)
70511 +{
70512 + int ret;
70513 +
70514 + ret = mm_flags & MMF_DUMPABLE_MASK;
70515 + return (ret >= 2) ? 2 : ret;
70516 +}
70517 +#endif
70518 +
70519 +void gr_handle_brute_attach(unsigned long mm_flags)
70520 +{
70521 +#ifdef CONFIG_GRKERNSEC_BRUTE
70522 + struct task_struct *p = current;
70523 + kuid_t uid = GLOBAL_ROOT_UID;
70524 + int daemon = 0;
70525 +
70526 + if (!grsec_enable_brute)
70527 + return;
70528 +
70529 + rcu_read_lock();
70530 + read_lock(&tasklist_lock);
70531 + read_lock(&grsec_exec_file_lock);
70532 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70533 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70534 + p->real_parent->brute = 1;
70535 + daemon = 1;
70536 + } else {
70537 + const struct cred *cred = __task_cred(p), *cred2;
70538 + struct task_struct *tsk, *tsk2;
70539 +
70540 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70541 + struct user_struct *user;
70542 +
70543 + uid = cred->uid;
70544 +
70545 + /* this is put upon execution past expiration */
70546 + user = find_user(uid);
70547 + if (user == NULL)
70548 + goto unlock;
70549 + user->suid_banned = 1;
70550 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70551 + if (user->suid_ban_expires == ~0UL)
70552 + user->suid_ban_expires--;
70553 +
70554 + /* only kill other threads of the same binary, from the same user */
70555 + do_each_thread(tsk2, tsk) {
70556 + cred2 = __task_cred(tsk);
70557 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70558 + gr_fake_force_sig(SIGKILL, tsk);
70559 + } while_each_thread(tsk2, tsk);
70560 + }
70561 + }
70562 +unlock:
70563 + read_unlock(&grsec_exec_file_lock);
70564 + read_unlock(&tasklist_lock);
70565 + rcu_read_unlock();
70566 +
70567 + if (gr_is_global_nonroot(uid))
70568 + 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);
70569 + else if (daemon)
70570 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70571 +
70572 +#endif
70573 + return;
70574 +}
70575 +
70576 +void gr_handle_brute_check(void)
70577 +{
70578 +#ifdef CONFIG_GRKERNSEC_BRUTE
70579 + struct task_struct *p = current;
70580 +
70581 + if (unlikely(p->brute)) {
70582 + if (!grsec_enable_brute)
70583 + p->brute = 0;
70584 + else if (time_before(get_seconds(), p->brute_expires))
70585 + msleep(30 * 1000);
70586 + }
70587 +#endif
70588 + return;
70589 +}
70590 +
70591 +void gr_handle_kernel_exploit(void)
70592 +{
70593 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70594 + const struct cred *cred;
70595 + struct task_struct *tsk, *tsk2;
70596 + struct user_struct *user;
70597 + kuid_t uid;
70598 +
70599 + if (in_irq() || in_serving_softirq() || in_nmi())
70600 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70601 +
70602 + uid = current_uid();
70603 +
70604 + if (gr_is_global_root(uid))
70605 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70606 + else {
70607 + /* kill all the processes of this user, hold a reference
70608 + to their creds struct, and prevent them from creating
70609 + another process until system reset
70610 + */
70611 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70612 + GR_GLOBAL_UID(uid));
70613 + /* we intentionally leak this ref */
70614 + user = get_uid(current->cred->user);
70615 + if (user)
70616 + user->kernel_banned = 1;
70617 +
70618 + /* kill all processes of this user */
70619 + read_lock(&tasklist_lock);
70620 + do_each_thread(tsk2, tsk) {
70621 + cred = __task_cred(tsk);
70622 + if (uid_eq(cred->uid, uid))
70623 + gr_fake_force_sig(SIGKILL, tsk);
70624 + } while_each_thread(tsk2, tsk);
70625 + read_unlock(&tasklist_lock);
70626 + }
70627 +#endif
70628 +}
70629 +
70630 +#ifdef CONFIG_GRKERNSEC_BRUTE
70631 +static bool suid_ban_expired(struct user_struct *user)
70632 +{
70633 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70634 + user->suid_banned = 0;
70635 + user->suid_ban_expires = 0;
70636 + free_uid(user);
70637 + return true;
70638 + }
70639 +
70640 + return false;
70641 +}
70642 +#endif
70643 +
70644 +int gr_process_kernel_exec_ban(void)
70645 +{
70646 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70647 + if (unlikely(current->cred->user->kernel_banned))
70648 + return -EPERM;
70649 +#endif
70650 + return 0;
70651 +}
70652 +
70653 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70654 +{
70655 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70656 + if (unlikely(user->kernel_banned))
70657 + gr_fake_force_sig(SIGKILL, current);
70658 +#endif
70659 + return 0;
70660 +}
70661 +
70662 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70663 +{
70664 +#ifdef CONFIG_GRKERNSEC_BRUTE
70665 + struct user_struct *user = current->cred->user;
70666 + if (unlikely(user->suid_banned)) {
70667 + if (suid_ban_expired(user))
70668 + return 0;
70669 + /* disallow execution of suid binaries only */
70670 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70671 + return -EPERM;
70672 + }
70673 +#endif
70674 + return 0;
70675 +}
70676 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70677 new file mode 100644
70678 index 0000000..4030d57
70679 --- /dev/null
70680 +++ b/grsecurity/grsec_sock.c
70681 @@ -0,0 +1,244 @@
70682 +#include <linux/kernel.h>
70683 +#include <linux/module.h>
70684 +#include <linux/sched.h>
70685 +#include <linux/file.h>
70686 +#include <linux/net.h>
70687 +#include <linux/in.h>
70688 +#include <linux/ip.h>
70689 +#include <net/sock.h>
70690 +#include <net/inet_sock.h>
70691 +#include <linux/grsecurity.h>
70692 +#include <linux/grinternal.h>
70693 +#include <linux/gracl.h>
70694 +
70695 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70696 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70697 +
70698 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70699 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70700 +
70701 +#ifdef CONFIG_UNIX_MODULE
70702 +EXPORT_SYMBOL(gr_acl_handle_unix);
70703 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70704 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70705 +EXPORT_SYMBOL(gr_handle_create);
70706 +#endif
70707 +
70708 +#ifdef CONFIG_GRKERNSEC
70709 +#define gr_conn_table_size 32749
70710 +struct conn_table_entry {
70711 + struct conn_table_entry *next;
70712 + struct signal_struct *sig;
70713 +};
70714 +
70715 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70716 +DEFINE_SPINLOCK(gr_conn_table_lock);
70717 +
70718 +extern const char * gr_socktype_to_name(unsigned char type);
70719 +extern const char * gr_proto_to_name(unsigned char proto);
70720 +extern const char * gr_sockfamily_to_name(unsigned char family);
70721 +
70722 +static __inline__ int
70723 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70724 +{
70725 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70726 +}
70727 +
70728 +static __inline__ int
70729 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70730 + __u16 sport, __u16 dport)
70731 +{
70732 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70733 + sig->gr_sport == sport && sig->gr_dport == dport))
70734 + return 1;
70735 + else
70736 + return 0;
70737 +}
70738 +
70739 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70740 +{
70741 + struct conn_table_entry **match;
70742 + unsigned int index;
70743 +
70744 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70745 + sig->gr_sport, sig->gr_dport,
70746 + gr_conn_table_size);
70747 +
70748 + newent->sig = sig;
70749 +
70750 + match = &gr_conn_table[index];
70751 + newent->next = *match;
70752 + *match = newent;
70753 +
70754 + return;
70755 +}
70756 +
70757 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70758 +{
70759 + struct conn_table_entry *match, *last = NULL;
70760 + unsigned int index;
70761 +
70762 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70763 + sig->gr_sport, sig->gr_dport,
70764 + gr_conn_table_size);
70765 +
70766 + match = gr_conn_table[index];
70767 + while (match && !conn_match(match->sig,
70768 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70769 + sig->gr_dport)) {
70770 + last = match;
70771 + match = match->next;
70772 + }
70773 +
70774 + if (match) {
70775 + if (last)
70776 + last->next = match->next;
70777 + else
70778 + gr_conn_table[index] = NULL;
70779 + kfree(match);
70780 + }
70781 +
70782 + return;
70783 +}
70784 +
70785 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70786 + __u16 sport, __u16 dport)
70787 +{
70788 + struct conn_table_entry *match;
70789 + unsigned int index;
70790 +
70791 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70792 +
70793 + match = gr_conn_table[index];
70794 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70795 + match = match->next;
70796 +
70797 + if (match)
70798 + return match->sig;
70799 + else
70800 + return NULL;
70801 +}
70802 +
70803 +#endif
70804 +
70805 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70806 +{
70807 +#ifdef CONFIG_GRKERNSEC
70808 + struct signal_struct *sig = task->signal;
70809 + struct conn_table_entry *newent;
70810 +
70811 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70812 + if (newent == NULL)
70813 + return;
70814 + /* no bh lock needed since we are called with bh disabled */
70815 + spin_lock(&gr_conn_table_lock);
70816 + gr_del_task_from_ip_table_nolock(sig);
70817 + sig->gr_saddr = inet->inet_rcv_saddr;
70818 + sig->gr_daddr = inet->inet_daddr;
70819 + sig->gr_sport = inet->inet_sport;
70820 + sig->gr_dport = inet->inet_dport;
70821 + gr_add_to_task_ip_table_nolock(sig, newent);
70822 + spin_unlock(&gr_conn_table_lock);
70823 +#endif
70824 + return;
70825 +}
70826 +
70827 +void gr_del_task_from_ip_table(struct task_struct *task)
70828 +{
70829 +#ifdef CONFIG_GRKERNSEC
70830 + spin_lock_bh(&gr_conn_table_lock);
70831 + gr_del_task_from_ip_table_nolock(task->signal);
70832 + spin_unlock_bh(&gr_conn_table_lock);
70833 +#endif
70834 + return;
70835 +}
70836 +
70837 +void
70838 +gr_attach_curr_ip(const struct sock *sk)
70839 +{
70840 +#ifdef CONFIG_GRKERNSEC
70841 + struct signal_struct *p, *set;
70842 + const struct inet_sock *inet = inet_sk(sk);
70843 +
70844 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70845 + return;
70846 +
70847 + set = current->signal;
70848 +
70849 + spin_lock_bh(&gr_conn_table_lock);
70850 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70851 + inet->inet_dport, inet->inet_sport);
70852 + if (unlikely(p != NULL)) {
70853 + set->curr_ip = p->curr_ip;
70854 + set->used_accept = 1;
70855 + gr_del_task_from_ip_table_nolock(p);
70856 + spin_unlock_bh(&gr_conn_table_lock);
70857 + return;
70858 + }
70859 + spin_unlock_bh(&gr_conn_table_lock);
70860 +
70861 + set->curr_ip = inet->inet_daddr;
70862 + set->used_accept = 1;
70863 +#endif
70864 + return;
70865 +}
70866 +
70867 +int
70868 +gr_handle_sock_all(const int family, const int type, const int protocol)
70869 +{
70870 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70871 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70872 + (family != AF_UNIX)) {
70873 + if (family == AF_INET)
70874 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70875 + else
70876 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70877 + return -EACCES;
70878 + }
70879 +#endif
70880 + return 0;
70881 +}
70882 +
70883 +int
70884 +gr_handle_sock_server(const struct sockaddr *sck)
70885 +{
70886 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70887 + if (grsec_enable_socket_server &&
70888 + in_group_p(grsec_socket_server_gid) &&
70889 + sck && (sck->sa_family != AF_UNIX) &&
70890 + (sck->sa_family != AF_LOCAL)) {
70891 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70892 + return -EACCES;
70893 + }
70894 +#endif
70895 + return 0;
70896 +}
70897 +
70898 +int
70899 +gr_handle_sock_server_other(const struct sock *sck)
70900 +{
70901 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70902 + if (grsec_enable_socket_server &&
70903 + in_group_p(grsec_socket_server_gid) &&
70904 + sck && (sck->sk_family != AF_UNIX) &&
70905 + (sck->sk_family != AF_LOCAL)) {
70906 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70907 + return -EACCES;
70908 + }
70909 +#endif
70910 + return 0;
70911 +}
70912 +
70913 +int
70914 +gr_handle_sock_client(const struct sockaddr *sck)
70915 +{
70916 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70917 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70918 + sck && (sck->sa_family != AF_UNIX) &&
70919 + (sck->sa_family != AF_LOCAL)) {
70920 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70921 + return -EACCES;
70922 + }
70923 +#endif
70924 + return 0;
70925 +}
70926 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70927 new file mode 100644
70928 index 0000000..a147ae7
70929 --- /dev/null
70930 +++ b/grsecurity/grsec_sysctl.c
70931 @@ -0,0 +1,470 @@
70932 +#include <linux/kernel.h>
70933 +#include <linux/sched.h>
70934 +#include <linux/sysctl.h>
70935 +#include <linux/grsecurity.h>
70936 +#include <linux/grinternal.h>
70937 +
70938 +int
70939 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70940 +{
70941 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70942 + if (dirname == NULL || name == NULL)
70943 + return 0;
70944 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70945 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70946 + return -EACCES;
70947 + }
70948 +#endif
70949 + return 0;
70950 +}
70951 +
70952 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70953 +static int __maybe_unused __read_only one = 1;
70954 +#endif
70955 +
70956 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70957 + defined(CONFIG_GRKERNSEC_DENYUSB)
70958 +struct ctl_table grsecurity_table[] = {
70959 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70960 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70961 +#ifdef CONFIG_GRKERNSEC_IO
70962 + {
70963 + .procname = "disable_priv_io",
70964 + .data = &grsec_disable_privio,
70965 + .maxlen = sizeof(int),
70966 + .mode = 0600,
70967 + .proc_handler = &proc_dointvec,
70968 + },
70969 +#endif
70970 +#endif
70971 +#ifdef CONFIG_GRKERNSEC_LINK
70972 + {
70973 + .procname = "linking_restrictions",
70974 + .data = &grsec_enable_link,
70975 + .maxlen = sizeof(int),
70976 + .mode = 0600,
70977 + .proc_handler = &proc_dointvec,
70978 + },
70979 +#endif
70980 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70981 + {
70982 + .procname = "enforce_symlinksifowner",
70983 + .data = &grsec_enable_symlinkown,
70984 + .maxlen = sizeof(int),
70985 + .mode = 0600,
70986 + .proc_handler = &proc_dointvec,
70987 + },
70988 + {
70989 + .procname = "symlinkown_gid",
70990 + .data = &grsec_symlinkown_gid,
70991 + .maxlen = sizeof(int),
70992 + .mode = 0600,
70993 + .proc_handler = &proc_dointvec,
70994 + },
70995 +#endif
70996 +#ifdef CONFIG_GRKERNSEC_BRUTE
70997 + {
70998 + .procname = "deter_bruteforce",
70999 + .data = &grsec_enable_brute,
71000 + .maxlen = sizeof(int),
71001 + .mode = 0600,
71002 + .proc_handler = &proc_dointvec,
71003 + },
71004 +#endif
71005 +#ifdef CONFIG_GRKERNSEC_FIFO
71006 + {
71007 + .procname = "fifo_restrictions",
71008 + .data = &grsec_enable_fifo,
71009 + .maxlen = sizeof(int),
71010 + .mode = 0600,
71011 + .proc_handler = &proc_dointvec,
71012 + },
71013 +#endif
71014 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71015 + {
71016 + .procname = "ptrace_readexec",
71017 + .data = &grsec_enable_ptrace_readexec,
71018 + .maxlen = sizeof(int),
71019 + .mode = 0600,
71020 + .proc_handler = &proc_dointvec,
71021 + },
71022 +#endif
71023 +#ifdef CONFIG_GRKERNSEC_SETXID
71024 + {
71025 + .procname = "consistent_setxid",
71026 + .data = &grsec_enable_setxid,
71027 + .maxlen = sizeof(int),
71028 + .mode = 0600,
71029 + .proc_handler = &proc_dointvec,
71030 + },
71031 +#endif
71032 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71033 + {
71034 + .procname = "ip_blackhole",
71035 + .data = &grsec_enable_blackhole,
71036 + .maxlen = sizeof(int),
71037 + .mode = 0600,
71038 + .proc_handler = &proc_dointvec,
71039 + },
71040 + {
71041 + .procname = "lastack_retries",
71042 + .data = &grsec_lastack_retries,
71043 + .maxlen = sizeof(int),
71044 + .mode = 0600,
71045 + .proc_handler = &proc_dointvec,
71046 + },
71047 +#endif
71048 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71049 + {
71050 + .procname = "exec_logging",
71051 + .data = &grsec_enable_execlog,
71052 + .maxlen = sizeof(int),
71053 + .mode = 0600,
71054 + .proc_handler = &proc_dointvec,
71055 + },
71056 +#endif
71057 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71058 + {
71059 + .procname = "rwxmap_logging",
71060 + .data = &grsec_enable_log_rwxmaps,
71061 + .maxlen = sizeof(int),
71062 + .mode = 0600,
71063 + .proc_handler = &proc_dointvec,
71064 + },
71065 +#endif
71066 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71067 + {
71068 + .procname = "signal_logging",
71069 + .data = &grsec_enable_signal,
71070 + .maxlen = sizeof(int),
71071 + .mode = 0600,
71072 + .proc_handler = &proc_dointvec,
71073 + },
71074 +#endif
71075 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71076 + {
71077 + .procname = "forkfail_logging",
71078 + .data = &grsec_enable_forkfail,
71079 + .maxlen = sizeof(int),
71080 + .mode = 0600,
71081 + .proc_handler = &proc_dointvec,
71082 + },
71083 +#endif
71084 +#ifdef CONFIG_GRKERNSEC_TIME
71085 + {
71086 + .procname = "timechange_logging",
71087 + .data = &grsec_enable_time,
71088 + .maxlen = sizeof(int),
71089 + .mode = 0600,
71090 + .proc_handler = &proc_dointvec,
71091 + },
71092 +#endif
71093 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71094 + {
71095 + .procname = "chroot_deny_shmat",
71096 + .data = &grsec_enable_chroot_shmat,
71097 + .maxlen = sizeof(int),
71098 + .mode = 0600,
71099 + .proc_handler = &proc_dointvec,
71100 + },
71101 +#endif
71102 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71103 + {
71104 + .procname = "chroot_deny_unix",
71105 + .data = &grsec_enable_chroot_unix,
71106 + .maxlen = sizeof(int),
71107 + .mode = 0600,
71108 + .proc_handler = &proc_dointvec,
71109 + },
71110 +#endif
71111 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71112 + {
71113 + .procname = "chroot_deny_mount",
71114 + .data = &grsec_enable_chroot_mount,
71115 + .maxlen = sizeof(int),
71116 + .mode = 0600,
71117 + .proc_handler = &proc_dointvec,
71118 + },
71119 +#endif
71120 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71121 + {
71122 + .procname = "chroot_deny_fchdir",
71123 + .data = &grsec_enable_chroot_fchdir,
71124 + .maxlen = sizeof(int),
71125 + .mode = 0600,
71126 + .proc_handler = &proc_dointvec,
71127 + },
71128 +#endif
71129 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71130 + {
71131 + .procname = "chroot_deny_chroot",
71132 + .data = &grsec_enable_chroot_double,
71133 + .maxlen = sizeof(int),
71134 + .mode = 0600,
71135 + .proc_handler = &proc_dointvec,
71136 + },
71137 +#endif
71138 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71139 + {
71140 + .procname = "chroot_deny_pivot",
71141 + .data = &grsec_enable_chroot_pivot,
71142 + .maxlen = sizeof(int),
71143 + .mode = 0600,
71144 + .proc_handler = &proc_dointvec,
71145 + },
71146 +#endif
71147 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71148 + {
71149 + .procname = "chroot_enforce_chdir",
71150 + .data = &grsec_enable_chroot_chdir,
71151 + .maxlen = sizeof(int),
71152 + .mode = 0600,
71153 + .proc_handler = &proc_dointvec,
71154 + },
71155 +#endif
71156 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71157 + {
71158 + .procname = "chroot_deny_chmod",
71159 + .data = &grsec_enable_chroot_chmod,
71160 + .maxlen = sizeof(int),
71161 + .mode = 0600,
71162 + .proc_handler = &proc_dointvec,
71163 + },
71164 +#endif
71165 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71166 + {
71167 + .procname = "chroot_deny_mknod",
71168 + .data = &grsec_enable_chroot_mknod,
71169 + .maxlen = sizeof(int),
71170 + .mode = 0600,
71171 + .proc_handler = &proc_dointvec,
71172 + },
71173 +#endif
71174 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71175 + {
71176 + .procname = "chroot_restrict_nice",
71177 + .data = &grsec_enable_chroot_nice,
71178 + .maxlen = sizeof(int),
71179 + .mode = 0600,
71180 + .proc_handler = &proc_dointvec,
71181 + },
71182 +#endif
71183 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71184 + {
71185 + .procname = "chroot_execlog",
71186 + .data = &grsec_enable_chroot_execlog,
71187 + .maxlen = sizeof(int),
71188 + .mode = 0600,
71189 + .proc_handler = &proc_dointvec,
71190 + },
71191 +#endif
71192 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71193 + {
71194 + .procname = "chroot_caps",
71195 + .data = &grsec_enable_chroot_caps,
71196 + .maxlen = sizeof(int),
71197 + .mode = 0600,
71198 + .proc_handler = &proc_dointvec,
71199 + },
71200 +#endif
71201 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71202 + {
71203 + .procname = "chroot_deny_sysctl",
71204 + .data = &grsec_enable_chroot_sysctl,
71205 + .maxlen = sizeof(int),
71206 + .mode = 0600,
71207 + .proc_handler = &proc_dointvec,
71208 + },
71209 +#endif
71210 +#ifdef CONFIG_GRKERNSEC_TPE
71211 + {
71212 + .procname = "tpe",
71213 + .data = &grsec_enable_tpe,
71214 + .maxlen = sizeof(int),
71215 + .mode = 0600,
71216 + .proc_handler = &proc_dointvec,
71217 + },
71218 + {
71219 + .procname = "tpe_gid",
71220 + .data = &grsec_tpe_gid,
71221 + .maxlen = sizeof(int),
71222 + .mode = 0600,
71223 + .proc_handler = &proc_dointvec,
71224 + },
71225 +#endif
71226 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71227 + {
71228 + .procname = "tpe_invert",
71229 + .data = &grsec_enable_tpe_invert,
71230 + .maxlen = sizeof(int),
71231 + .mode = 0600,
71232 + .proc_handler = &proc_dointvec,
71233 + },
71234 +#endif
71235 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71236 + {
71237 + .procname = "tpe_restrict_all",
71238 + .data = &grsec_enable_tpe_all,
71239 + .maxlen = sizeof(int),
71240 + .mode = 0600,
71241 + .proc_handler = &proc_dointvec,
71242 + },
71243 +#endif
71244 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71245 + {
71246 + .procname = "socket_all",
71247 + .data = &grsec_enable_socket_all,
71248 + .maxlen = sizeof(int),
71249 + .mode = 0600,
71250 + .proc_handler = &proc_dointvec,
71251 + },
71252 + {
71253 + .procname = "socket_all_gid",
71254 + .data = &grsec_socket_all_gid,
71255 + .maxlen = sizeof(int),
71256 + .mode = 0600,
71257 + .proc_handler = &proc_dointvec,
71258 + },
71259 +#endif
71260 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71261 + {
71262 + .procname = "socket_client",
71263 + .data = &grsec_enable_socket_client,
71264 + .maxlen = sizeof(int),
71265 + .mode = 0600,
71266 + .proc_handler = &proc_dointvec,
71267 + },
71268 + {
71269 + .procname = "socket_client_gid",
71270 + .data = &grsec_socket_client_gid,
71271 + .maxlen = sizeof(int),
71272 + .mode = 0600,
71273 + .proc_handler = &proc_dointvec,
71274 + },
71275 +#endif
71276 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71277 + {
71278 + .procname = "socket_server",
71279 + .data = &grsec_enable_socket_server,
71280 + .maxlen = sizeof(int),
71281 + .mode = 0600,
71282 + .proc_handler = &proc_dointvec,
71283 + },
71284 + {
71285 + .procname = "socket_server_gid",
71286 + .data = &grsec_socket_server_gid,
71287 + .maxlen = sizeof(int),
71288 + .mode = 0600,
71289 + .proc_handler = &proc_dointvec,
71290 + },
71291 +#endif
71292 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71293 + {
71294 + .procname = "audit_group",
71295 + .data = &grsec_enable_group,
71296 + .maxlen = sizeof(int),
71297 + .mode = 0600,
71298 + .proc_handler = &proc_dointvec,
71299 + },
71300 + {
71301 + .procname = "audit_gid",
71302 + .data = &grsec_audit_gid,
71303 + .maxlen = sizeof(int),
71304 + .mode = 0600,
71305 + .proc_handler = &proc_dointvec,
71306 + },
71307 +#endif
71308 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71309 + {
71310 + .procname = "audit_chdir",
71311 + .data = &grsec_enable_chdir,
71312 + .maxlen = sizeof(int),
71313 + .mode = 0600,
71314 + .proc_handler = &proc_dointvec,
71315 + },
71316 +#endif
71317 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71318 + {
71319 + .procname = "audit_mount",
71320 + .data = &grsec_enable_mount,
71321 + .maxlen = sizeof(int),
71322 + .mode = 0600,
71323 + .proc_handler = &proc_dointvec,
71324 + },
71325 +#endif
71326 +#ifdef CONFIG_GRKERNSEC_DMESG
71327 + {
71328 + .procname = "dmesg",
71329 + .data = &grsec_enable_dmesg,
71330 + .maxlen = sizeof(int),
71331 + .mode = 0600,
71332 + .proc_handler = &proc_dointvec,
71333 + },
71334 +#endif
71335 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71336 + {
71337 + .procname = "chroot_findtask",
71338 + .data = &grsec_enable_chroot_findtask,
71339 + .maxlen = sizeof(int),
71340 + .mode = 0600,
71341 + .proc_handler = &proc_dointvec,
71342 + },
71343 +#endif
71344 +#ifdef CONFIG_GRKERNSEC_RESLOG
71345 + {
71346 + .procname = "resource_logging",
71347 + .data = &grsec_resource_logging,
71348 + .maxlen = sizeof(int),
71349 + .mode = 0600,
71350 + .proc_handler = &proc_dointvec,
71351 + },
71352 +#endif
71353 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71354 + {
71355 + .procname = "audit_ptrace",
71356 + .data = &grsec_enable_audit_ptrace,
71357 + .maxlen = sizeof(int),
71358 + .mode = 0600,
71359 + .proc_handler = &proc_dointvec,
71360 + },
71361 +#endif
71362 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71363 + {
71364 + .procname = "harden_ptrace",
71365 + .data = &grsec_enable_harden_ptrace,
71366 + .maxlen = sizeof(int),
71367 + .mode = 0600,
71368 + .proc_handler = &proc_dointvec,
71369 + },
71370 +#endif
71371 + {
71372 + .procname = "grsec_lock",
71373 + .data = &grsec_lock,
71374 + .maxlen = sizeof(int),
71375 + .mode = 0600,
71376 + .proc_handler = &proc_dointvec,
71377 + },
71378 +#endif
71379 +#ifdef CONFIG_GRKERNSEC_ROFS
71380 + {
71381 + .procname = "romount_protect",
71382 + .data = &grsec_enable_rofs,
71383 + .maxlen = sizeof(int),
71384 + .mode = 0600,
71385 + .proc_handler = &proc_dointvec_minmax,
71386 + .extra1 = &one,
71387 + .extra2 = &one,
71388 + },
71389 +#endif
71390 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71391 + {
71392 + .procname = "deny_new_usb",
71393 + .data = &grsec_deny_new_usb,
71394 + .maxlen = sizeof(int),
71395 + .mode = 0600,
71396 + .proc_handler = &proc_dointvec,
71397 + },
71398 +#endif
71399 + { }
71400 +};
71401 +#endif
71402 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71403 new file mode 100644
71404 index 0000000..0dc13c3
71405 --- /dev/null
71406 +++ b/grsecurity/grsec_time.c
71407 @@ -0,0 +1,16 @@
71408 +#include <linux/kernel.h>
71409 +#include <linux/sched.h>
71410 +#include <linux/grinternal.h>
71411 +#include <linux/module.h>
71412 +
71413 +void
71414 +gr_log_timechange(void)
71415 +{
71416 +#ifdef CONFIG_GRKERNSEC_TIME
71417 + if (grsec_enable_time)
71418 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71419 +#endif
71420 + return;
71421 +}
71422 +
71423 +EXPORT_SYMBOL(gr_log_timechange);
71424 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71425 new file mode 100644
71426 index 0000000..ee57dcf
71427 --- /dev/null
71428 +++ b/grsecurity/grsec_tpe.c
71429 @@ -0,0 +1,73 @@
71430 +#include <linux/kernel.h>
71431 +#include <linux/sched.h>
71432 +#include <linux/file.h>
71433 +#include <linux/fs.h>
71434 +#include <linux/grinternal.h>
71435 +
71436 +extern int gr_acl_tpe_check(void);
71437 +
71438 +int
71439 +gr_tpe_allow(const struct file *file)
71440 +{
71441 +#ifdef CONFIG_GRKERNSEC
71442 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71443 + const struct cred *cred = current_cred();
71444 + char *msg = NULL;
71445 + char *msg2 = NULL;
71446 +
71447 + // never restrict root
71448 + if (gr_is_global_root(cred->uid))
71449 + return 1;
71450 +
71451 + if (grsec_enable_tpe) {
71452 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71453 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71454 + msg = "not being in trusted group";
71455 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71456 + msg = "being in untrusted group";
71457 +#else
71458 + if (in_group_p(grsec_tpe_gid))
71459 + msg = "being in untrusted group";
71460 +#endif
71461 + }
71462 + if (!msg && gr_acl_tpe_check())
71463 + msg = "being in untrusted role";
71464 +
71465 + // not in any affected group/role
71466 + if (!msg)
71467 + goto next_check;
71468 +
71469 + if (gr_is_global_nonroot(inode->i_uid))
71470 + msg2 = "file in non-root-owned directory";
71471 + else if (inode->i_mode & S_IWOTH)
71472 + msg2 = "file in world-writable directory";
71473 + else if (inode->i_mode & S_IWGRP)
71474 + msg2 = "file in group-writable directory";
71475 +
71476 + if (msg && msg2) {
71477 + char fullmsg[70] = {0};
71478 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71479 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71480 + return 0;
71481 + }
71482 + msg = NULL;
71483 +next_check:
71484 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71485 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71486 + return 1;
71487 +
71488 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71489 + msg = "directory not owned by user";
71490 + else if (inode->i_mode & S_IWOTH)
71491 + msg = "file in world-writable directory";
71492 + else if (inode->i_mode & S_IWGRP)
71493 + msg = "file in group-writable directory";
71494 +
71495 + if (msg) {
71496 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71497 + return 0;
71498 + }
71499 +#endif
71500 +#endif
71501 + return 1;
71502 +}
71503 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71504 new file mode 100644
71505 index 0000000..ae02d8e
71506 --- /dev/null
71507 +++ b/grsecurity/grsec_usb.c
71508 @@ -0,0 +1,15 @@
71509 +#include <linux/kernel.h>
71510 +#include <linux/grinternal.h>
71511 +#include <linux/module.h>
71512 +
71513 +int gr_handle_new_usb(void)
71514 +{
71515 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71516 + if (grsec_deny_new_usb) {
71517 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71518 + return 1;
71519 + }
71520 +#endif
71521 + return 0;
71522 +}
71523 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71524 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71525 new file mode 100644
71526 index 0000000..9f7b1ac
71527 --- /dev/null
71528 +++ b/grsecurity/grsum.c
71529 @@ -0,0 +1,61 @@
71530 +#include <linux/err.h>
71531 +#include <linux/kernel.h>
71532 +#include <linux/sched.h>
71533 +#include <linux/mm.h>
71534 +#include <linux/scatterlist.h>
71535 +#include <linux/crypto.h>
71536 +#include <linux/gracl.h>
71537 +
71538 +
71539 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71540 +#error "crypto and sha256 must be built into the kernel"
71541 +#endif
71542 +
71543 +int
71544 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71545 +{
71546 + char *p;
71547 + struct crypto_hash *tfm;
71548 + struct hash_desc desc;
71549 + struct scatterlist sg;
71550 + unsigned char temp_sum[GR_SHA_LEN];
71551 + volatile int retval = 0;
71552 + volatile int dummy = 0;
71553 + unsigned int i;
71554 +
71555 + sg_init_table(&sg, 1);
71556 +
71557 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71558 + if (IS_ERR(tfm)) {
71559 + /* should never happen, since sha256 should be built in */
71560 + return 1;
71561 + }
71562 +
71563 + desc.tfm = tfm;
71564 + desc.flags = 0;
71565 +
71566 + crypto_hash_init(&desc);
71567 +
71568 + p = salt;
71569 + sg_set_buf(&sg, p, GR_SALT_LEN);
71570 + crypto_hash_update(&desc, &sg, sg.length);
71571 +
71572 + p = entry->pw;
71573 + sg_set_buf(&sg, p, strlen(p));
71574 +
71575 + crypto_hash_update(&desc, &sg, sg.length);
71576 +
71577 + crypto_hash_final(&desc, temp_sum);
71578 +
71579 + memset(entry->pw, 0, GR_PW_LEN);
71580 +
71581 + for (i = 0; i < GR_SHA_LEN; i++)
71582 + if (sum[i] != temp_sum[i])
71583 + retval = 1;
71584 + else
71585 + dummy = 1; // waste a cycle
71586 +
71587 + crypto_free_hash(tfm);
71588 +
71589 + return retval;
71590 +}
71591 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71592 index 77ff547..181834f 100644
71593 --- a/include/asm-generic/4level-fixup.h
71594 +++ b/include/asm-generic/4level-fixup.h
71595 @@ -13,8 +13,10 @@
71596 #define pmd_alloc(mm, pud, address) \
71597 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71598 NULL: pmd_offset(pud, address))
71599 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71600
71601 #define pud_alloc(mm, pgd, address) (pgd)
71602 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71603 #define pud_offset(pgd, start) (pgd)
71604 #define pud_none(pud) 0
71605 #define pud_bad(pud) 0
71606 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71607 index b7babf0..04ad282 100644
71608 --- a/include/asm-generic/atomic-long.h
71609 +++ b/include/asm-generic/atomic-long.h
71610 @@ -22,6 +22,12 @@
71611
71612 typedef atomic64_t atomic_long_t;
71613
71614 +#ifdef CONFIG_PAX_REFCOUNT
71615 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71616 +#else
71617 +typedef atomic64_t atomic_long_unchecked_t;
71618 +#endif
71619 +
71620 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71621
71622 static inline long atomic_long_read(atomic_long_t *l)
71623 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71624 return (long)atomic64_read(v);
71625 }
71626
71627 +#ifdef CONFIG_PAX_REFCOUNT
71628 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71629 +{
71630 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71631 +
71632 + return (long)atomic64_read_unchecked(v);
71633 +}
71634 +#endif
71635 +
71636 static inline void atomic_long_set(atomic_long_t *l, long i)
71637 {
71638 atomic64_t *v = (atomic64_t *)l;
71639 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71640 atomic64_set(v, i);
71641 }
71642
71643 +#ifdef CONFIG_PAX_REFCOUNT
71644 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71645 +{
71646 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71647 +
71648 + atomic64_set_unchecked(v, i);
71649 +}
71650 +#endif
71651 +
71652 static inline void atomic_long_inc(atomic_long_t *l)
71653 {
71654 atomic64_t *v = (atomic64_t *)l;
71655 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71656 atomic64_inc(v);
71657 }
71658
71659 +#ifdef CONFIG_PAX_REFCOUNT
71660 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71661 +{
71662 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71663 +
71664 + atomic64_inc_unchecked(v);
71665 +}
71666 +#endif
71667 +
71668 static inline void atomic_long_dec(atomic_long_t *l)
71669 {
71670 atomic64_t *v = (atomic64_t *)l;
71671 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71672 atomic64_dec(v);
71673 }
71674
71675 +#ifdef CONFIG_PAX_REFCOUNT
71676 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71677 +{
71678 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71679 +
71680 + atomic64_dec_unchecked(v);
71681 +}
71682 +#endif
71683 +
71684 static inline void atomic_long_add(long i, atomic_long_t *l)
71685 {
71686 atomic64_t *v = (atomic64_t *)l;
71687 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71688 atomic64_add(i, v);
71689 }
71690
71691 +#ifdef CONFIG_PAX_REFCOUNT
71692 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71693 +{
71694 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71695 +
71696 + atomic64_add_unchecked(i, v);
71697 +}
71698 +#endif
71699 +
71700 static inline void atomic_long_sub(long i, atomic_long_t *l)
71701 {
71702 atomic64_t *v = (atomic64_t *)l;
71703 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71704 atomic64_sub(i, v);
71705 }
71706
71707 +#ifdef CONFIG_PAX_REFCOUNT
71708 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71709 +{
71710 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71711 +
71712 + atomic64_sub_unchecked(i, v);
71713 +}
71714 +#endif
71715 +
71716 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71717 {
71718 atomic64_t *v = (atomic64_t *)l;
71719 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71720 return (long)atomic64_add_return(i, v);
71721 }
71722
71723 +#ifdef CONFIG_PAX_REFCOUNT
71724 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71725 +{
71726 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71727 +
71728 + return (long)atomic64_add_return_unchecked(i, v);
71729 +}
71730 +#endif
71731 +
71732 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71733 {
71734 atomic64_t *v = (atomic64_t *)l;
71735 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71736 return (long)atomic64_inc_return(v);
71737 }
71738
71739 +#ifdef CONFIG_PAX_REFCOUNT
71740 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71741 +{
71742 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71743 +
71744 + return (long)atomic64_inc_return_unchecked(v);
71745 +}
71746 +#endif
71747 +
71748 static inline long atomic_long_dec_return(atomic_long_t *l)
71749 {
71750 atomic64_t *v = (atomic64_t *)l;
71751 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71752
71753 typedef atomic_t atomic_long_t;
71754
71755 +#ifdef CONFIG_PAX_REFCOUNT
71756 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71757 +#else
71758 +typedef atomic_t atomic_long_unchecked_t;
71759 +#endif
71760 +
71761 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71762 static inline long atomic_long_read(atomic_long_t *l)
71763 {
71764 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71765 return (long)atomic_read(v);
71766 }
71767
71768 +#ifdef CONFIG_PAX_REFCOUNT
71769 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71770 +{
71771 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71772 +
71773 + return (long)atomic_read_unchecked(v);
71774 +}
71775 +#endif
71776 +
71777 static inline void atomic_long_set(atomic_long_t *l, long i)
71778 {
71779 atomic_t *v = (atomic_t *)l;
71780 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71781 atomic_set(v, i);
71782 }
71783
71784 +#ifdef CONFIG_PAX_REFCOUNT
71785 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71786 +{
71787 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71788 +
71789 + atomic_set_unchecked(v, i);
71790 +}
71791 +#endif
71792 +
71793 static inline void atomic_long_inc(atomic_long_t *l)
71794 {
71795 atomic_t *v = (atomic_t *)l;
71796 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71797 atomic_inc(v);
71798 }
71799
71800 +#ifdef CONFIG_PAX_REFCOUNT
71801 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71802 +{
71803 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71804 +
71805 + atomic_inc_unchecked(v);
71806 +}
71807 +#endif
71808 +
71809 static inline void atomic_long_dec(atomic_long_t *l)
71810 {
71811 atomic_t *v = (atomic_t *)l;
71812 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71813 atomic_dec(v);
71814 }
71815
71816 +#ifdef CONFIG_PAX_REFCOUNT
71817 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71818 +{
71819 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71820 +
71821 + atomic_dec_unchecked(v);
71822 +}
71823 +#endif
71824 +
71825 static inline void atomic_long_add(long i, atomic_long_t *l)
71826 {
71827 atomic_t *v = (atomic_t *)l;
71828 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71829 atomic_add(i, v);
71830 }
71831
71832 +#ifdef CONFIG_PAX_REFCOUNT
71833 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71834 +{
71835 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71836 +
71837 + atomic_add_unchecked(i, v);
71838 +}
71839 +#endif
71840 +
71841 static inline void atomic_long_sub(long i, atomic_long_t *l)
71842 {
71843 atomic_t *v = (atomic_t *)l;
71844 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71845 atomic_sub(i, v);
71846 }
71847
71848 +#ifdef CONFIG_PAX_REFCOUNT
71849 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71850 +{
71851 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71852 +
71853 + atomic_sub_unchecked(i, v);
71854 +}
71855 +#endif
71856 +
71857 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71858 {
71859 atomic_t *v = (atomic_t *)l;
71860 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71861 return (long)atomic_add_return(i, v);
71862 }
71863
71864 +#ifdef CONFIG_PAX_REFCOUNT
71865 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71866 +{
71867 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71868 +
71869 + return (long)atomic_add_return_unchecked(i, v);
71870 +}
71871 +
71872 +#endif
71873 +
71874 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71875 {
71876 atomic_t *v = (atomic_t *)l;
71877 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71878 return (long)atomic_inc_return(v);
71879 }
71880
71881 +#ifdef CONFIG_PAX_REFCOUNT
71882 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71883 +{
71884 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71885 +
71886 + return (long)atomic_inc_return_unchecked(v);
71887 +}
71888 +#endif
71889 +
71890 static inline long atomic_long_dec_return(atomic_long_t *l)
71891 {
71892 atomic_t *v = (atomic_t *)l;
71893 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71894
71895 #endif /* BITS_PER_LONG == 64 */
71896
71897 +#ifdef CONFIG_PAX_REFCOUNT
71898 +static inline void pax_refcount_needs_these_functions(void)
71899 +{
71900 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71901 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71902 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71903 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71904 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71905 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71906 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71907 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71908 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71909 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71910 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71911 +#ifdef CONFIG_X86
71912 + atomic_clear_mask_unchecked(0, NULL);
71913 + atomic_set_mask_unchecked(0, NULL);
71914 +#endif
71915 +
71916 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71917 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71918 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71919 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71920 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71921 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71922 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71923 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71924 +}
71925 +#else
71926 +#define atomic_read_unchecked(v) atomic_read(v)
71927 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71928 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71929 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71930 +#define atomic_inc_unchecked(v) atomic_inc(v)
71931 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71932 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71933 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71934 +#define atomic_dec_unchecked(v) atomic_dec(v)
71935 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71936 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71937 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71938 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71939 +
71940 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71941 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71942 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71943 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71944 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71945 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71946 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71947 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71948 +#endif
71949 +
71950 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71951 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71952 index 33bd2de..f31bff97 100644
71953 --- a/include/asm-generic/atomic.h
71954 +++ b/include/asm-generic/atomic.h
71955 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71956 * Atomically clears the bits set in @mask from @v
71957 */
71958 #ifndef atomic_clear_mask
71959 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71960 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71961 {
71962 unsigned long flags;
71963
71964 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71965 index b18ce4f..2ee2843 100644
71966 --- a/include/asm-generic/atomic64.h
71967 +++ b/include/asm-generic/atomic64.h
71968 @@ -16,6 +16,8 @@ typedef struct {
71969 long long counter;
71970 } atomic64_t;
71971
71972 +typedef atomic64_t atomic64_unchecked_t;
71973 +
71974 #define ATOMIC64_INIT(i) { (i) }
71975
71976 extern long long atomic64_read(const atomic64_t *v);
71977 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71978 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71979 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71980
71981 +#define atomic64_read_unchecked(v) atomic64_read(v)
71982 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71983 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71984 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71985 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71986 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71987 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71988 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71989 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71990 +
71991 #endif /* _ASM_GENERIC_ATOMIC64_H */
71992 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71993 index 1bfcfe5..e04c5c9 100644
71994 --- a/include/asm-generic/cache.h
71995 +++ b/include/asm-generic/cache.h
71996 @@ -6,7 +6,7 @@
71997 * cache lines need to provide their own cache.h.
71998 */
71999
72000 -#define L1_CACHE_SHIFT 5
72001 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72002 +#define L1_CACHE_SHIFT 5UL
72003 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72004
72005 #endif /* __ASM_GENERIC_CACHE_H */
72006 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72007 index 0d68a1e..b74a761 100644
72008 --- a/include/asm-generic/emergency-restart.h
72009 +++ b/include/asm-generic/emergency-restart.h
72010 @@ -1,7 +1,7 @@
72011 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72012 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72013
72014 -static inline void machine_emergency_restart(void)
72015 +static inline __noreturn void machine_emergency_restart(void)
72016 {
72017 machine_restart(NULL);
72018 }
72019 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72020 index 90f99c7..00ce236 100644
72021 --- a/include/asm-generic/kmap_types.h
72022 +++ b/include/asm-generic/kmap_types.h
72023 @@ -2,9 +2,9 @@
72024 #define _ASM_GENERIC_KMAP_TYPES_H
72025
72026 #ifdef __WITH_KM_FENCE
72027 -# define KM_TYPE_NR 41
72028 +# define KM_TYPE_NR 42
72029 #else
72030 -# define KM_TYPE_NR 20
72031 +# define KM_TYPE_NR 21
72032 #endif
72033
72034 #endif
72035 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72036 index 9ceb03b..62b0b8f 100644
72037 --- a/include/asm-generic/local.h
72038 +++ b/include/asm-generic/local.h
72039 @@ -23,24 +23,37 @@ typedef struct
72040 atomic_long_t a;
72041 } local_t;
72042
72043 +typedef struct {
72044 + atomic_long_unchecked_t a;
72045 +} local_unchecked_t;
72046 +
72047 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72048
72049 #define local_read(l) atomic_long_read(&(l)->a)
72050 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72051 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72052 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72053 #define local_inc(l) atomic_long_inc(&(l)->a)
72054 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72055 #define local_dec(l) atomic_long_dec(&(l)->a)
72056 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72057 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72058 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72059 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72060 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72061
72062 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72063 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72064 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72065 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72066 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72067 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72068 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72069 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72070 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72071
72072 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72073 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72074 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72075 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72076 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72077 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72078 index 725612b..9cc513a 100644
72079 --- a/include/asm-generic/pgtable-nopmd.h
72080 +++ b/include/asm-generic/pgtable-nopmd.h
72081 @@ -1,14 +1,19 @@
72082 #ifndef _PGTABLE_NOPMD_H
72083 #define _PGTABLE_NOPMD_H
72084
72085 -#ifndef __ASSEMBLY__
72086 -
72087 #include <asm-generic/pgtable-nopud.h>
72088
72089 -struct mm_struct;
72090 -
72091 #define __PAGETABLE_PMD_FOLDED
72092
72093 +#define PMD_SHIFT PUD_SHIFT
72094 +#define PTRS_PER_PMD 1
72095 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72096 +#define PMD_MASK (~(PMD_SIZE-1))
72097 +
72098 +#ifndef __ASSEMBLY__
72099 +
72100 +struct mm_struct;
72101 +
72102 /*
72103 * Having the pmd type consist of a pud gets the size right, and allows
72104 * us to conceptually access the pud entry that this pmd is folded into
72105 @@ -16,11 +21,6 @@ struct mm_struct;
72106 */
72107 typedef struct { pud_t pud; } pmd_t;
72108
72109 -#define PMD_SHIFT PUD_SHIFT
72110 -#define PTRS_PER_PMD 1
72111 -#define PMD_SIZE (1UL << PMD_SHIFT)
72112 -#define PMD_MASK (~(PMD_SIZE-1))
72113 -
72114 /*
72115 * The "pud_xxx()" functions here are trivial for a folded two-level
72116 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72117 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72118 index 810431d..0ec4804f 100644
72119 --- a/include/asm-generic/pgtable-nopud.h
72120 +++ b/include/asm-generic/pgtable-nopud.h
72121 @@ -1,10 +1,15 @@
72122 #ifndef _PGTABLE_NOPUD_H
72123 #define _PGTABLE_NOPUD_H
72124
72125 -#ifndef __ASSEMBLY__
72126 -
72127 #define __PAGETABLE_PUD_FOLDED
72128
72129 +#define PUD_SHIFT PGDIR_SHIFT
72130 +#define PTRS_PER_PUD 1
72131 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72132 +#define PUD_MASK (~(PUD_SIZE-1))
72133 +
72134 +#ifndef __ASSEMBLY__
72135 +
72136 /*
72137 * Having the pud type consist of a pgd gets the size right, and allows
72138 * us to conceptually access the pgd entry that this pud is folded into
72139 @@ -12,11 +17,6 @@
72140 */
72141 typedef struct { pgd_t pgd; } pud_t;
72142
72143 -#define PUD_SHIFT PGDIR_SHIFT
72144 -#define PTRS_PER_PUD 1
72145 -#define PUD_SIZE (1UL << PUD_SHIFT)
72146 -#define PUD_MASK (~(PUD_SIZE-1))
72147 -
72148 /*
72149 * The "pgd_xxx()" functions here are trivial for a folded two-level
72150 * setup: the pud is never bad, and a pud always exists (as it's folded
72151 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72152 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72153
72154 #define pgd_populate(mm, pgd, pud) do { } while (0)
72155 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72156 /*
72157 * (puds are folded into pgds so this doesn't get actually called,
72158 * but the define is needed for a generic inline function.)
72159 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72160 index 0807ddf..cd67747 100644
72161 --- a/include/asm-generic/pgtable.h
72162 +++ b/include/asm-generic/pgtable.h
72163 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72164 }
72165 #endif /* CONFIG_NUMA_BALANCING */
72166
72167 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72168 +#ifdef CONFIG_PAX_KERNEXEC
72169 +#error KERNEXEC requires pax_open_kernel
72170 +#else
72171 +static inline unsigned long pax_open_kernel(void) { return 0; }
72172 +#endif
72173 +#endif
72174 +
72175 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72176 +#ifdef CONFIG_PAX_KERNEXEC
72177 +#error KERNEXEC requires pax_close_kernel
72178 +#else
72179 +static inline unsigned long pax_close_kernel(void) { return 0; }
72180 +#endif
72181 +#endif
72182 +
72183 #endif /* CONFIG_MMU */
72184
72185 #endif /* !__ASSEMBLY__ */
72186 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72187 index dc1269c..48a4f51 100644
72188 --- a/include/asm-generic/uaccess.h
72189 +++ b/include/asm-generic/uaccess.h
72190 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72191 return __clear_user(to, n);
72192 }
72193
72194 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72195 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72196 +#error UDEREF requires pax_open_userland
72197 +#else
72198 +static inline unsigned long pax_open_userland(void) { return 0; }
72199 +#endif
72200 +#endif
72201 +
72202 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72203 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72204 +#error UDEREF requires pax_close_userland
72205 +#else
72206 +static inline unsigned long pax_close_userland(void) { return 0; }
72207 +#endif
72208 +#endif
72209 +
72210 #endif /* __ASM_GENERIC_UACCESS_H */
72211 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72212 index 69732d2..cbe16d9 100644
72213 --- a/include/asm-generic/vmlinux.lds.h
72214 +++ b/include/asm-generic/vmlinux.lds.h
72215 @@ -227,6 +227,7 @@
72216 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72217 VMLINUX_SYMBOL(__start_rodata) = .; \
72218 *(.rodata) *(.rodata.*) \
72219 + *(.data..read_only) \
72220 *(__vermagic) /* Kernel version magic */ \
72221 . = ALIGN(8); \
72222 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72223 @@ -710,17 +711,18 @@
72224 * section in the linker script will go there too. @phdr should have
72225 * a leading colon.
72226 *
72227 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72228 + * Note that this macros defines per_cpu_load as an absolute symbol.
72229 * If there is no need to put the percpu section at a predetermined
72230 * address, use PERCPU_SECTION.
72231 */
72232 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72233 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72234 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72235 + per_cpu_load = .; \
72236 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72237 - LOAD_OFFSET) { \
72238 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72239 PERCPU_INPUT(cacheline) \
72240 } phdr \
72241 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72242 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72243
72244 /**
72245 * PERCPU_SECTION - define output section for percpu area, simple version
72246 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72247 index 418d270..bfd2794 100644
72248 --- a/include/crypto/algapi.h
72249 +++ b/include/crypto/algapi.h
72250 @@ -34,7 +34,7 @@ struct crypto_type {
72251 unsigned int maskclear;
72252 unsigned int maskset;
72253 unsigned int tfmsize;
72254 -};
72255 +} __do_const;
72256
72257 struct crypto_instance {
72258 struct crypto_alg alg;
72259 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72260 index 12083dc..39740ec 100644
72261 --- a/include/drm/drmP.h
72262 +++ b/include/drm/drmP.h
72263 @@ -69,6 +69,7 @@
72264 #include <linux/workqueue.h>
72265 #include <linux/poll.h>
72266 #include <asm/pgalloc.h>
72267 +#include <asm/local.h>
72268 #include <drm/drm.h>
72269 #include <drm/drm_sarea.h>
72270
72271 @@ -293,10 +294,12 @@ do { \
72272 * \param cmd command.
72273 * \param arg argument.
72274 */
72275 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72276 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72277 + struct drm_file *file_priv);
72278 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72279 struct drm_file *file_priv);
72280
72281 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72282 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72283 unsigned long arg);
72284
72285 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72286 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72287 struct drm_ioctl_desc {
72288 unsigned int cmd;
72289 int flags;
72290 - drm_ioctl_t *func;
72291 + drm_ioctl_t func;
72292 unsigned int cmd_drv;
72293 const char *name;
72294 -};
72295 +} __do_const;
72296
72297 /**
72298 * Creates a driver or general drm_ioctl_desc array entry for the given
72299 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72300 int (*show)(struct seq_file*, void*); /** show callback */
72301 u32 driver_features; /**< Required driver features for this entry */
72302 void *data;
72303 -};
72304 +} __do_const;
72305
72306 /**
72307 * debugfs node structure. This structure represents a debugfs file.
72308 @@ -1088,7 +1091,7 @@ struct drm_device {
72309
72310 /** \name Usage Counters */
72311 /*@{ */
72312 - int open_count; /**< Outstanding files open */
72313 + local_t open_count; /**< Outstanding files open */
72314 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72315 atomic_t vma_count; /**< Outstanding vma areas open */
72316 int buf_use; /**< Buffers in use -- cannot alloc */
72317 @@ -1099,7 +1102,7 @@ struct drm_device {
72318 /*@{ */
72319 unsigned long counters;
72320 enum drm_stat_type types[15];
72321 - atomic_t counts[15];
72322 + atomic_unchecked_t counts[15];
72323 /*@} */
72324
72325 struct list_head filelist;
72326 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72327 index f43d556..94d9343 100644
72328 --- a/include/drm/drm_crtc_helper.h
72329 +++ b/include/drm/drm_crtc_helper.h
72330 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72331 struct drm_connector *connector);
72332 /* disable encoder when not in use - more explicit than dpms off */
72333 void (*disable)(struct drm_encoder *encoder);
72334 -};
72335 +} __no_const;
72336
72337 /**
72338 * drm_connector_helper_funcs - helper operations for connectors
72339 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72340 index 72dcbe8..8db58d7 100644
72341 --- a/include/drm/ttm/ttm_memory.h
72342 +++ b/include/drm/ttm/ttm_memory.h
72343 @@ -48,7 +48,7 @@
72344
72345 struct ttm_mem_shrink {
72346 int (*do_shrink) (struct ttm_mem_shrink *);
72347 -};
72348 +} __no_const;
72349
72350 /**
72351 * struct ttm_mem_global - Global memory accounting structure.
72352 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72353 index 4b840e8..155d235 100644
72354 --- a/include/keys/asymmetric-subtype.h
72355 +++ b/include/keys/asymmetric-subtype.h
72356 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72357 /* Verify the signature on a key of this subtype (optional) */
72358 int (*verify_signature)(const struct key *key,
72359 const struct public_key_signature *sig);
72360 -};
72361 +} __do_const;
72362
72363 /**
72364 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72365 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72366 index c1da539..1dcec55 100644
72367 --- a/include/linux/atmdev.h
72368 +++ b/include/linux/atmdev.h
72369 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72370 #endif
72371
72372 struct k_atm_aal_stats {
72373 -#define __HANDLE_ITEM(i) atomic_t i
72374 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72375 __AAL_STAT_ITEMS
72376 #undef __HANDLE_ITEM
72377 };
72378 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72379 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72380 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72381 struct module *owner;
72382 -};
72383 +} __do_const ;
72384
72385 struct atmphy_ops {
72386 int (*start)(struct atm_dev *dev);
72387 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72388 index 70cf138..0418ee2 100644
72389 --- a/include/linux/binfmts.h
72390 +++ b/include/linux/binfmts.h
72391 @@ -73,8 +73,10 @@ struct linux_binfmt {
72392 int (*load_binary)(struct linux_binprm *);
72393 int (*load_shlib)(struct file *);
72394 int (*core_dump)(struct coredump_params *cprm);
72395 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72396 + void (*handle_mmap)(struct file *);
72397 unsigned long min_coredump; /* minimal dump size */
72398 -};
72399 +} __do_const;
72400
72401 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72402
72403 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72404 index 2fdb4a4..54aad7e 100644
72405 --- a/include/linux/blkdev.h
72406 +++ b/include/linux/blkdev.h
72407 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72408 /* this callback is with swap_lock and sometimes page table lock held */
72409 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72410 struct module *owner;
72411 -};
72412 +} __do_const;
72413
72414 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72415 unsigned long);
72416 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72417 index 7c2e030..b72475d 100644
72418 --- a/include/linux/blktrace_api.h
72419 +++ b/include/linux/blktrace_api.h
72420 @@ -23,7 +23,7 @@ struct blk_trace {
72421 struct dentry *dir;
72422 struct dentry *dropped_file;
72423 struct dentry *msg_file;
72424 - atomic_t dropped;
72425 + atomic_unchecked_t dropped;
72426 };
72427
72428 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72429 diff --git a/include/linux/cache.h b/include/linux/cache.h
72430 index 4c57065..40346da 100644
72431 --- a/include/linux/cache.h
72432 +++ b/include/linux/cache.h
72433 @@ -16,6 +16,14 @@
72434 #define __read_mostly
72435 #endif
72436
72437 +#ifndef __read_only
72438 +#ifdef CONFIG_PAX_KERNEXEC
72439 +#error KERNEXEC requires __read_only
72440 +#else
72441 +#define __read_only __read_mostly
72442 +#endif
72443 +#endif
72444 +
72445 #ifndef ____cacheline_aligned
72446 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72447 #endif
72448 diff --git a/include/linux/capability.h b/include/linux/capability.h
72449 index d9a4f7f4..19f77d6 100644
72450 --- a/include/linux/capability.h
72451 +++ b/include/linux/capability.h
72452 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72453 extern bool nsown_capable(int cap);
72454 extern bool inode_capable(const struct inode *inode, int cap);
72455 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72456 +extern bool capable_nolog(int cap);
72457 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72458 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72459
72460 /* audit system wants to get cap info from files as well */
72461 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72462
72463 +extern int is_privileged_binary(const struct dentry *dentry);
72464 +
72465 #endif /* !_LINUX_CAPABILITY_H */
72466 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72467 index 8609d57..86e4d79 100644
72468 --- a/include/linux/cdrom.h
72469 +++ b/include/linux/cdrom.h
72470 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72471
72472 /* driver specifications */
72473 const int capability; /* capability flags */
72474 - int n_minors; /* number of active minor devices */
72475 /* handle uniform packets for scsi type devices (scsi,atapi) */
72476 int (*generic_packet) (struct cdrom_device_info *,
72477 struct packet_command *);
72478 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72479 index 4ce9056..86caac6 100644
72480 --- a/include/linux/cleancache.h
72481 +++ b/include/linux/cleancache.h
72482 @@ -31,7 +31,7 @@ struct cleancache_ops {
72483 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72484 void (*invalidate_inode)(int, struct cleancache_filekey);
72485 void (*invalidate_fs)(int);
72486 -};
72487 +} __no_const;
72488
72489 extern struct cleancache_ops *
72490 cleancache_register_ops(struct cleancache_ops *ops);
72491 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72492 index 1ec14a7..d0654a2 100644
72493 --- a/include/linux/clk-provider.h
72494 +++ b/include/linux/clk-provider.h
72495 @@ -132,6 +132,7 @@ struct clk_ops {
72496 unsigned long);
72497 void (*init)(struct clk_hw *hw);
72498 };
72499 +typedef struct clk_ops __no_const clk_ops_no_const;
72500
72501 /**
72502 * struct clk_init_data - holds init data that's common to all clocks and is
72503 diff --git a/include/linux/compat.h b/include/linux/compat.h
72504 index ec1aee4..1077986 100644
72505 --- a/include/linux/compat.h
72506 +++ b/include/linux/compat.h
72507 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72508 compat_size_t __user *len_ptr);
72509
72510 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72511 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72512 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72513 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72514 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72515 compat_ssize_t msgsz, int msgflg);
72516 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72517 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72518 compat_ulong_t addr, compat_ulong_t data);
72519 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72520 - compat_long_t addr, compat_long_t data);
72521 + compat_ulong_t addr, compat_ulong_t data);
72522
72523 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72524 /*
72525 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72526 index ded4299..da50e3b 100644
72527 --- a/include/linux/compiler-gcc4.h
72528 +++ b/include/linux/compiler-gcc4.h
72529 @@ -39,9 +39,29 @@
72530 # define __compiletime_warning(message) __attribute__((warning(message)))
72531 # define __compiletime_error(message) __attribute__((error(message)))
72532 #endif /* __CHECKER__ */
72533 +
72534 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72535 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72536 +#define __bos0(ptr) __bos((ptr), 0)
72537 +#define __bos1(ptr) __bos((ptr), 1)
72538 #endif /* GCC_VERSION >= 40300 */
72539
72540 #if GCC_VERSION >= 40500
72541 +
72542 +#ifdef CONSTIFY_PLUGIN
72543 +#define __no_const __attribute__((no_const))
72544 +#define __do_const __attribute__((do_const))
72545 +#endif
72546 +
72547 +#ifdef SIZE_OVERFLOW_PLUGIN
72548 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72549 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72550 +#endif
72551 +
72552 +#ifdef LATENT_ENTROPY_PLUGIN
72553 +#define __latent_entropy __attribute__((latent_entropy))
72554 +#endif
72555 +
72556 /*
72557 * Mark a position in code as unreachable. This can be used to
72558 * suppress control flow warnings after asm blocks that transfer
72559 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72560 index 92669cd..1771a15 100644
72561 --- a/include/linux/compiler.h
72562 +++ b/include/linux/compiler.h
72563 @@ -5,11 +5,14 @@
72564
72565 #ifdef __CHECKER__
72566 # define __user __attribute__((noderef, address_space(1)))
72567 +# define __force_user __force __user
72568 # define __kernel __attribute__((address_space(0)))
72569 +# define __force_kernel __force __kernel
72570 # define __safe __attribute__((safe))
72571 # define __force __attribute__((force))
72572 # define __nocast __attribute__((nocast))
72573 # define __iomem __attribute__((noderef, address_space(2)))
72574 +# define __force_iomem __force __iomem
72575 # define __must_hold(x) __attribute__((context(x,1,1)))
72576 # define __acquires(x) __attribute__((context(x,0,1)))
72577 # define __releases(x) __attribute__((context(x,1,0)))
72578 @@ -17,20 +20,37 @@
72579 # define __release(x) __context__(x,-1)
72580 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72581 # define __percpu __attribute__((noderef, address_space(3)))
72582 +# define __force_percpu __force __percpu
72583 #ifdef CONFIG_SPARSE_RCU_POINTER
72584 # define __rcu __attribute__((noderef, address_space(4)))
72585 +# define __force_rcu __force __rcu
72586 #else
72587 # define __rcu
72588 +# define __force_rcu
72589 #endif
72590 extern void __chk_user_ptr(const volatile void __user *);
72591 extern void __chk_io_ptr(const volatile void __iomem *);
72592 #else
72593 -# define __user
72594 -# define __kernel
72595 +# ifdef CHECKER_PLUGIN
72596 +//# define __user
72597 +//# define __force_user
72598 +//# define __kernel
72599 +//# define __force_kernel
72600 +# else
72601 +# ifdef STRUCTLEAK_PLUGIN
72602 +# define __user __attribute__((user))
72603 +# else
72604 +# define __user
72605 +# endif
72606 +# define __force_user
72607 +# define __kernel
72608 +# define __force_kernel
72609 +# endif
72610 # define __safe
72611 # define __force
72612 # define __nocast
72613 # define __iomem
72614 +# define __force_iomem
72615 # define __chk_user_ptr(x) (void)0
72616 # define __chk_io_ptr(x) (void)0
72617 # define __builtin_warning(x, y...) (1)
72618 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72619 # define __release(x) (void)0
72620 # define __cond_lock(x,c) (c)
72621 # define __percpu
72622 +# define __force_percpu
72623 # define __rcu
72624 +# define __force_rcu
72625 #endif
72626
72627 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72628 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72629 # define __attribute_const__ /* unimplemented */
72630 #endif
72631
72632 +#ifndef __no_const
72633 +# define __no_const
72634 +#endif
72635 +
72636 +#ifndef __do_const
72637 +# define __do_const
72638 +#endif
72639 +
72640 +#ifndef __size_overflow
72641 +# define __size_overflow(...)
72642 +#endif
72643 +
72644 +#ifndef __intentional_overflow
72645 +# define __intentional_overflow(...)
72646 +#endif
72647 +
72648 +#ifndef __latent_entropy
72649 +# define __latent_entropy
72650 +#endif
72651 +
72652 /*
72653 * Tell gcc if a function is cold. The compiler will assume any path
72654 * directly leading to the call is unlikely.
72655 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72656 #define __cold
72657 #endif
72658
72659 +#ifndef __alloc_size
72660 +#define __alloc_size(...)
72661 +#endif
72662 +
72663 +#ifndef __bos
72664 +#define __bos(ptr, arg)
72665 +#endif
72666 +
72667 +#ifndef __bos0
72668 +#define __bos0(ptr)
72669 +#endif
72670 +
72671 +#ifndef __bos1
72672 +#define __bos1(ptr)
72673 +#endif
72674 +
72675 /* Simple shorthand for a section definition */
72676 #ifndef __section
72677 # define __section(S) __attribute__ ((__section__(#S)))
72678 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72679 * use is to mediate communication between process-level code and irq/NMI
72680 * handlers, all running on the same CPU.
72681 */
72682 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72683 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72684 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72685
72686 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72687 #ifdef CONFIG_KPROBES
72688 diff --git a/include/linux/completion.h b/include/linux/completion.h
72689 index 3cd574d..adce5fa 100644
72690 --- a/include/linux/completion.h
72691 +++ b/include/linux/completion.h
72692 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72693 extern void wait_for_completion(struct completion *);
72694 extern void wait_for_completion_io(struct completion *);
72695 extern int wait_for_completion_interruptible(struct completion *x);
72696 -extern int wait_for_completion_killable(struct completion *x);
72697 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72698 extern unsigned long wait_for_completion_timeout(struct completion *x,
72699 unsigned long timeout);
72700 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72701 unsigned long timeout);
72702 extern long wait_for_completion_interruptible_timeout(
72703 - struct completion *x, unsigned long timeout);
72704 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72705 extern long wait_for_completion_killable_timeout(
72706 - struct completion *x, unsigned long timeout);
72707 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72708 extern bool try_wait_for_completion(struct completion *x);
72709 extern bool completion_done(struct completion *x);
72710
72711 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72712 index 34025df..d94bbbc 100644
72713 --- a/include/linux/configfs.h
72714 +++ b/include/linux/configfs.h
72715 @@ -125,7 +125,7 @@ struct configfs_attribute {
72716 const char *ca_name;
72717 struct module *ca_owner;
72718 umode_t ca_mode;
72719 -};
72720 +} __do_const;
72721
72722 /*
72723 * Users often need to create attribute structures for their configurable
72724 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72725 index 90d5a15..950cb80 100644
72726 --- a/include/linux/cpufreq.h
72727 +++ b/include/linux/cpufreq.h
72728 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72729 int (*suspend) (struct cpufreq_policy *policy);
72730 int (*resume) (struct cpufreq_policy *policy);
72731 struct freq_attr **attr;
72732 -};
72733 +} __do_const;
72734
72735 /* flags */
72736
72737 @@ -325,6 +325,7 @@ struct global_attr {
72738 ssize_t (*store)(struct kobject *a, struct attribute *b,
72739 const char *c, size_t count);
72740 };
72741 +typedef struct global_attr __no_const global_attr_no_const;
72742
72743 #define define_one_global_ro(_name) \
72744 static struct global_attr _name = \
72745 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72746 index 0bc4b74..973b368 100644
72747 --- a/include/linux/cpuidle.h
72748 +++ b/include/linux/cpuidle.h
72749 @@ -52,7 +52,8 @@ struct cpuidle_state {
72750 int index);
72751
72752 int (*enter_dead) (struct cpuidle_device *dev, int index);
72753 -};
72754 +} __do_const;
72755 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72756
72757 /* Idle State Flags */
72758 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72759 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72760 void (*reflect) (struct cpuidle_device *dev, int index);
72761
72762 struct module *owner;
72763 -};
72764 +} __do_const;
72765
72766 #ifdef CONFIG_CPU_IDLE
72767
72768 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72769 index d08e4d2..95fad61 100644
72770 --- a/include/linux/cpumask.h
72771 +++ b/include/linux/cpumask.h
72772 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72773 }
72774
72775 /* Valid inputs for n are -1 and 0. */
72776 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72777 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72778 {
72779 return n+1;
72780 }
72781
72782 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72783 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72784 {
72785 return n+1;
72786 }
72787
72788 -static inline unsigned int cpumask_next_and(int n,
72789 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72790 const struct cpumask *srcp,
72791 const struct cpumask *andp)
72792 {
72793 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72794 *
72795 * Returns >= nr_cpu_ids if no further cpus set.
72796 */
72797 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72798 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72799 {
72800 /* -1 is a legal arg here. */
72801 if (n != -1)
72802 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72803 *
72804 * Returns >= nr_cpu_ids if no further cpus unset.
72805 */
72806 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72807 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72808 {
72809 /* -1 is a legal arg here. */
72810 if (n != -1)
72811 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72812 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72813 }
72814
72815 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72816 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72817 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72818
72819 /**
72820 diff --git a/include/linux/cred.h b/include/linux/cred.h
72821 index 04421e8..6bce4ef 100644
72822 --- a/include/linux/cred.h
72823 +++ b/include/linux/cred.h
72824 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72825 static inline void validate_process_creds(void)
72826 {
72827 }
72828 +static inline void validate_task_creds(struct task_struct *task)
72829 +{
72830 +}
72831 #endif
72832
72833 /**
72834 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72835 index b92eadf..b4ecdc1 100644
72836 --- a/include/linux/crypto.h
72837 +++ b/include/linux/crypto.h
72838 @@ -373,7 +373,7 @@ struct cipher_tfm {
72839 const u8 *key, unsigned int keylen);
72840 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72841 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72842 -};
72843 +} __no_const;
72844
72845 struct hash_tfm {
72846 int (*init)(struct hash_desc *desc);
72847 @@ -394,13 +394,13 @@ struct compress_tfm {
72848 int (*cot_decompress)(struct crypto_tfm *tfm,
72849 const u8 *src, unsigned int slen,
72850 u8 *dst, unsigned int *dlen);
72851 -};
72852 +} __no_const;
72853
72854 struct rng_tfm {
72855 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72856 unsigned int dlen);
72857 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72858 -};
72859 +} __no_const;
72860
72861 #define crt_ablkcipher crt_u.ablkcipher
72862 #define crt_aead crt_u.aead
72863 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72864 index 653589e..4ef254a 100644
72865 --- a/include/linux/ctype.h
72866 +++ b/include/linux/ctype.h
72867 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72868 * Fast implementation of tolower() for internal usage. Do not use in your
72869 * code.
72870 */
72871 -static inline char _tolower(const char c)
72872 +static inline unsigned char _tolower(const unsigned char c)
72873 {
72874 return c | 0x20;
72875 }
72876 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72877 index 7925bf0..d5143d2 100644
72878 --- a/include/linux/decompress/mm.h
72879 +++ b/include/linux/decompress/mm.h
72880 @@ -77,7 +77,7 @@ static void free(void *where)
72881 * warnings when not needed (indeed large_malloc / large_free are not
72882 * needed by inflate */
72883
72884 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72885 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72886 #define free(a) kfree(a)
72887
72888 #define large_malloc(a) vmalloc(a)
72889 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72890 index 5f1ab92..39c35ae 100644
72891 --- a/include/linux/devfreq.h
72892 +++ b/include/linux/devfreq.h
72893 @@ -114,7 +114,7 @@ struct devfreq_governor {
72894 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72895 int (*event_handler)(struct devfreq *devfreq,
72896 unsigned int event, void *data);
72897 -};
72898 +} __do_const;
72899
72900 /**
72901 * struct devfreq - Device devfreq structure
72902 diff --git a/include/linux/device.h b/include/linux/device.h
72903 index 22b546a..a573dc9 100644
72904 --- a/include/linux/device.h
72905 +++ b/include/linux/device.h
72906 @@ -305,7 +305,7 @@ struct subsys_interface {
72907 struct list_head node;
72908 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72909 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72910 -};
72911 +} __do_const;
72912
72913 int subsys_interface_register(struct subsys_interface *sif);
72914 void subsys_interface_unregister(struct subsys_interface *sif);
72915 @@ -493,7 +493,7 @@ struct device_type {
72916 void (*release)(struct device *dev);
72917
72918 const struct dev_pm_ops *pm;
72919 -};
72920 +} __do_const;
72921
72922 /* interface for exporting device attributes */
72923 struct device_attribute {
72924 @@ -503,11 +503,12 @@ struct device_attribute {
72925 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72926 const char *buf, size_t count);
72927 };
72928 +typedef struct device_attribute __no_const device_attribute_no_const;
72929
72930 struct dev_ext_attribute {
72931 struct device_attribute attr;
72932 void *var;
72933 -};
72934 +} __do_const;
72935
72936 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72937 char *buf);
72938 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72939 index 94af418..b1ca7a2 100644
72940 --- a/include/linux/dma-mapping.h
72941 +++ b/include/linux/dma-mapping.h
72942 @@ -54,7 +54,7 @@ struct dma_map_ops {
72943 u64 (*get_required_mask)(struct device *dev);
72944 #endif
72945 int is_phys;
72946 -};
72947 +} __do_const;
72948
72949 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72950
72951 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72952 index cb286b1..923d066 100644
72953 --- a/include/linux/dmaengine.h
72954 +++ b/include/linux/dmaengine.h
72955 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72956 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72957 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72958
72959 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72960 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72961 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72962 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72963 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72964 struct dma_pinned_list *pinned_list, struct page *page,
72965 unsigned int offset, size_t len);
72966
72967 diff --git a/include/linux/efi.h b/include/linux/efi.h
72968 index 5f8f176..62a0556 100644
72969 --- a/include/linux/efi.h
72970 +++ b/include/linux/efi.h
72971 @@ -745,6 +745,7 @@ struct efivar_operations {
72972 efi_set_variable_t *set_variable;
72973 efi_query_variable_store_t *query_variable_store;
72974 };
72975 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72976
72977 struct efivars {
72978 /*
72979 diff --git a/include/linux/elf.h b/include/linux/elf.h
72980 index 40a3c0e..4c45a38 100644
72981 --- a/include/linux/elf.h
72982 +++ b/include/linux/elf.h
72983 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72984 #define elf_note elf32_note
72985 #define elf_addr_t Elf32_Off
72986 #define Elf_Half Elf32_Half
72987 +#define elf_dyn Elf32_Dyn
72988
72989 #else
72990
72991 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72992 #define elf_note elf64_note
72993 #define elf_addr_t Elf64_Off
72994 #define Elf_Half Elf64_Half
72995 +#define elf_dyn Elf64_Dyn
72996
72997 #endif
72998
72999 diff --git a/include/linux/err.h b/include/linux/err.h
73000 index 221fcfb..f29e5e2 100644
73001 --- a/include/linux/err.h
73002 +++ b/include/linux/err.h
73003 @@ -19,12 +19,12 @@
73004
73005 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
73006
73007 -static inline void * __must_check ERR_PTR(long error)
73008 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73009 {
73010 return (void *) error;
73011 }
73012
73013 -static inline long __must_check PTR_ERR(__force const void *ptr)
73014 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73015 {
73016 return (long) ptr;
73017 }
73018 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73019 index fcb51c8..bdafcf6 100644
73020 --- a/include/linux/extcon.h
73021 +++ b/include/linux/extcon.h
73022 @@ -134,7 +134,7 @@ struct extcon_dev {
73023 /* /sys/class/extcon/.../mutually_exclusive/... */
73024 struct attribute_group attr_g_muex;
73025 struct attribute **attrs_muex;
73026 - struct device_attribute *d_attrs_muex;
73027 + device_attribute_no_const *d_attrs_muex;
73028 };
73029
73030 /**
73031 diff --git a/include/linux/fb.h b/include/linux/fb.h
73032 index ffac70a..ca3e711 100644
73033 --- a/include/linux/fb.h
73034 +++ b/include/linux/fb.h
73035 @@ -304,7 +304,7 @@ struct fb_ops {
73036 /* called at KDB enter and leave time to prepare the console */
73037 int (*fb_debug_enter)(struct fb_info *info);
73038 int (*fb_debug_leave)(struct fb_info *info);
73039 -};
73040 +} __do_const;
73041
73042 #ifdef CONFIG_FB_TILEBLITTING
73043 #define FB_TILE_CURSOR_NONE 0
73044 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73045 index 085197b..0fa6f0b 100644
73046 --- a/include/linux/fdtable.h
73047 +++ b/include/linux/fdtable.h
73048 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73049 void put_files_struct(struct files_struct *fs);
73050 void reset_files_struct(struct files_struct *);
73051 int unshare_files(struct files_struct **);
73052 -struct files_struct *dup_fd(struct files_struct *, int *);
73053 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73054 void do_close_on_exec(struct files_struct *);
73055 int iterate_fd(struct files_struct *, unsigned,
73056 int (*)(const void *, struct file *, unsigned),
73057 diff --git a/include/linux/filter.h b/include/linux/filter.h
73058 index a6ac848..a104a76 100644
73059 --- a/include/linux/filter.h
73060 +++ b/include/linux/filter.h
73061 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
73062
73063 struct sk_buff;
73064 struct sock;
73065 +struct bpf_jit_work;
73066
73067 struct sk_filter
73068 {
73069 @@ -27,6 +28,9 @@ struct sk_filter
73070 unsigned int len; /* Number of filter blocks */
73071 unsigned int (*bpf_func)(const struct sk_buff *skb,
73072 const struct sock_filter *filter);
73073 +#ifdef CONFIG_BPF_JIT
73074 + struct bpf_jit_work *work;
73075 +#endif
73076 struct rcu_head rcu;
73077 struct sock_filter insns[0];
73078 };
73079 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73080 index 8293262..2b3b8bd 100644
73081 --- a/include/linux/frontswap.h
73082 +++ b/include/linux/frontswap.h
73083 @@ -11,7 +11,7 @@ struct frontswap_ops {
73084 int (*load)(unsigned, pgoff_t, struct page *);
73085 void (*invalidate_page)(unsigned, pgoff_t);
73086 void (*invalidate_area)(unsigned);
73087 -};
73088 +} __no_const;
73089
73090 extern bool frontswap_enabled;
73091 extern struct frontswap_ops *
73092 diff --git a/include/linux/fs.h b/include/linux/fs.h
73093 index 9818747..788bfbd 100644
73094 --- a/include/linux/fs.h
73095 +++ b/include/linux/fs.h
73096 @@ -1554,7 +1554,8 @@ struct file_operations {
73097 long (*fallocate)(struct file *file, int mode, loff_t offset,
73098 loff_t len);
73099 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73100 -};
73101 +} __do_const;
73102 +typedef struct file_operations __no_const file_operations_no_const;
73103
73104 struct inode_operations {
73105 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73106 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73107 return !IS_DEADDIR(inode);
73108 }
73109
73110 +static inline bool is_sidechannel_device(const struct inode *inode)
73111 +{
73112 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73113 + umode_t mode = inode->i_mode;
73114 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73115 +#else
73116 + return false;
73117 +#endif
73118 +}
73119 +
73120 #endif /* _LINUX_FS_H */
73121 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73122 index 2b93a9a..855d94a 100644
73123 --- a/include/linux/fs_struct.h
73124 +++ b/include/linux/fs_struct.h
73125 @@ -6,7 +6,7 @@
73126 #include <linux/seqlock.h>
73127
73128 struct fs_struct {
73129 - int users;
73130 + atomic_t users;
73131 spinlock_t lock;
73132 seqcount_t seq;
73133 int umask;
73134 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73135 index a9ff9a3..1ba1788 100644
73136 --- a/include/linux/fscache-cache.h
73137 +++ b/include/linux/fscache-cache.h
73138 @@ -113,7 +113,7 @@ struct fscache_operation {
73139 fscache_operation_release_t release;
73140 };
73141
73142 -extern atomic_t fscache_op_debug_id;
73143 +extern atomic_unchecked_t fscache_op_debug_id;
73144 extern void fscache_op_work_func(struct work_struct *work);
73145
73146 extern void fscache_enqueue_operation(struct fscache_operation *);
73147 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73148 INIT_WORK(&op->work, fscache_op_work_func);
73149 atomic_set(&op->usage, 1);
73150 op->state = FSCACHE_OP_ST_INITIALISED;
73151 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73152 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73153 op->processor = processor;
73154 op->release = release;
73155 INIT_LIST_HEAD(&op->pend_link);
73156 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73157 index 7a08623..4c07b0f 100644
73158 --- a/include/linux/fscache.h
73159 +++ b/include/linux/fscache.h
73160 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73161 * - this is mandatory for any object that may have data
73162 */
73163 void (*now_uncached)(void *cookie_netfs_data);
73164 -};
73165 +} __do_const;
73166
73167 /*
73168 * fscache cached network filesystem type
73169 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73170 index 1c804b0..1432c2b 100644
73171 --- a/include/linux/fsnotify.h
73172 +++ b/include/linux/fsnotify.h
73173 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73174 struct inode *inode = file_inode(file);
73175 __u32 mask = FS_ACCESS;
73176
73177 + if (is_sidechannel_device(inode))
73178 + return;
73179 +
73180 if (S_ISDIR(inode->i_mode))
73181 mask |= FS_ISDIR;
73182
73183 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73184 struct inode *inode = file_inode(file);
73185 __u32 mask = FS_MODIFY;
73186
73187 + if (is_sidechannel_device(inode))
73188 + return;
73189 +
73190 if (S_ISDIR(inode->i_mode))
73191 mask |= FS_ISDIR;
73192
73193 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73194 */
73195 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73196 {
73197 - return kstrdup(name, GFP_KERNEL);
73198 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73199 }
73200
73201 /*
73202 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73203 index 9f3c275..8bdff5d 100644
73204 --- a/include/linux/genhd.h
73205 +++ b/include/linux/genhd.h
73206 @@ -194,7 +194,7 @@ struct gendisk {
73207 struct kobject *slave_dir;
73208
73209 struct timer_rand_state *random;
73210 - atomic_t sync_io; /* RAID */
73211 + atomic_unchecked_t sync_io; /* RAID */
73212 struct disk_events *ev;
73213 #ifdef CONFIG_BLK_DEV_INTEGRITY
73214 struct blk_integrity *integrity;
73215 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73216 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73217
73218 /* drivers/char/random.c */
73219 -extern void add_disk_randomness(struct gendisk *disk);
73220 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73221 extern void rand_initialize_disk(struct gendisk *disk);
73222
73223 static inline sector_t get_start_sect(struct block_device *bdev)
73224 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73225 index 023bc34..b02b46a 100644
73226 --- a/include/linux/genl_magic_func.h
73227 +++ b/include/linux/genl_magic_func.h
73228 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73229 },
73230
73231 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73232 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73233 +static struct genl_ops ZZZ_genl_ops[] = {
73234 #include GENL_MAGIC_INCLUDE_FILE
73235 };
73236
73237 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73238 index 9b4dd49..61fd41d 100644
73239 --- a/include/linux/gfp.h
73240 +++ b/include/linux/gfp.h
73241 @@ -35,6 +35,13 @@ struct vm_area_struct;
73242 #define ___GFP_NO_KSWAPD 0x400000u
73243 #define ___GFP_OTHER_NODE 0x800000u
73244 #define ___GFP_WRITE 0x1000000u
73245 +
73246 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73247 +#define ___GFP_USERCOPY 0x2000000u
73248 +#else
73249 +#define ___GFP_USERCOPY 0
73250 +#endif
73251 +
73252 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73253
73254 /*
73255 @@ -92,6 +99,7 @@ struct vm_area_struct;
73256 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73257 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73258 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73259 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73260
73261 /*
73262 * This may seem redundant, but it's a way of annotating false positives vs.
73263 @@ -99,7 +107,7 @@ struct vm_area_struct;
73264 */
73265 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73266
73267 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73268 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73269 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73270
73271 /* This equals 0, but use constants in case they ever change */
73272 @@ -153,6 +161,8 @@ struct vm_area_struct;
73273 /* 4GB DMA on some platforms */
73274 #define GFP_DMA32 __GFP_DMA32
73275
73276 +#define GFP_USERCOPY __GFP_USERCOPY
73277 +
73278 /* Convert GFP flags to their corresponding migrate type */
73279 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73280 {
73281 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73282 new file mode 100644
73283 index 0000000..ebe6d72
73284 --- /dev/null
73285 +++ b/include/linux/gracl.h
73286 @@ -0,0 +1,319 @@
73287 +#ifndef GR_ACL_H
73288 +#define GR_ACL_H
73289 +
73290 +#include <linux/grdefs.h>
73291 +#include <linux/resource.h>
73292 +#include <linux/capability.h>
73293 +#include <linux/dcache.h>
73294 +#include <asm/resource.h>
73295 +
73296 +/* Major status information */
73297 +
73298 +#define GR_VERSION "grsecurity 2.9.1"
73299 +#define GRSECURITY_VERSION 0x2901
73300 +
73301 +enum {
73302 + GR_SHUTDOWN = 0,
73303 + GR_ENABLE = 1,
73304 + GR_SPROLE = 2,
73305 + GR_RELOAD = 3,
73306 + GR_SEGVMOD = 4,
73307 + GR_STATUS = 5,
73308 + GR_UNSPROLE = 6,
73309 + GR_PASSSET = 7,
73310 + GR_SPROLEPAM = 8,
73311 +};
73312 +
73313 +/* Password setup definitions
73314 + * kernel/grhash.c */
73315 +enum {
73316 + GR_PW_LEN = 128,
73317 + GR_SALT_LEN = 16,
73318 + GR_SHA_LEN = 32,
73319 +};
73320 +
73321 +enum {
73322 + GR_SPROLE_LEN = 64,
73323 +};
73324 +
73325 +enum {
73326 + GR_NO_GLOB = 0,
73327 + GR_REG_GLOB,
73328 + GR_CREATE_GLOB
73329 +};
73330 +
73331 +#define GR_NLIMITS 32
73332 +
73333 +/* Begin Data Structures */
73334 +
73335 +struct sprole_pw {
73336 + unsigned char *rolename;
73337 + unsigned char salt[GR_SALT_LEN];
73338 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73339 +};
73340 +
73341 +struct name_entry {
73342 + __u32 key;
73343 + ino_t inode;
73344 + dev_t device;
73345 + char *name;
73346 + __u16 len;
73347 + __u8 deleted;
73348 + struct name_entry *prev;
73349 + struct name_entry *next;
73350 +};
73351 +
73352 +struct inodev_entry {
73353 + struct name_entry *nentry;
73354 + struct inodev_entry *prev;
73355 + struct inodev_entry *next;
73356 +};
73357 +
73358 +struct acl_role_db {
73359 + struct acl_role_label **r_hash;
73360 + __u32 r_size;
73361 +};
73362 +
73363 +struct inodev_db {
73364 + struct inodev_entry **i_hash;
73365 + __u32 i_size;
73366 +};
73367 +
73368 +struct name_db {
73369 + struct name_entry **n_hash;
73370 + __u32 n_size;
73371 +};
73372 +
73373 +struct crash_uid {
73374 + uid_t uid;
73375 + unsigned long expires;
73376 +};
73377 +
73378 +struct gr_hash_struct {
73379 + void **table;
73380 + void **nametable;
73381 + void *first;
73382 + __u32 table_size;
73383 + __u32 used_size;
73384 + int type;
73385 +};
73386 +
73387 +/* Userspace Grsecurity ACL data structures */
73388 +
73389 +struct acl_subject_label {
73390 + char *filename;
73391 + ino_t inode;
73392 + dev_t device;
73393 + __u32 mode;
73394 + kernel_cap_t cap_mask;
73395 + kernel_cap_t cap_lower;
73396 + kernel_cap_t cap_invert_audit;
73397 +
73398 + struct rlimit res[GR_NLIMITS];
73399 + __u32 resmask;
73400 +
73401 + __u8 user_trans_type;
73402 + __u8 group_trans_type;
73403 + uid_t *user_transitions;
73404 + gid_t *group_transitions;
73405 + __u16 user_trans_num;
73406 + __u16 group_trans_num;
73407 +
73408 + __u32 sock_families[2];
73409 + __u32 ip_proto[8];
73410 + __u32 ip_type;
73411 + struct acl_ip_label **ips;
73412 + __u32 ip_num;
73413 + __u32 inaddr_any_override;
73414 +
73415 + __u32 crashes;
73416 + unsigned long expires;
73417 +
73418 + struct acl_subject_label *parent_subject;
73419 + struct gr_hash_struct *hash;
73420 + struct acl_subject_label *prev;
73421 + struct acl_subject_label *next;
73422 +
73423 + struct acl_object_label **obj_hash;
73424 + __u32 obj_hash_size;
73425 + __u16 pax_flags;
73426 +};
73427 +
73428 +struct role_allowed_ip {
73429 + __u32 addr;
73430 + __u32 netmask;
73431 +
73432 + struct role_allowed_ip *prev;
73433 + struct role_allowed_ip *next;
73434 +};
73435 +
73436 +struct role_transition {
73437 + char *rolename;
73438 +
73439 + struct role_transition *prev;
73440 + struct role_transition *next;
73441 +};
73442 +
73443 +struct acl_role_label {
73444 + char *rolename;
73445 + uid_t uidgid;
73446 + __u16 roletype;
73447 +
73448 + __u16 auth_attempts;
73449 + unsigned long expires;
73450 +
73451 + struct acl_subject_label *root_label;
73452 + struct gr_hash_struct *hash;
73453 +
73454 + struct acl_role_label *prev;
73455 + struct acl_role_label *next;
73456 +
73457 + struct role_transition *transitions;
73458 + struct role_allowed_ip *allowed_ips;
73459 + uid_t *domain_children;
73460 + __u16 domain_child_num;
73461 +
73462 + umode_t umask;
73463 +
73464 + struct acl_subject_label **subj_hash;
73465 + __u32 subj_hash_size;
73466 +};
73467 +
73468 +struct user_acl_role_db {
73469 + struct acl_role_label **r_table;
73470 + __u32 num_pointers; /* Number of allocations to track */
73471 + __u32 num_roles; /* Number of roles */
73472 + __u32 num_domain_children; /* Number of domain children */
73473 + __u32 num_subjects; /* Number of subjects */
73474 + __u32 num_objects; /* Number of objects */
73475 +};
73476 +
73477 +struct acl_object_label {
73478 + char *filename;
73479 + ino_t inode;
73480 + dev_t device;
73481 + __u32 mode;
73482 +
73483 + struct acl_subject_label *nested;
73484 + struct acl_object_label *globbed;
73485 +
73486 + /* next two structures not used */
73487 +
73488 + struct acl_object_label *prev;
73489 + struct acl_object_label *next;
73490 +};
73491 +
73492 +struct acl_ip_label {
73493 + char *iface;
73494 + __u32 addr;
73495 + __u32 netmask;
73496 + __u16 low, high;
73497 + __u8 mode;
73498 + __u32 type;
73499 + __u32 proto[8];
73500 +
73501 + /* next two structures not used */
73502 +
73503 + struct acl_ip_label *prev;
73504 + struct acl_ip_label *next;
73505 +};
73506 +
73507 +struct gr_arg {
73508 + struct user_acl_role_db role_db;
73509 + unsigned char pw[GR_PW_LEN];
73510 + unsigned char salt[GR_SALT_LEN];
73511 + unsigned char sum[GR_SHA_LEN];
73512 + unsigned char sp_role[GR_SPROLE_LEN];
73513 + struct sprole_pw *sprole_pws;
73514 + dev_t segv_device;
73515 + ino_t segv_inode;
73516 + uid_t segv_uid;
73517 + __u16 num_sprole_pws;
73518 + __u16 mode;
73519 +};
73520 +
73521 +struct gr_arg_wrapper {
73522 + struct gr_arg *arg;
73523 + __u32 version;
73524 + __u32 size;
73525 +};
73526 +
73527 +struct subject_map {
73528 + struct acl_subject_label *user;
73529 + struct acl_subject_label *kernel;
73530 + struct subject_map *prev;
73531 + struct subject_map *next;
73532 +};
73533 +
73534 +struct acl_subj_map_db {
73535 + struct subject_map **s_hash;
73536 + __u32 s_size;
73537 +};
73538 +
73539 +/* End Data Structures Section */
73540 +
73541 +/* Hash functions generated by empirical testing by Brad Spengler
73542 + Makes good use of the low bits of the inode. Generally 0-1 times
73543 + in loop for successful match. 0-3 for unsuccessful match.
73544 + Shift/add algorithm with modulus of table size and an XOR*/
73545 +
73546 +static __inline__ unsigned int
73547 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73548 +{
73549 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73550 +}
73551 +
73552 + static __inline__ unsigned int
73553 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73554 +{
73555 + return ((const unsigned long)userp % sz);
73556 +}
73557 +
73558 +static __inline__ unsigned int
73559 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73560 +{
73561 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73562 +}
73563 +
73564 +static __inline__ unsigned int
73565 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73566 +{
73567 + return full_name_hash((const unsigned char *)name, len) % sz;
73568 +}
73569 +
73570 +#define FOR_EACH_ROLE_START(role) \
73571 + role = role_list; \
73572 + while (role) {
73573 +
73574 +#define FOR_EACH_ROLE_END(role) \
73575 + role = role->prev; \
73576 + }
73577 +
73578 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73579 + subj = NULL; \
73580 + iter = 0; \
73581 + while (iter < role->subj_hash_size) { \
73582 + if (subj == NULL) \
73583 + subj = role->subj_hash[iter]; \
73584 + if (subj == NULL) { \
73585 + iter++; \
73586 + continue; \
73587 + }
73588 +
73589 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73590 + subj = subj->next; \
73591 + if (subj == NULL) \
73592 + iter++; \
73593 + }
73594 +
73595 +
73596 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73597 + subj = role->hash->first; \
73598 + while (subj != NULL) {
73599 +
73600 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73601 + subj = subj->next; \
73602 + }
73603 +
73604 +#endif
73605 +
73606 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73607 new file mode 100644
73608 index 0000000..33ebd1f
73609 --- /dev/null
73610 +++ b/include/linux/gracl_compat.h
73611 @@ -0,0 +1,156 @@
73612 +#ifndef GR_ACL_COMPAT_H
73613 +#define GR_ACL_COMPAT_H
73614 +
73615 +#include <linux/resource.h>
73616 +#include <asm/resource.h>
73617 +
73618 +struct sprole_pw_compat {
73619 + compat_uptr_t rolename;
73620 + unsigned char salt[GR_SALT_LEN];
73621 + unsigned char sum[GR_SHA_LEN];
73622 +};
73623 +
73624 +struct gr_hash_struct_compat {
73625 + compat_uptr_t table;
73626 + compat_uptr_t nametable;
73627 + compat_uptr_t first;
73628 + __u32 table_size;
73629 + __u32 used_size;
73630 + int type;
73631 +};
73632 +
73633 +struct acl_subject_label_compat {
73634 + compat_uptr_t filename;
73635 + compat_ino_t inode;
73636 + __u32 device;
73637 + __u32 mode;
73638 + kernel_cap_t cap_mask;
73639 + kernel_cap_t cap_lower;
73640 + kernel_cap_t cap_invert_audit;
73641 +
73642 + struct compat_rlimit res[GR_NLIMITS];
73643 + __u32 resmask;
73644 +
73645 + __u8 user_trans_type;
73646 + __u8 group_trans_type;
73647 + compat_uptr_t user_transitions;
73648 + compat_uptr_t group_transitions;
73649 + __u16 user_trans_num;
73650 + __u16 group_trans_num;
73651 +
73652 + __u32 sock_families[2];
73653 + __u32 ip_proto[8];
73654 + __u32 ip_type;
73655 + compat_uptr_t ips;
73656 + __u32 ip_num;
73657 + __u32 inaddr_any_override;
73658 +
73659 + __u32 crashes;
73660 + compat_ulong_t expires;
73661 +
73662 + compat_uptr_t parent_subject;
73663 + compat_uptr_t hash;
73664 + compat_uptr_t prev;
73665 + compat_uptr_t next;
73666 +
73667 + compat_uptr_t obj_hash;
73668 + __u32 obj_hash_size;
73669 + __u16 pax_flags;
73670 +};
73671 +
73672 +struct role_allowed_ip_compat {
73673 + __u32 addr;
73674 + __u32 netmask;
73675 +
73676 + compat_uptr_t prev;
73677 + compat_uptr_t next;
73678 +};
73679 +
73680 +struct role_transition_compat {
73681 + compat_uptr_t rolename;
73682 +
73683 + compat_uptr_t prev;
73684 + compat_uptr_t next;
73685 +};
73686 +
73687 +struct acl_role_label_compat {
73688 + compat_uptr_t rolename;
73689 + uid_t uidgid;
73690 + __u16 roletype;
73691 +
73692 + __u16 auth_attempts;
73693 + compat_ulong_t expires;
73694 +
73695 + compat_uptr_t root_label;
73696 + compat_uptr_t hash;
73697 +
73698 + compat_uptr_t prev;
73699 + compat_uptr_t next;
73700 +
73701 + compat_uptr_t transitions;
73702 + compat_uptr_t allowed_ips;
73703 + compat_uptr_t domain_children;
73704 + __u16 domain_child_num;
73705 +
73706 + umode_t umask;
73707 +
73708 + compat_uptr_t subj_hash;
73709 + __u32 subj_hash_size;
73710 +};
73711 +
73712 +struct user_acl_role_db_compat {
73713 + compat_uptr_t r_table;
73714 + __u32 num_pointers;
73715 + __u32 num_roles;
73716 + __u32 num_domain_children;
73717 + __u32 num_subjects;
73718 + __u32 num_objects;
73719 +};
73720 +
73721 +struct acl_object_label_compat {
73722 + compat_uptr_t filename;
73723 + compat_ino_t inode;
73724 + __u32 device;
73725 + __u32 mode;
73726 +
73727 + compat_uptr_t nested;
73728 + compat_uptr_t globbed;
73729 +
73730 + compat_uptr_t prev;
73731 + compat_uptr_t next;
73732 +};
73733 +
73734 +struct acl_ip_label_compat {
73735 + compat_uptr_t iface;
73736 + __u32 addr;
73737 + __u32 netmask;
73738 + __u16 low, high;
73739 + __u8 mode;
73740 + __u32 type;
73741 + __u32 proto[8];
73742 +
73743 + compat_uptr_t prev;
73744 + compat_uptr_t next;
73745 +};
73746 +
73747 +struct gr_arg_compat {
73748 + struct user_acl_role_db_compat role_db;
73749 + unsigned char pw[GR_PW_LEN];
73750 + unsigned char salt[GR_SALT_LEN];
73751 + unsigned char sum[GR_SHA_LEN];
73752 + unsigned char sp_role[GR_SPROLE_LEN];
73753 + compat_uptr_t sprole_pws;
73754 + __u32 segv_device;
73755 + compat_ino_t segv_inode;
73756 + uid_t segv_uid;
73757 + __u16 num_sprole_pws;
73758 + __u16 mode;
73759 +};
73760 +
73761 +struct gr_arg_wrapper_compat {
73762 + compat_uptr_t arg;
73763 + __u32 version;
73764 + __u32 size;
73765 +};
73766 +
73767 +#endif
73768 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73769 new file mode 100644
73770 index 0000000..323ecf2
73771 --- /dev/null
73772 +++ b/include/linux/gralloc.h
73773 @@ -0,0 +1,9 @@
73774 +#ifndef __GRALLOC_H
73775 +#define __GRALLOC_H
73776 +
73777 +void acl_free_all(void);
73778 +int acl_alloc_stack_init(unsigned long size);
73779 +void *acl_alloc(unsigned long len);
73780 +void *acl_alloc_num(unsigned long num, unsigned long len);
73781 +
73782 +#endif
73783 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73784 new file mode 100644
73785 index 0000000..be66033
73786 --- /dev/null
73787 +++ b/include/linux/grdefs.h
73788 @@ -0,0 +1,140 @@
73789 +#ifndef GRDEFS_H
73790 +#define GRDEFS_H
73791 +
73792 +/* Begin grsecurity status declarations */
73793 +
73794 +enum {
73795 + GR_READY = 0x01,
73796 + GR_STATUS_INIT = 0x00 // disabled state
73797 +};
73798 +
73799 +/* Begin ACL declarations */
73800 +
73801 +/* Role flags */
73802 +
73803 +enum {
73804 + GR_ROLE_USER = 0x0001,
73805 + GR_ROLE_GROUP = 0x0002,
73806 + GR_ROLE_DEFAULT = 0x0004,
73807 + GR_ROLE_SPECIAL = 0x0008,
73808 + GR_ROLE_AUTH = 0x0010,
73809 + GR_ROLE_NOPW = 0x0020,
73810 + GR_ROLE_GOD = 0x0040,
73811 + GR_ROLE_LEARN = 0x0080,
73812 + GR_ROLE_TPE = 0x0100,
73813 + GR_ROLE_DOMAIN = 0x0200,
73814 + GR_ROLE_PAM = 0x0400,
73815 + GR_ROLE_PERSIST = 0x0800
73816 +};
73817 +
73818 +/* ACL Subject and Object mode flags */
73819 +enum {
73820 + GR_DELETED = 0x80000000
73821 +};
73822 +
73823 +/* ACL Object-only mode flags */
73824 +enum {
73825 + GR_READ = 0x00000001,
73826 + GR_APPEND = 0x00000002,
73827 + GR_WRITE = 0x00000004,
73828 + GR_EXEC = 0x00000008,
73829 + GR_FIND = 0x00000010,
73830 + GR_INHERIT = 0x00000020,
73831 + GR_SETID = 0x00000040,
73832 + GR_CREATE = 0x00000080,
73833 + GR_DELETE = 0x00000100,
73834 + GR_LINK = 0x00000200,
73835 + GR_AUDIT_READ = 0x00000400,
73836 + GR_AUDIT_APPEND = 0x00000800,
73837 + GR_AUDIT_WRITE = 0x00001000,
73838 + GR_AUDIT_EXEC = 0x00002000,
73839 + GR_AUDIT_FIND = 0x00004000,
73840 + GR_AUDIT_INHERIT= 0x00008000,
73841 + GR_AUDIT_SETID = 0x00010000,
73842 + GR_AUDIT_CREATE = 0x00020000,
73843 + GR_AUDIT_DELETE = 0x00040000,
73844 + GR_AUDIT_LINK = 0x00080000,
73845 + GR_PTRACERD = 0x00100000,
73846 + GR_NOPTRACE = 0x00200000,
73847 + GR_SUPPRESS = 0x00400000,
73848 + GR_NOLEARN = 0x00800000,
73849 + GR_INIT_TRANSFER= 0x01000000
73850 +};
73851 +
73852 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73853 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73854 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73855 +
73856 +/* ACL subject-only mode flags */
73857 +enum {
73858 + GR_KILL = 0x00000001,
73859 + GR_VIEW = 0x00000002,
73860 + GR_PROTECTED = 0x00000004,
73861 + GR_LEARN = 0x00000008,
73862 + GR_OVERRIDE = 0x00000010,
73863 + /* just a placeholder, this mode is only used in userspace */
73864 + GR_DUMMY = 0x00000020,
73865 + GR_PROTSHM = 0x00000040,
73866 + GR_KILLPROC = 0x00000080,
73867 + GR_KILLIPPROC = 0x00000100,
73868 + /* just a placeholder, this mode is only used in userspace */
73869 + GR_NOTROJAN = 0x00000200,
73870 + GR_PROTPROCFD = 0x00000400,
73871 + GR_PROCACCT = 0x00000800,
73872 + GR_RELAXPTRACE = 0x00001000,
73873 + //GR_NESTED = 0x00002000,
73874 + GR_INHERITLEARN = 0x00004000,
73875 + GR_PROCFIND = 0x00008000,
73876 + GR_POVERRIDE = 0x00010000,
73877 + GR_KERNELAUTH = 0x00020000,
73878 + GR_ATSECURE = 0x00040000,
73879 + GR_SHMEXEC = 0x00080000
73880 +};
73881 +
73882 +enum {
73883 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73884 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73885 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73886 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73887 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73888 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73889 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73890 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73891 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73892 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73893 +};
73894 +
73895 +enum {
73896 + GR_ID_USER = 0x01,
73897 + GR_ID_GROUP = 0x02,
73898 +};
73899 +
73900 +enum {
73901 + GR_ID_ALLOW = 0x01,
73902 + GR_ID_DENY = 0x02,
73903 +};
73904 +
73905 +#define GR_CRASH_RES 31
73906 +#define GR_UIDTABLE_MAX 500
73907 +
73908 +/* begin resource learning section */
73909 +enum {
73910 + GR_RLIM_CPU_BUMP = 60,
73911 + GR_RLIM_FSIZE_BUMP = 50000,
73912 + GR_RLIM_DATA_BUMP = 10000,
73913 + GR_RLIM_STACK_BUMP = 1000,
73914 + GR_RLIM_CORE_BUMP = 10000,
73915 + GR_RLIM_RSS_BUMP = 500000,
73916 + GR_RLIM_NPROC_BUMP = 1,
73917 + GR_RLIM_NOFILE_BUMP = 5,
73918 + GR_RLIM_MEMLOCK_BUMP = 50000,
73919 + GR_RLIM_AS_BUMP = 500000,
73920 + GR_RLIM_LOCKS_BUMP = 2,
73921 + GR_RLIM_SIGPENDING_BUMP = 5,
73922 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73923 + GR_RLIM_NICE_BUMP = 1,
73924 + GR_RLIM_RTPRIO_BUMP = 1,
73925 + GR_RLIM_RTTIME_BUMP = 1000000
73926 +};
73927 +
73928 +#endif
73929 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73930 new file mode 100644
73931 index 0000000..e337683
73932 --- /dev/null
73933 +++ b/include/linux/grinternal.h
73934 @@ -0,0 +1,229 @@
73935 +#ifndef __GRINTERNAL_H
73936 +#define __GRINTERNAL_H
73937 +
73938 +#ifdef CONFIG_GRKERNSEC
73939 +
73940 +#include <linux/fs.h>
73941 +#include <linux/mnt_namespace.h>
73942 +#include <linux/nsproxy.h>
73943 +#include <linux/gracl.h>
73944 +#include <linux/grdefs.h>
73945 +#include <linux/grmsg.h>
73946 +
73947 +void gr_add_learn_entry(const char *fmt, ...)
73948 + __attribute__ ((format (printf, 1, 2)));
73949 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73950 + const struct vfsmount *mnt);
73951 +__u32 gr_check_create(const struct dentry *new_dentry,
73952 + const struct dentry *parent,
73953 + const struct vfsmount *mnt, const __u32 mode);
73954 +int gr_check_protected_task(const struct task_struct *task);
73955 +__u32 to_gr_audit(const __u32 reqmode);
73956 +int gr_set_acls(const int type);
73957 +int gr_apply_subject_to_task(struct task_struct *task);
73958 +int gr_acl_is_enabled(void);
73959 +char gr_roletype_to_char(void);
73960 +
73961 +void gr_handle_alertkill(struct task_struct *task);
73962 +char *gr_to_filename(const struct dentry *dentry,
73963 + const struct vfsmount *mnt);
73964 +char *gr_to_filename1(const struct dentry *dentry,
73965 + const struct vfsmount *mnt);
73966 +char *gr_to_filename2(const struct dentry *dentry,
73967 + const struct vfsmount *mnt);
73968 +char *gr_to_filename3(const struct dentry *dentry,
73969 + const struct vfsmount *mnt);
73970 +
73971 +extern int grsec_enable_ptrace_readexec;
73972 +extern int grsec_enable_harden_ptrace;
73973 +extern int grsec_enable_link;
73974 +extern int grsec_enable_fifo;
73975 +extern int grsec_enable_execve;
73976 +extern int grsec_enable_shm;
73977 +extern int grsec_enable_execlog;
73978 +extern int grsec_enable_signal;
73979 +extern int grsec_enable_audit_ptrace;
73980 +extern int grsec_enable_forkfail;
73981 +extern int grsec_enable_time;
73982 +extern int grsec_enable_rofs;
73983 +extern int grsec_deny_new_usb;
73984 +extern int grsec_enable_chroot_shmat;
73985 +extern int grsec_enable_chroot_mount;
73986 +extern int grsec_enable_chroot_double;
73987 +extern int grsec_enable_chroot_pivot;
73988 +extern int grsec_enable_chroot_chdir;
73989 +extern int grsec_enable_chroot_chmod;
73990 +extern int grsec_enable_chroot_mknod;
73991 +extern int grsec_enable_chroot_fchdir;
73992 +extern int grsec_enable_chroot_nice;
73993 +extern int grsec_enable_chroot_execlog;
73994 +extern int grsec_enable_chroot_caps;
73995 +extern int grsec_enable_chroot_sysctl;
73996 +extern int grsec_enable_chroot_unix;
73997 +extern int grsec_enable_symlinkown;
73998 +extern kgid_t grsec_symlinkown_gid;
73999 +extern int grsec_enable_tpe;
74000 +extern kgid_t grsec_tpe_gid;
74001 +extern int grsec_enable_tpe_all;
74002 +extern int grsec_enable_tpe_invert;
74003 +extern int grsec_enable_socket_all;
74004 +extern kgid_t grsec_socket_all_gid;
74005 +extern int grsec_enable_socket_client;
74006 +extern kgid_t grsec_socket_client_gid;
74007 +extern int grsec_enable_socket_server;
74008 +extern kgid_t grsec_socket_server_gid;
74009 +extern kgid_t grsec_audit_gid;
74010 +extern int grsec_enable_group;
74011 +extern int grsec_enable_log_rwxmaps;
74012 +extern int grsec_enable_mount;
74013 +extern int grsec_enable_chdir;
74014 +extern int grsec_resource_logging;
74015 +extern int grsec_enable_blackhole;
74016 +extern int grsec_lastack_retries;
74017 +extern int grsec_enable_brute;
74018 +extern int grsec_lock;
74019 +
74020 +extern spinlock_t grsec_alert_lock;
74021 +extern unsigned long grsec_alert_wtime;
74022 +extern unsigned long grsec_alert_fyet;
74023 +
74024 +extern spinlock_t grsec_audit_lock;
74025 +
74026 +extern rwlock_t grsec_exec_file_lock;
74027 +
74028 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74029 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74030 + (tsk)->exec_file->f_path.mnt) : "/")
74031 +
74032 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74033 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74034 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74035 +
74036 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74037 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74038 + (tsk)->exec_file->f_path.mnt) : "/")
74039 +
74040 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74041 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74042 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74043 +
74044 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74045 +
74046 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74047 +
74048 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74049 +{
74050 + if (file1 && file2) {
74051 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74052 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74053 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74054 + return true;
74055 + }
74056 +
74057 + return false;
74058 +}
74059 +
74060 +#define GR_CHROOT_CAPS {{ \
74061 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74062 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74063 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74064 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74065 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74066 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74067 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74068 +
74069 +#define security_learn(normal_msg,args...) \
74070 +({ \
74071 + read_lock(&grsec_exec_file_lock); \
74072 + gr_add_learn_entry(normal_msg "\n", ## args); \
74073 + read_unlock(&grsec_exec_file_lock); \
74074 +})
74075 +
74076 +enum {
74077 + GR_DO_AUDIT,
74078 + GR_DONT_AUDIT,
74079 + /* used for non-audit messages that we shouldn't kill the task on */
74080 + GR_DONT_AUDIT_GOOD
74081 +};
74082 +
74083 +enum {
74084 + GR_TTYSNIFF,
74085 + GR_RBAC,
74086 + GR_RBAC_STR,
74087 + GR_STR_RBAC,
74088 + GR_RBAC_MODE2,
74089 + GR_RBAC_MODE3,
74090 + GR_FILENAME,
74091 + GR_SYSCTL_HIDDEN,
74092 + GR_NOARGS,
74093 + GR_ONE_INT,
74094 + GR_ONE_INT_TWO_STR,
74095 + GR_ONE_STR,
74096 + GR_STR_INT,
74097 + GR_TWO_STR_INT,
74098 + GR_TWO_INT,
74099 + GR_TWO_U64,
74100 + GR_THREE_INT,
74101 + GR_FIVE_INT_TWO_STR,
74102 + GR_TWO_STR,
74103 + GR_THREE_STR,
74104 + GR_FOUR_STR,
74105 + GR_STR_FILENAME,
74106 + GR_FILENAME_STR,
74107 + GR_FILENAME_TWO_INT,
74108 + GR_FILENAME_TWO_INT_STR,
74109 + GR_TEXTREL,
74110 + GR_PTRACE,
74111 + GR_RESOURCE,
74112 + GR_CAP,
74113 + GR_SIG,
74114 + GR_SIG2,
74115 + GR_CRASH1,
74116 + GR_CRASH2,
74117 + GR_PSACCT,
74118 + GR_RWXMAP,
74119 + GR_RWXMAPVMA
74120 +};
74121 +
74122 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74123 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74124 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74125 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74126 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74127 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74128 +#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)
74129 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74130 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74131 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74132 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74133 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74134 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74135 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74136 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74137 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74138 +#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)
74139 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74140 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74141 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74142 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74143 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74144 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74145 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74146 +#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)
74147 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74148 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74149 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74150 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74151 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74152 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74153 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74154 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74155 +#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)
74156 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74157 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74158 +
74159 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74160 +
74161 +#endif
74162 +
74163 +#endif
74164 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74165 new file mode 100644
74166 index 0000000..a4396b5
74167 --- /dev/null
74168 +++ b/include/linux/grmsg.h
74169 @@ -0,0 +1,113 @@
74170 +#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"
74171 +#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"
74172 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74173 +#define GR_STOPMOD_MSG "denied modification of module state by "
74174 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74175 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74176 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74177 +#define GR_IOPL_MSG "denied use of iopl() by "
74178 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74179 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74180 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74181 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74182 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74183 +#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"
74184 +#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"
74185 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74186 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74187 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74188 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74189 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74190 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74191 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74192 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74193 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74194 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74195 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74196 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74197 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74198 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74199 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74200 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74201 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74202 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74203 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74204 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74205 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74206 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74207 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74208 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74209 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74210 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74211 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74212 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74213 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74214 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74215 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74216 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74217 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74218 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74219 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74220 +#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"
74221 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74222 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74223 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74224 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74225 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74226 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74227 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74228 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74229 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74230 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74231 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74232 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74233 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74234 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74235 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74236 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74237 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74238 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74239 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74240 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74241 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74242 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74243 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74244 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74245 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74246 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74247 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74248 +#define GR_TIME_MSG "time set by "
74249 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74250 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74251 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74252 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74253 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74254 +#define GR_BIND_MSG "denied bind() by "
74255 +#define GR_CONNECT_MSG "denied connect() by "
74256 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74257 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74258 +#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"
74259 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74260 +#define GR_CAP_ACL_MSG "use of %s denied for "
74261 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74262 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74263 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74264 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74265 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74266 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74267 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74268 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74269 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74270 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74271 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74272 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74273 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74274 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74275 +#define GR_VM86_MSG "denied use of vm86 by "
74276 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74277 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74278 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74279 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74280 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74281 +#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 "
74282 +#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 "
74283 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74284 new file mode 100644
74285 index 0000000..d6f5a21
74286 --- /dev/null
74287 +++ b/include/linux/grsecurity.h
74288 @@ -0,0 +1,244 @@
74289 +#ifndef GR_SECURITY_H
74290 +#define GR_SECURITY_H
74291 +#include <linux/fs.h>
74292 +#include <linux/fs_struct.h>
74293 +#include <linux/binfmts.h>
74294 +#include <linux/gracl.h>
74295 +
74296 +/* notify of brain-dead configs */
74297 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74298 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74299 +#endif
74300 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74301 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74302 +#endif
74303 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74304 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74305 +#endif
74306 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74307 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74308 +#endif
74309 +
74310 +int gr_handle_new_usb(void);
74311 +
74312 +void gr_handle_brute_attach(unsigned long mm_flags);
74313 +void gr_handle_brute_check(void);
74314 +void gr_handle_kernel_exploit(void);
74315 +
74316 +char gr_roletype_to_char(void);
74317 +
74318 +int gr_acl_enable_at_secure(void);
74319 +
74320 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74321 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74322 +
74323 +void gr_del_task_from_ip_table(struct task_struct *p);
74324 +
74325 +int gr_pid_is_chrooted(struct task_struct *p);
74326 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74327 +int gr_handle_chroot_nice(void);
74328 +int gr_handle_chroot_sysctl(const int op);
74329 +int gr_handle_chroot_setpriority(struct task_struct *p,
74330 + const int niceval);
74331 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74332 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74333 + const struct vfsmount *mnt);
74334 +void gr_handle_chroot_chdir(const struct path *path);
74335 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74336 + const struct vfsmount *mnt, const int mode);
74337 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74338 + const struct vfsmount *mnt, const int mode);
74339 +int gr_handle_chroot_mount(const struct dentry *dentry,
74340 + const struct vfsmount *mnt,
74341 + const char *dev_name);
74342 +int gr_handle_chroot_pivot(void);
74343 +int gr_handle_chroot_unix(const pid_t pid);
74344 +
74345 +int gr_handle_rawio(const struct inode *inode);
74346 +
74347 +void gr_handle_ioperm(void);
74348 +void gr_handle_iopl(void);
74349 +
74350 +umode_t gr_acl_umask(void);
74351 +
74352 +int gr_tpe_allow(const struct file *file);
74353 +
74354 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74355 +void gr_clear_chroot_entries(struct task_struct *task);
74356 +
74357 +void gr_log_forkfail(const int retval);
74358 +void gr_log_timechange(void);
74359 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74360 +void gr_log_chdir(const struct dentry *dentry,
74361 + const struct vfsmount *mnt);
74362 +void gr_log_chroot_exec(const struct dentry *dentry,
74363 + const struct vfsmount *mnt);
74364 +void gr_log_remount(const char *devname, const int retval);
74365 +void gr_log_unmount(const char *devname, const int retval);
74366 +void gr_log_mount(const char *from, const char *to, const int retval);
74367 +void gr_log_textrel(struct vm_area_struct *vma);
74368 +void gr_log_ptgnustack(struct file *file);
74369 +void gr_log_rwxmmap(struct file *file);
74370 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74371 +
74372 +int gr_handle_follow_link(const struct inode *parent,
74373 + const struct inode *inode,
74374 + const struct dentry *dentry,
74375 + const struct vfsmount *mnt);
74376 +int gr_handle_fifo(const struct dentry *dentry,
74377 + const struct vfsmount *mnt,
74378 + const struct dentry *dir, const int flag,
74379 + const int acc_mode);
74380 +int gr_handle_hardlink(const struct dentry *dentry,
74381 + const struct vfsmount *mnt,
74382 + struct inode *inode,
74383 + const int mode, const struct filename *to);
74384 +
74385 +int gr_is_capable(const int cap);
74386 +int gr_is_capable_nolog(const int cap);
74387 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74388 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74389 +
74390 +void gr_copy_label(struct task_struct *tsk);
74391 +void gr_handle_crash(struct task_struct *task, const int sig);
74392 +int gr_handle_signal(const struct task_struct *p, const int sig);
74393 +int gr_check_crash_uid(const kuid_t uid);
74394 +int gr_check_protected_task(const struct task_struct *task);
74395 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74396 +int gr_acl_handle_mmap(const struct file *file,
74397 + const unsigned long prot);
74398 +int gr_acl_handle_mprotect(const struct file *file,
74399 + const unsigned long prot);
74400 +int gr_check_hidden_task(const struct task_struct *tsk);
74401 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74402 + const struct vfsmount *mnt);
74403 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74404 + const struct vfsmount *mnt);
74405 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74406 + const struct vfsmount *mnt, const int fmode);
74407 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74408 + const struct vfsmount *mnt, umode_t *mode);
74409 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74410 + const struct vfsmount *mnt);
74411 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74412 + const struct vfsmount *mnt);
74413 +int gr_handle_ptrace(struct task_struct *task, const long request);
74414 +int gr_handle_proc_ptrace(struct task_struct *task);
74415 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74416 + const struct vfsmount *mnt);
74417 +int gr_check_crash_exec(const struct file *filp);
74418 +int gr_acl_is_enabled(void);
74419 +void gr_set_kernel_label(struct task_struct *task);
74420 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74421 + const kgid_t gid);
74422 +int gr_set_proc_label(const struct dentry *dentry,
74423 + const struct vfsmount *mnt,
74424 + const int unsafe_flags);
74425 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74426 + const struct vfsmount *mnt);
74427 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74428 + const struct vfsmount *mnt, int acc_mode);
74429 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74430 + const struct dentry *p_dentry,
74431 + const struct vfsmount *p_mnt,
74432 + int open_flags, int acc_mode, const int imode);
74433 +void gr_handle_create(const struct dentry *dentry,
74434 + const struct vfsmount *mnt);
74435 +void gr_handle_proc_create(const struct dentry *dentry,
74436 + const struct inode *inode);
74437 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74438 + const struct dentry *parent_dentry,
74439 + const struct vfsmount *parent_mnt,
74440 + const int mode);
74441 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74442 + const struct dentry *parent_dentry,
74443 + const struct vfsmount *parent_mnt);
74444 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74445 + const struct vfsmount *mnt);
74446 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74447 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74448 + const struct vfsmount *mnt);
74449 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74450 + const struct dentry *parent_dentry,
74451 + const struct vfsmount *parent_mnt,
74452 + const struct filename *from);
74453 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74454 + const struct dentry *parent_dentry,
74455 + const struct vfsmount *parent_mnt,
74456 + const struct dentry *old_dentry,
74457 + const struct vfsmount *old_mnt, const struct filename *to);
74458 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74459 +int gr_acl_handle_rename(struct dentry *new_dentry,
74460 + struct dentry *parent_dentry,
74461 + const struct vfsmount *parent_mnt,
74462 + struct dentry *old_dentry,
74463 + struct inode *old_parent_inode,
74464 + struct vfsmount *old_mnt, const struct filename *newname);
74465 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74466 + struct dentry *old_dentry,
74467 + struct dentry *new_dentry,
74468 + struct vfsmount *mnt, const __u8 replace);
74469 +__u32 gr_check_link(const struct dentry *new_dentry,
74470 + const struct dentry *parent_dentry,
74471 + const struct vfsmount *parent_mnt,
74472 + const struct dentry *old_dentry,
74473 + const struct vfsmount *old_mnt);
74474 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74475 + const unsigned int namelen, const ino_t ino);
74476 +
74477 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74478 + const struct vfsmount *mnt);
74479 +void gr_acl_handle_exit(void);
74480 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74481 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74482 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74483 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74484 +void gr_audit_ptrace(struct task_struct *task);
74485 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74486 +void gr_put_exec_file(struct task_struct *task);
74487 +
74488 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74489 +
74490 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74491 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74492 + const unsigned long wanted, const int gt);
74493 +#else
74494 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74495 + const unsigned long wanted, const int gt)
74496 +{
74497 +}
74498 +#endif
74499 +
74500 +#ifdef CONFIG_GRKERNSEC_RESLOG
74501 +extern void gr_log_resource(const struct task_struct *task, const int res,
74502 + const unsigned long wanted, const int gt);
74503 +#else
74504 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74505 + const unsigned long wanted, const int gt)
74506 +{
74507 +}
74508 +#endif
74509 +
74510 +#ifdef CONFIG_GRKERNSEC
74511 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74512 +void gr_handle_vm86(void);
74513 +void gr_handle_mem_readwrite(u64 from, u64 to);
74514 +
74515 +void gr_log_badprocpid(const char *entry);
74516 +
74517 +extern int grsec_enable_dmesg;
74518 +extern int grsec_disable_privio;
74519 +
74520 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74521 +extern kgid_t grsec_proc_gid;
74522 +#endif
74523 +
74524 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74525 +extern int grsec_enable_chroot_findtask;
74526 +#endif
74527 +#ifdef CONFIG_GRKERNSEC_SETXID
74528 +extern int grsec_enable_setxid;
74529 +#endif
74530 +#endif
74531 +
74532 +#endif
74533 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74534 new file mode 100644
74535 index 0000000..e7ffaaf
74536 --- /dev/null
74537 +++ b/include/linux/grsock.h
74538 @@ -0,0 +1,19 @@
74539 +#ifndef __GRSOCK_H
74540 +#define __GRSOCK_H
74541 +
74542 +extern void gr_attach_curr_ip(const struct sock *sk);
74543 +extern int gr_handle_sock_all(const int family, const int type,
74544 + const int protocol);
74545 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74546 +extern int gr_handle_sock_server_other(const struct sock *sck);
74547 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74548 +extern int gr_search_connect(struct socket * sock,
74549 + struct sockaddr_in * addr);
74550 +extern int gr_search_bind(struct socket * sock,
74551 + struct sockaddr_in * addr);
74552 +extern int gr_search_listen(struct socket * sock);
74553 +extern int gr_search_accept(struct socket * sock);
74554 +extern int gr_search_socket(const int domain, const int type,
74555 + const int protocol);
74556 +
74557 +#endif
74558 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74559 index 7fb31da..08b5114 100644
74560 --- a/include/linux/highmem.h
74561 +++ b/include/linux/highmem.h
74562 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74563 kunmap_atomic(kaddr);
74564 }
74565
74566 +static inline void sanitize_highpage(struct page *page)
74567 +{
74568 + void *kaddr;
74569 + unsigned long flags;
74570 +
74571 + local_irq_save(flags);
74572 + kaddr = kmap_atomic(page);
74573 + clear_page(kaddr);
74574 + kunmap_atomic(kaddr);
74575 + local_irq_restore(flags);
74576 +}
74577 +
74578 static inline void zero_user_segments(struct page *page,
74579 unsigned start1, unsigned end1,
74580 unsigned start2, unsigned end2)
74581 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74582 index 1c7b89a..7f52502 100644
74583 --- a/include/linux/hwmon-sysfs.h
74584 +++ b/include/linux/hwmon-sysfs.h
74585 @@ -25,7 +25,8 @@
74586 struct sensor_device_attribute{
74587 struct device_attribute dev_attr;
74588 int index;
74589 -};
74590 +} __do_const;
74591 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74592 #define to_sensor_dev_attr(_dev_attr) \
74593 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74594
74595 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74596 struct device_attribute dev_attr;
74597 u8 index;
74598 u8 nr;
74599 -};
74600 +} __do_const;
74601 #define to_sensor_dev_attr_2(_dev_attr) \
74602 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74603
74604 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74605 index e988fa9..ff9f17e 100644
74606 --- a/include/linux/i2c.h
74607 +++ b/include/linux/i2c.h
74608 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74609 /* To determine what the adapter supports */
74610 u32 (*functionality) (struct i2c_adapter *);
74611 };
74612 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74613
74614 /**
74615 * struct i2c_bus_recovery_info - I2C bus recovery information
74616 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74617 index d23c3c2..eb63c81 100644
74618 --- a/include/linux/i2o.h
74619 +++ b/include/linux/i2o.h
74620 @@ -565,7 +565,7 @@ struct i2o_controller {
74621 struct i2o_device *exec; /* Executive */
74622 #if BITS_PER_LONG == 64
74623 spinlock_t context_list_lock; /* lock for context_list */
74624 - atomic_t context_list_counter; /* needed for unique contexts */
74625 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74626 struct list_head context_list; /* list of context id's
74627 and pointers */
74628 #endif
74629 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74630 index aff7ad8..3942bbd 100644
74631 --- a/include/linux/if_pppox.h
74632 +++ b/include/linux/if_pppox.h
74633 @@ -76,7 +76,7 @@ struct pppox_proto {
74634 int (*ioctl)(struct socket *sock, unsigned int cmd,
74635 unsigned long arg);
74636 struct module *owner;
74637 -};
74638 +} __do_const;
74639
74640 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74641 extern void unregister_pppox_proto(int proto_num);
74642 diff --git a/include/linux/init.h b/include/linux/init.h
74643 index e73f2b7..cc996e0 100644
74644 --- a/include/linux/init.h
74645 +++ b/include/linux/init.h
74646 @@ -39,9 +39,17 @@
74647 * Also note, that this data cannot be "const".
74648 */
74649
74650 +#define add_init_latent_entropy __latent_entropy
74651 +
74652 +#ifdef CONFIG_MEMORY_HOTPLUG
74653 +#define add_meminit_latent_entropy
74654 +#else
74655 +#define add_meminit_latent_entropy __latent_entropy
74656 +#endif
74657 +
74658 /* These are for everybody (although not all archs will actually
74659 discard it in modules) */
74660 -#define __init __section(.init.text) __cold notrace
74661 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74662 #define __initdata __section(.init.data)
74663 #define __initconst __constsection(.init.rodata)
74664 #define __exitdata __section(.exit.data)
74665 @@ -102,7 +110,7 @@
74666 #define __cpuexitconst
74667
74668 /* Used for MEMORY_HOTPLUG */
74669 -#define __meminit __section(.meminit.text) __cold notrace
74670 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74671 #define __meminitdata __section(.meminit.data)
74672 #define __meminitconst __constsection(.meminit.rodata)
74673 #define __memexit __section(.memexit.text) __exitused __cold notrace
74674 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74675 index 5cd0f09..c9f67cc 100644
74676 --- a/include/linux/init_task.h
74677 +++ b/include/linux/init_task.h
74678 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74679
74680 #define INIT_TASK_COMM "swapper"
74681
74682 +#ifdef CONFIG_X86
74683 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74684 +#else
74685 +#define INIT_TASK_THREAD_INFO
74686 +#endif
74687 +
74688 /*
74689 * INIT_TASK is used to set up the first task table, touch at
74690 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74691 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74692 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74693 .comm = INIT_TASK_COMM, \
74694 .thread = INIT_THREAD, \
74695 + INIT_TASK_THREAD_INFO \
74696 .fs = &init_fs, \
74697 .files = &init_files, \
74698 .signal = &init_signals, \
74699 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74700 index 5fa5afe..ac55b25 100644
74701 --- a/include/linux/interrupt.h
74702 +++ b/include/linux/interrupt.h
74703 @@ -430,7 +430,7 @@ enum
74704 /* map softirq index to softirq name. update 'softirq_to_name' in
74705 * kernel/softirq.c when adding a new softirq.
74706 */
74707 -extern char *softirq_to_name[NR_SOFTIRQS];
74708 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74709
74710 /* softirq mask and active fields moved to irq_cpustat_t in
74711 * asm/hardirq.h to get better cache usage. KAO
74712 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74713
74714 struct softirq_action
74715 {
74716 - void (*action)(struct softirq_action *);
74717 -};
74718 + void (*action)(void);
74719 +} __no_const;
74720
74721 asmlinkage void do_softirq(void);
74722 asmlinkage void __do_softirq(void);
74723 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74724 +extern void open_softirq(int nr, void (*action)(void));
74725 extern void softirq_init(void);
74726 extern void __raise_softirq_irqoff(unsigned int nr);
74727
74728 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74729 index 3aeb730..2177f39 100644
74730 --- a/include/linux/iommu.h
74731 +++ b/include/linux/iommu.h
74732 @@ -113,7 +113,7 @@ struct iommu_ops {
74733 u32 (*domain_get_windows)(struct iommu_domain *domain);
74734
74735 unsigned long pgsize_bitmap;
74736 -};
74737 +} __do_const;
74738
74739 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74740 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74741 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74742 index 89b7c24..382af74 100644
74743 --- a/include/linux/ioport.h
74744 +++ b/include/linux/ioport.h
74745 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74746 int adjust_resource(struct resource *res, resource_size_t start,
74747 resource_size_t size);
74748 resource_size_t resource_alignment(struct resource *res);
74749 -static inline resource_size_t resource_size(const struct resource *res)
74750 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74751 {
74752 return res->end - res->start + 1;
74753 }
74754 diff --git a/include/linux/irq.h b/include/linux/irq.h
74755 index f04d3ba..bcf2cfb 100644
74756 --- a/include/linux/irq.h
74757 +++ b/include/linux/irq.h
74758 @@ -333,7 +333,8 @@ struct irq_chip {
74759 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74760
74761 unsigned long flags;
74762 -};
74763 +} __do_const;
74764 +typedef struct irq_chip __no_const irq_chip_no_const;
74765
74766 /*
74767 * irq_chip specific flags
74768 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74769 index 3e203eb..3fe68d0 100644
74770 --- a/include/linux/irqchip/arm-gic.h
74771 +++ b/include/linux/irqchip/arm-gic.h
74772 @@ -59,9 +59,11 @@
74773
74774 #ifndef __ASSEMBLY__
74775
74776 +#include <linux/irq.h>
74777 +
74778 struct device_node;
74779
74780 -extern struct irq_chip gic_arch_extn;
74781 +extern irq_chip_no_const gic_arch_extn;
74782
74783 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74784 u32 offset, struct device_node *);
74785 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74786 index 6883e19..e854fcb 100644
74787 --- a/include/linux/kallsyms.h
74788 +++ b/include/linux/kallsyms.h
74789 @@ -15,7 +15,8 @@
74790
74791 struct module;
74792
74793 -#ifdef CONFIG_KALLSYMS
74794 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74795 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74796 /* Lookup the address for a symbol. Returns 0 if not found. */
74797 unsigned long kallsyms_lookup_name(const char *name);
74798
74799 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74800 /* Stupid that this does nothing, but I didn't create this mess. */
74801 #define __print_symbol(fmt, addr)
74802 #endif /*CONFIG_KALLSYMS*/
74803 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74804 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74805 +extern unsigned long kallsyms_lookup_name(const char *name);
74806 +extern void __print_symbol(const char *fmt, unsigned long address);
74807 +extern int sprint_backtrace(char *buffer, unsigned long address);
74808 +extern int sprint_symbol(char *buffer, unsigned long address);
74809 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74810 +const char *kallsyms_lookup(unsigned long addr,
74811 + unsigned long *symbolsize,
74812 + unsigned long *offset,
74813 + char **modname, char *namebuf);
74814 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74815 + unsigned long *symbolsize,
74816 + unsigned long *offset);
74817 +#endif
74818
74819 /* This macro allows us to keep printk typechecking */
74820 static __printf(1, 2)
74821 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74822 index 518a53a..5e28358 100644
74823 --- a/include/linux/key-type.h
74824 +++ b/include/linux/key-type.h
74825 @@ -125,7 +125,7 @@ struct key_type {
74826 /* internal fields */
74827 struct list_head link; /* link in types list */
74828 struct lock_class_key lock_class; /* key->sem lock class */
74829 -};
74830 +} __do_const;
74831
74832 extern struct key_type key_type_keyring;
74833
74834 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74835 index c6e091b..a940adf 100644
74836 --- a/include/linux/kgdb.h
74837 +++ b/include/linux/kgdb.h
74838 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74839 extern int kgdb_io_module_registered;
74840
74841 extern atomic_t kgdb_setting_breakpoint;
74842 -extern atomic_t kgdb_cpu_doing_single_step;
74843 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74844
74845 extern struct task_struct *kgdb_usethread;
74846 extern struct task_struct *kgdb_contthread;
74847 @@ -254,7 +254,7 @@ struct kgdb_arch {
74848 void (*correct_hw_break)(void);
74849
74850 void (*enable_nmi)(bool on);
74851 -};
74852 +} __do_const;
74853
74854 /**
74855 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74856 @@ -279,7 +279,7 @@ struct kgdb_io {
74857 void (*pre_exception) (void);
74858 void (*post_exception) (void);
74859 int is_console;
74860 -};
74861 +} __do_const;
74862
74863 extern struct kgdb_arch arch_kgdb_ops;
74864
74865 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74866 index 0555cc6..b16a7a4 100644
74867 --- a/include/linux/kmod.h
74868 +++ b/include/linux/kmod.h
74869 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74870 * usually useless though. */
74871 extern __printf(2, 3)
74872 int __request_module(bool wait, const char *name, ...);
74873 +extern __printf(3, 4)
74874 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74875 #define request_module(mod...) __request_module(true, mod)
74876 #define request_module_nowait(mod...) __request_module(false, mod)
74877 #define try_then_request_module(x, mod...) \
74878 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74879 index 939b112..ed6ed51 100644
74880 --- a/include/linux/kobject.h
74881 +++ b/include/linux/kobject.h
74882 @@ -111,7 +111,7 @@ struct kobj_type {
74883 struct attribute **default_attrs;
74884 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74885 const void *(*namespace)(struct kobject *kobj);
74886 -};
74887 +} __do_const;
74888
74889 struct kobj_uevent_env {
74890 char *envp[UEVENT_NUM_ENVP];
74891 @@ -134,6 +134,7 @@ struct kobj_attribute {
74892 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74893 const char *buf, size_t count);
74894 };
74895 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74896
74897 extern const struct sysfs_ops kobj_sysfs_ops;
74898
74899 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74900 index f66b065..c2c29b4 100644
74901 --- a/include/linux/kobject_ns.h
74902 +++ b/include/linux/kobject_ns.h
74903 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74904 const void *(*netlink_ns)(struct sock *sk);
74905 const void *(*initial_ns)(void);
74906 void (*drop_ns)(void *);
74907 -};
74908 +} __do_const;
74909
74910 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74911 int kobj_ns_type_registered(enum kobj_ns_type type);
74912 diff --git a/include/linux/kref.h b/include/linux/kref.h
74913 index 484604d..0f6c5b6 100644
74914 --- a/include/linux/kref.h
74915 +++ b/include/linux/kref.h
74916 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74917 static inline int kref_sub(struct kref *kref, unsigned int count,
74918 void (*release)(struct kref *kref))
74919 {
74920 - WARN_ON(release == NULL);
74921 + BUG_ON(release == NULL);
74922
74923 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74924 release(kref);
74925 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74926 index a63d83e..77fd685 100644
74927 --- a/include/linux/kvm_host.h
74928 +++ b/include/linux/kvm_host.h
74929 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74930 {
74931 }
74932 #endif
74933 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74934 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74935 struct module *module);
74936 void kvm_exit(void);
74937
74938 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74939 struct kvm_guest_debug *dbg);
74940 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74941
74942 -int kvm_arch_init(void *opaque);
74943 +int kvm_arch_init(const void *opaque);
74944 void kvm_arch_exit(void);
74945
74946 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74947 diff --git a/include/linux/libata.h b/include/linux/libata.h
74948 index 4ea55bb..dcd2601 100644
74949 --- a/include/linux/libata.h
74950 +++ b/include/linux/libata.h
74951 @@ -924,7 +924,7 @@ struct ata_port_operations {
74952 * fields must be pointers.
74953 */
74954 const struct ata_port_operations *inherits;
74955 -};
74956 +} __do_const;
74957
74958 struct ata_port_info {
74959 unsigned long flags;
74960 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74961 index d3e8ad2..a949f68 100644
74962 --- a/include/linux/linkage.h
74963 +++ b/include/linux/linkage.h
74964 @@ -31,6 +31,7 @@
74965 #endif
74966
74967 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74968 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74969 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74970
74971 /*
74972 diff --git a/include/linux/list.h b/include/linux/list.h
74973 index f4d8a2f..38e6e46 100644
74974 --- a/include/linux/list.h
74975 +++ b/include/linux/list.h
74976 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74977 extern void list_del(struct list_head *entry);
74978 #endif
74979
74980 +extern void __pax_list_add(struct list_head *new,
74981 + struct list_head *prev,
74982 + struct list_head *next);
74983 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74984 +{
74985 + __pax_list_add(new, head, head->next);
74986 +}
74987 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74988 +{
74989 + __pax_list_add(new, head->prev, head);
74990 +}
74991 +extern void pax_list_del(struct list_head *entry);
74992 +
74993 /**
74994 * list_replace - replace old entry by new one
74995 * @old : the element to be replaced
74996 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74997 INIT_LIST_HEAD(entry);
74998 }
74999
75000 +extern void pax_list_del_init(struct list_head *entry);
75001 +
75002 /**
75003 * list_move - delete from one list and add as another's head
75004 * @list: the entry to move
75005 diff --git a/include/linux/math64.h b/include/linux/math64.h
75006 index 2913b86..8dcbb1e 100644
75007 --- a/include/linux/math64.h
75008 +++ b/include/linux/math64.h
75009 @@ -15,7 +15,7 @@
75010 * This is commonly provided by 32bit archs to provide an optimized 64bit
75011 * divide.
75012 */
75013 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75014 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75015 {
75016 *remainder = dividend % divisor;
75017 return dividend / divisor;
75018 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
75019 /**
75020 * div64_u64 - unsigned 64bit divide with 64bit divisor
75021 */
75022 -static inline u64 div64_u64(u64 dividend, u64 divisor)
75023 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
75024 {
75025 return dividend / divisor;
75026 }
75027 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75028 #define div64_ul(x, y) div_u64((x), (y))
75029
75030 #ifndef div_u64_rem
75031 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75032 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75033 {
75034 *remainder = do_div(dividend, divisor);
75035 return dividend;
75036 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75037 * divide.
75038 */
75039 #ifndef div_u64
75040 -static inline u64 div_u64(u64 dividend, u32 divisor)
75041 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75042 {
75043 u32 remainder;
75044 return div_u64_rem(dividend, divisor, &remainder);
75045 diff --git a/include/linux/mm.h b/include/linux/mm.h
75046 index f022460..6ecf4f9 100644
75047 --- a/include/linux/mm.h
75048 +++ b/include/linux/mm.h
75049 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75050 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75051 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75052 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75053 +
75054 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75055 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75056 +#endif
75057 +
75058 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75059
75060 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
75061 @@ -208,8 +213,8 @@ struct vm_operations_struct {
75062 /* called by access_process_vm when get_user_pages() fails, typically
75063 * for use by special VMAs that can switch between memory and hardware
75064 */
75065 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75066 - void *buf, int len, int write);
75067 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75068 + void *buf, size_t len, int write);
75069 #ifdef CONFIG_NUMA
75070 /*
75071 * set_policy() op must add a reference to any non-NULL @new mempolicy
75072 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75073 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75074 unsigned long size, pgoff_t pgoff);
75075 };
75076 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75077
75078 struct mmu_gather;
75079 struct inode;
75080 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75081 unsigned long *pfn);
75082 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75083 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75084 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75085 - void *buf, int len, int write);
75086 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75087 + void *buf, size_t len, int write);
75088
75089 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75090 loff_t const holebegin, loff_t const holelen)
75091 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75092 }
75093 #endif
75094
75095 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75096 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75097 - void *buf, int len, int write);
75098 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75099 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75100 + void *buf, size_t len, int write);
75101
75102 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75103 unsigned long start, unsigned long nr_pages,
75104 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75105 int set_page_dirty_lock(struct page *page);
75106 int clear_page_dirty_for_io(struct page *page);
75107
75108 -/* Is the vma a continuation of the stack vma above it? */
75109 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75110 -{
75111 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75112 -}
75113 -
75114 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75115 - unsigned long addr)
75116 -{
75117 - return (vma->vm_flags & VM_GROWSDOWN) &&
75118 - (vma->vm_start == addr) &&
75119 - !vma_growsdown(vma->vm_prev, addr);
75120 -}
75121 -
75122 -/* Is the vma a continuation of the stack vma below it? */
75123 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75124 -{
75125 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75126 -}
75127 -
75128 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75129 - unsigned long addr)
75130 -{
75131 - return (vma->vm_flags & VM_GROWSUP) &&
75132 - (vma->vm_end == addr) &&
75133 - !vma_growsup(vma->vm_next, addr);
75134 -}
75135 -
75136 extern pid_t
75137 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75138
75139 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75140 }
75141 #endif
75142
75143 +#ifdef CONFIG_MMU
75144 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75145 +#else
75146 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75147 +{
75148 + return __pgprot(0);
75149 +}
75150 +#endif
75151 +
75152 int vma_wants_writenotify(struct vm_area_struct *vma);
75153
75154 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75155 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75156 {
75157 return 0;
75158 }
75159 +
75160 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75161 + unsigned long address)
75162 +{
75163 + return 0;
75164 +}
75165 #else
75166 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75167 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75168 #endif
75169
75170 #ifdef __PAGETABLE_PMD_FOLDED
75171 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75172 {
75173 return 0;
75174 }
75175 +
75176 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75177 + unsigned long address)
75178 +{
75179 + return 0;
75180 +}
75181 #else
75182 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75183 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75184 #endif
75185
75186 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75187 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75188 NULL: pud_offset(pgd, address);
75189 }
75190
75191 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75192 +{
75193 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75194 + NULL: pud_offset(pgd, address);
75195 +}
75196 +
75197 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75198 {
75199 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75200 NULL: pmd_offset(pud, address);
75201 }
75202 +
75203 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75204 +{
75205 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75206 + NULL: pmd_offset(pud, address);
75207 +}
75208 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75209
75210 #if USE_SPLIT_PTLOCKS
75211 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75212 unsigned long len, unsigned long prot, unsigned long flags,
75213 unsigned long pgoff, unsigned long *populate);
75214 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75215 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75216
75217 #ifdef CONFIG_MMU
75218 extern int __mm_populate(unsigned long addr, unsigned long len,
75219 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75220 unsigned long high_limit;
75221 unsigned long align_mask;
75222 unsigned long align_offset;
75223 + unsigned long threadstack_offset;
75224 };
75225
75226 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75227 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75228 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75229 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75230
75231 /*
75232 * Search for an unmapped address range.
75233 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75234 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75235 */
75236 static inline unsigned long
75237 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75238 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75239 {
75240 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75241 return unmapped_area(info);
75242 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75243 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75244 struct vm_area_struct **pprev);
75245
75246 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75247 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75248 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75249 +
75250 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75251 NULL if none. Assume start_addr < end_addr. */
75252 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75253 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75254 return vma;
75255 }
75256
75257 -#ifdef CONFIG_MMU
75258 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75259 -#else
75260 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75261 -{
75262 - return __pgprot(0);
75263 -}
75264 -#endif
75265 -
75266 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75267 unsigned long change_prot_numa(struct vm_area_struct *vma,
75268 unsigned long start, unsigned long end);
75269 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75270 static inline void vm_stat_account(struct mm_struct *mm,
75271 unsigned long flags, struct file *file, long pages)
75272 {
75273 +
75274 +#ifdef CONFIG_PAX_RANDMMAP
75275 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75276 +#endif
75277 +
75278 mm->total_vm += pages;
75279 }
75280 #endif /* CONFIG_PROC_FS */
75281 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75282 extern int sysctl_memory_failure_early_kill;
75283 extern int sysctl_memory_failure_recovery;
75284 extern void shake_page(struct page *p, int access);
75285 -extern atomic_long_t num_poisoned_pages;
75286 +extern atomic_long_unchecked_t num_poisoned_pages;
75287 extern int soft_offline_page(struct page *page, int flags);
75288
75289 extern void dump_page(struct page *page);
75290 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75291 static inline void setup_nr_node_ids(void) {}
75292 #endif
75293
75294 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75295 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75296 +#else
75297 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75298 +#endif
75299 +
75300 #endif /* __KERNEL__ */
75301 #endif /* _LINUX_MM_H */
75302 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75303 index faf4b7c..1e70c6e 100644
75304 --- a/include/linux/mm_types.h
75305 +++ b/include/linux/mm_types.h
75306 @@ -289,6 +289,8 @@ struct vm_area_struct {
75307 #ifdef CONFIG_NUMA
75308 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75309 #endif
75310 +
75311 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75312 };
75313
75314 struct core_thread {
75315 @@ -435,6 +437,24 @@ struct mm_struct {
75316 int first_nid;
75317 #endif
75318 struct uprobes_state uprobes_state;
75319 +
75320 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75321 + unsigned long pax_flags;
75322 +#endif
75323 +
75324 +#ifdef CONFIG_PAX_DLRESOLVE
75325 + unsigned long call_dl_resolve;
75326 +#endif
75327 +
75328 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75329 + unsigned long call_syscall;
75330 +#endif
75331 +
75332 +#ifdef CONFIG_PAX_ASLR
75333 + unsigned long delta_mmap; /* randomized offset */
75334 + unsigned long delta_stack; /* randomized offset */
75335 +#endif
75336 +
75337 };
75338
75339 /* first nid will either be a valid NID or one of these values */
75340 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75341 index c5d5278..f0b68c8 100644
75342 --- a/include/linux/mmiotrace.h
75343 +++ b/include/linux/mmiotrace.h
75344 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75345 /* Called from ioremap.c */
75346 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75347 void __iomem *addr);
75348 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75349 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75350
75351 /* For anyone to insert markers. Remember trailing newline. */
75352 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75353 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75354 {
75355 }
75356
75357 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75358 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75359 {
75360 }
75361
75362 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75363 index af4a3b7..9ad8889 100644
75364 --- a/include/linux/mmzone.h
75365 +++ b/include/linux/mmzone.h
75366 @@ -396,7 +396,7 @@ struct zone {
75367 unsigned long flags; /* zone flags, see below */
75368
75369 /* Zone statistics */
75370 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75371 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75372
75373 /*
75374 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75375 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75376 index 45e9214..a7227d6 100644
75377 --- a/include/linux/mod_devicetable.h
75378 +++ b/include/linux/mod_devicetable.h
75379 @@ -13,7 +13,7 @@
75380 typedef unsigned long kernel_ulong_t;
75381 #endif
75382
75383 -#define PCI_ANY_ID (~0)
75384 +#define PCI_ANY_ID ((__u16)~0)
75385
75386 struct pci_device_id {
75387 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75388 @@ -139,7 +139,7 @@ struct usb_device_id {
75389 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75390 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75391
75392 -#define HID_ANY_ID (~0)
75393 +#define HID_ANY_ID (~0U)
75394 #define HID_BUS_ANY 0xffff
75395 #define HID_GROUP_ANY 0x0000
75396
75397 @@ -467,7 +467,7 @@ struct dmi_system_id {
75398 const char *ident;
75399 struct dmi_strmatch matches[4];
75400 void *driver_data;
75401 -};
75402 +} __do_const;
75403 /*
75404 * struct dmi_device_id appears during expansion of
75405 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75406 diff --git a/include/linux/module.h b/include/linux/module.h
75407 index 46f1ea0..a34ca37 100644
75408 --- a/include/linux/module.h
75409 +++ b/include/linux/module.h
75410 @@ -17,9 +17,11 @@
75411 #include <linux/moduleparam.h>
75412 #include <linux/tracepoint.h>
75413 #include <linux/export.h>
75414 +#include <linux/fs.h>
75415
75416 #include <linux/percpu.h>
75417 #include <asm/module.h>
75418 +#include <asm/pgtable.h>
75419
75420 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75421 #define MODULE_SIG_STRING "~Module signature appended~\n"
75422 @@ -54,12 +56,13 @@ struct module_attribute {
75423 int (*test)(struct module *);
75424 void (*free)(struct module *);
75425 };
75426 +typedef struct module_attribute __no_const module_attribute_no_const;
75427
75428 struct module_version_attribute {
75429 struct module_attribute mattr;
75430 const char *module_name;
75431 const char *version;
75432 -} __attribute__ ((__aligned__(sizeof(void *))));
75433 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75434
75435 extern ssize_t __modver_version_show(struct module_attribute *,
75436 struct module_kobject *, char *);
75437 @@ -232,7 +235,7 @@ struct module
75438
75439 /* Sysfs stuff. */
75440 struct module_kobject mkobj;
75441 - struct module_attribute *modinfo_attrs;
75442 + module_attribute_no_const *modinfo_attrs;
75443 const char *version;
75444 const char *srcversion;
75445 struct kobject *holders_dir;
75446 @@ -281,19 +284,16 @@ struct module
75447 int (*init)(void);
75448
75449 /* If this is non-NULL, vfree after init() returns */
75450 - void *module_init;
75451 + void *module_init_rx, *module_init_rw;
75452
75453 /* Here is the actual code + data, vfree'd on unload. */
75454 - void *module_core;
75455 + void *module_core_rx, *module_core_rw;
75456
75457 /* Here are the sizes of the init and core sections */
75458 - unsigned int init_size, core_size;
75459 + unsigned int init_size_rw, core_size_rw;
75460
75461 /* The size of the executable code in each section. */
75462 - unsigned int init_text_size, core_text_size;
75463 -
75464 - /* Size of RO sections of the module (text+rodata) */
75465 - unsigned int init_ro_size, core_ro_size;
75466 + unsigned int init_size_rx, core_size_rx;
75467
75468 /* Arch-specific module values */
75469 struct mod_arch_specific arch;
75470 @@ -349,6 +349,10 @@ struct module
75471 #ifdef CONFIG_EVENT_TRACING
75472 struct ftrace_event_call **trace_events;
75473 unsigned int num_trace_events;
75474 + struct file_operations trace_id;
75475 + struct file_operations trace_enable;
75476 + struct file_operations trace_format;
75477 + struct file_operations trace_filter;
75478 #endif
75479 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75480 unsigned int num_ftrace_callsites;
75481 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75482 bool is_module_percpu_address(unsigned long addr);
75483 bool is_module_text_address(unsigned long addr);
75484
75485 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75486 +{
75487 +
75488 +#ifdef CONFIG_PAX_KERNEXEC
75489 + if (ktla_ktva(addr) >= (unsigned long)start &&
75490 + ktla_ktva(addr) < (unsigned long)start + size)
75491 + return 1;
75492 +#endif
75493 +
75494 + return ((void *)addr >= start && (void *)addr < start + size);
75495 +}
75496 +
75497 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75498 +{
75499 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75500 +}
75501 +
75502 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75503 +{
75504 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75505 +}
75506 +
75507 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75508 +{
75509 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75510 +}
75511 +
75512 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75513 +{
75514 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75515 +}
75516 +
75517 static inline int within_module_core(unsigned long addr, const struct module *mod)
75518 {
75519 - return (unsigned long)mod->module_core <= addr &&
75520 - addr < (unsigned long)mod->module_core + mod->core_size;
75521 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75522 }
75523
75524 static inline int within_module_init(unsigned long addr, const struct module *mod)
75525 {
75526 - return (unsigned long)mod->module_init <= addr &&
75527 - addr < (unsigned long)mod->module_init + mod->init_size;
75528 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75529 }
75530
75531 /* Search for module by name: must hold module_mutex. */
75532 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75533 index 560ca53..ef621ef 100644
75534 --- a/include/linux/moduleloader.h
75535 +++ b/include/linux/moduleloader.h
75536 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75537 sections. Returns NULL on failure. */
75538 void *module_alloc(unsigned long size);
75539
75540 +#ifdef CONFIG_PAX_KERNEXEC
75541 +void *module_alloc_exec(unsigned long size);
75542 +#else
75543 +#define module_alloc_exec(x) module_alloc(x)
75544 +#endif
75545 +
75546 /* Free memory returned from module_alloc. */
75547 void module_free(struct module *mod, void *module_region);
75548
75549 +#ifdef CONFIG_PAX_KERNEXEC
75550 +void module_free_exec(struct module *mod, void *module_region);
75551 +#else
75552 +#define module_free_exec(x, y) module_free((x), (y))
75553 +#endif
75554 +
75555 /*
75556 * Apply the given relocation to the (simplified) ELF. Return -error
75557 * or 0.
75558 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75559 unsigned int relsec,
75560 struct module *me)
75561 {
75562 +#ifdef CONFIG_MODULES
75563 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75564 +#endif
75565 return -ENOEXEC;
75566 }
75567 #endif
75568 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75569 unsigned int relsec,
75570 struct module *me)
75571 {
75572 +#ifdef CONFIG_MODULES
75573 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75574 +#endif
75575 return -ENOEXEC;
75576 }
75577 #endif
75578 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75579 index 27d9da3..5d94aa3 100644
75580 --- a/include/linux/moduleparam.h
75581 +++ b/include/linux/moduleparam.h
75582 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75583 * @len is usually just sizeof(string).
75584 */
75585 #define module_param_string(name, string, len, perm) \
75586 - static const struct kparam_string __param_string_##name \
75587 + static const struct kparam_string __param_string_##name __used \
75588 = { len, string }; \
75589 __module_param_call(MODULE_PARAM_PREFIX, name, \
75590 &param_ops_string, \
75591 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75592 */
75593 #define module_param_array_named(name, array, type, nump, perm) \
75594 param_check_##type(name, &(array)[0]); \
75595 - static const struct kparam_array __param_arr_##name \
75596 + static const struct kparam_array __param_arr_##name __used \
75597 = { .max = ARRAY_SIZE(array), .num = nump, \
75598 .ops = &param_ops_##type, \
75599 .elemsize = sizeof(array[0]), .elem = array }; \
75600 diff --git a/include/linux/namei.h b/include/linux/namei.h
75601 index 5a5ff57..5ae5070 100644
75602 --- a/include/linux/namei.h
75603 +++ b/include/linux/namei.h
75604 @@ -19,7 +19,7 @@ struct nameidata {
75605 unsigned seq;
75606 int last_type;
75607 unsigned depth;
75608 - char *saved_names[MAX_NESTED_LINKS + 1];
75609 + const char *saved_names[MAX_NESTED_LINKS + 1];
75610 };
75611
75612 /*
75613 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75614
75615 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75616
75617 -static inline void nd_set_link(struct nameidata *nd, char *path)
75618 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75619 {
75620 nd->saved_names[nd->depth] = path;
75621 }
75622
75623 -static inline char *nd_get_link(struct nameidata *nd)
75624 +static inline const char *nd_get_link(const struct nameidata *nd)
75625 {
75626 return nd->saved_names[nd->depth];
75627 }
75628 diff --git a/include/linux/net.h b/include/linux/net.h
75629 index 4f27575..fc8a65f 100644
75630 --- a/include/linux/net.h
75631 +++ b/include/linux/net.h
75632 @@ -183,7 +183,7 @@ struct net_proto_family {
75633 int (*create)(struct net *net, struct socket *sock,
75634 int protocol, int kern);
75635 struct module *owner;
75636 -};
75637 +} __do_const;
75638
75639 struct iovec;
75640 struct kvec;
75641 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75642 index 9a41568..203d903 100644
75643 --- a/include/linux/netdevice.h
75644 +++ b/include/linux/netdevice.h
75645 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75646 int (*ndo_change_carrier)(struct net_device *dev,
75647 bool new_carrier);
75648 };
75649 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75650
75651 /*
75652 * The DEVICE structure.
75653 @@ -1131,7 +1132,7 @@ struct net_device {
75654 int iflink;
75655
75656 struct net_device_stats stats;
75657 - atomic_long_t rx_dropped; /* dropped packets by core network
75658 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75659 * Do not use this in drivers.
75660 */
75661
75662 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75663 index de70f7b..2675e91 100644
75664 --- a/include/linux/netfilter.h
75665 +++ b/include/linux/netfilter.h
75666 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75667 #endif
75668 /* Use the module struct to lock set/get code in place */
75669 struct module *owner;
75670 -};
75671 +} __do_const;
75672
75673 /* Function to register/unregister hook points. */
75674 int nf_register_hook(struct nf_hook_ops *reg);
75675 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75676 index d80e275..c3510b8 100644
75677 --- a/include/linux/netfilter/ipset/ip_set.h
75678 +++ b/include/linux/netfilter/ipset/ip_set.h
75679 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75680 /* Return true if "b" set is the same as "a"
75681 * according to the create set parameters */
75682 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75683 -};
75684 +} __do_const;
75685
75686 /* The core set type structure */
75687 struct ip_set_type {
75688 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75689 index cadb740..d7c37c0 100644
75690 --- a/include/linux/netfilter/nfnetlink.h
75691 +++ b/include/linux/netfilter/nfnetlink.h
75692 @@ -16,7 +16,7 @@ struct nfnl_callback {
75693 const struct nlattr * const cda[]);
75694 const struct nla_policy *policy; /* netlink attribute policy */
75695 const u_int16_t attr_count; /* number of nlattr's */
75696 -};
75697 +} __do_const;
75698
75699 struct nfnetlink_subsystem {
75700 const char *name;
75701 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75702 new file mode 100644
75703 index 0000000..33f4af8
75704 --- /dev/null
75705 +++ b/include/linux/netfilter/xt_gradm.h
75706 @@ -0,0 +1,9 @@
75707 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75708 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75709 +
75710 +struct xt_gradm_mtinfo {
75711 + __u16 flags;
75712 + __u16 invflags;
75713 +};
75714 +
75715 +#endif
75716 diff --git a/include/linux/nls.h b/include/linux/nls.h
75717 index 5dc635f..35f5e11 100644
75718 --- a/include/linux/nls.h
75719 +++ b/include/linux/nls.h
75720 @@ -31,7 +31,7 @@ struct nls_table {
75721 const unsigned char *charset2upper;
75722 struct module *owner;
75723 struct nls_table *next;
75724 -};
75725 +} __do_const;
75726
75727 /* this value hold the maximum octet of charset */
75728 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75729 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75730 index d14a4c3..a078786 100644
75731 --- a/include/linux/notifier.h
75732 +++ b/include/linux/notifier.h
75733 @@ -54,7 +54,8 @@ struct notifier_block {
75734 notifier_fn_t notifier_call;
75735 struct notifier_block __rcu *next;
75736 int priority;
75737 -};
75738 +} __do_const;
75739 +typedef struct notifier_block __no_const notifier_block_no_const;
75740
75741 struct atomic_notifier_head {
75742 spinlock_t lock;
75743 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75744 index a4c5624..79d6d88 100644
75745 --- a/include/linux/oprofile.h
75746 +++ b/include/linux/oprofile.h
75747 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75748 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75749 char const * name, ulong * val);
75750
75751 -/** Create a file for read-only access to an atomic_t. */
75752 +/** Create a file for read-only access to an atomic_unchecked_t. */
75753 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75754 - char const * name, atomic_t * val);
75755 + char const * name, atomic_unchecked_t * val);
75756
75757 /** create a directory */
75758 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75759 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75760 index 8db71dc..a76bf2c 100644
75761 --- a/include/linux/pci_hotplug.h
75762 +++ b/include/linux/pci_hotplug.h
75763 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75764 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75765 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75766 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75767 -};
75768 +} __do_const;
75769 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75770
75771 /**
75772 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75773 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75774 index c43f6ea..2d4416f 100644
75775 --- a/include/linux/perf_event.h
75776 +++ b/include/linux/perf_event.h
75777 @@ -328,8 +328,8 @@ struct perf_event {
75778
75779 enum perf_event_active_state state;
75780 unsigned int attach_state;
75781 - local64_t count;
75782 - atomic64_t child_count;
75783 + local64_t count; /* PaX: fix it one day */
75784 + atomic64_unchecked_t child_count;
75785
75786 /*
75787 * These are the total time in nanoseconds that the event
75788 @@ -380,8 +380,8 @@ struct perf_event {
75789 * These accumulate total time (in nanoseconds) that children
75790 * events have been enabled and running, respectively.
75791 */
75792 - atomic64_t child_total_time_enabled;
75793 - atomic64_t child_total_time_running;
75794 + atomic64_unchecked_t child_total_time_enabled;
75795 + atomic64_unchecked_t child_total_time_running;
75796
75797 /*
75798 * Protect attach/detach and child_list:
75799 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75800 entry->ip[entry->nr++] = ip;
75801 }
75802
75803 -extern int sysctl_perf_event_paranoid;
75804 +extern int sysctl_perf_event_legitimately_concerned;
75805 extern int sysctl_perf_event_mlock;
75806 extern int sysctl_perf_event_sample_rate;
75807 extern int sysctl_perf_cpu_time_max_percent;
75808 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75809 loff_t *ppos);
75810
75811
75812 +static inline bool perf_paranoid_any(void)
75813 +{
75814 + return sysctl_perf_event_legitimately_concerned > 2;
75815 +}
75816 +
75817 static inline bool perf_paranoid_tracepoint_raw(void)
75818 {
75819 - return sysctl_perf_event_paranoid > -1;
75820 + return sysctl_perf_event_legitimately_concerned > -1;
75821 }
75822
75823 static inline bool perf_paranoid_cpu(void)
75824 {
75825 - return sysctl_perf_event_paranoid > 0;
75826 + return sysctl_perf_event_legitimately_concerned > 0;
75827 }
75828
75829 static inline bool perf_paranoid_kernel(void)
75830 {
75831 - return sysctl_perf_event_paranoid > 1;
75832 + return sysctl_perf_event_legitimately_concerned > 1;
75833 }
75834
75835 extern void perf_event_init(void);
75836 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75837 struct device_attribute attr;
75838 u64 id;
75839 const char *event_str;
75840 -};
75841 +} __do_const;
75842
75843 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75844 static struct perf_pmu_events_attr _var = { \
75845 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75846 index b8809fe..ae4ccd0 100644
75847 --- a/include/linux/pipe_fs_i.h
75848 +++ b/include/linux/pipe_fs_i.h
75849 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75850 struct mutex mutex;
75851 wait_queue_head_t wait;
75852 unsigned int nrbufs, curbuf, buffers;
75853 - unsigned int readers;
75854 - unsigned int writers;
75855 - unsigned int files;
75856 - unsigned int waiting_writers;
75857 + atomic_t readers;
75858 + atomic_t writers;
75859 + atomic_t files;
75860 + atomic_t waiting_writers;
75861 unsigned int r_counter;
75862 unsigned int w_counter;
75863 struct page *tmp_page;
75864 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75865 index 5f28cae..3d23723 100644
75866 --- a/include/linux/platform_data/usb-ehci-s5p.h
75867 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75868 @@ -14,7 +14,7 @@
75869 struct s5p_ehci_platdata {
75870 int (*phy_init)(struct platform_device *pdev, int type);
75871 int (*phy_exit)(struct platform_device *pdev, int type);
75872 -};
75873 +} __no_const;
75874
75875 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75876
75877 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75878 index c256c59..8ea94c7 100644
75879 --- a/include/linux/platform_data/usb-ohci-exynos.h
75880 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75881 @@ -14,7 +14,7 @@
75882 struct exynos4_ohci_platdata {
75883 int (*phy_init)(struct platform_device *pdev, int type);
75884 int (*phy_exit)(struct platform_device *pdev, int type);
75885 -};
75886 +} __no_const;
75887
75888 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75889
75890 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75891 index 7c1d252..c5c773e 100644
75892 --- a/include/linux/pm_domain.h
75893 +++ b/include/linux/pm_domain.h
75894 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75895
75896 struct gpd_cpu_data {
75897 unsigned int saved_exit_latency;
75898 - struct cpuidle_state *idle_state;
75899 + cpuidle_state_no_const *idle_state;
75900 };
75901
75902 struct generic_pm_domain {
75903 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75904 index 6fa7cea..7bf6415 100644
75905 --- a/include/linux/pm_runtime.h
75906 +++ b/include/linux/pm_runtime.h
75907 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75908
75909 static inline void pm_runtime_mark_last_busy(struct device *dev)
75910 {
75911 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75912 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75913 }
75914
75915 #else /* !CONFIG_PM_RUNTIME */
75916 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75917 index 195aafc..49a7bc2 100644
75918 --- a/include/linux/pnp.h
75919 +++ b/include/linux/pnp.h
75920 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75921 struct pnp_fixup {
75922 char id[7];
75923 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75924 -};
75925 +} __do_const;
75926
75927 /* config parameters */
75928 #define PNP_CONFIG_NORMAL 0x0001
75929 diff --git a/include/linux/poison.h b/include/linux/poison.h
75930 index 2110a81..13a11bb 100644
75931 --- a/include/linux/poison.h
75932 +++ b/include/linux/poison.h
75933 @@ -19,8 +19,8 @@
75934 * under normal circumstances, used to verify that nobody uses
75935 * non-initialized list entries.
75936 */
75937 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75938 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75939 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75940 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75941
75942 /********** include/linux/timer.h **********/
75943 /*
75944 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75945 index d8b187c3..9a9257a 100644
75946 --- a/include/linux/power/smartreflex.h
75947 +++ b/include/linux/power/smartreflex.h
75948 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75949 int (*notify)(struct omap_sr *sr, u32 status);
75950 u8 notify_flags;
75951 u8 class_type;
75952 -};
75953 +} __do_const;
75954
75955 /**
75956 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75957 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75958 index 4ea1d37..80f4b33 100644
75959 --- a/include/linux/ppp-comp.h
75960 +++ b/include/linux/ppp-comp.h
75961 @@ -84,7 +84,7 @@ struct compressor {
75962 struct module *owner;
75963 /* Extra skb space needed by the compressor algorithm */
75964 unsigned int comp_extra;
75965 -};
75966 +} __do_const;
75967
75968 /*
75969 * The return value from decompress routine is the length of the
75970 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75971 index f5d4723..a6ea2fa 100644
75972 --- a/include/linux/preempt.h
75973 +++ b/include/linux/preempt.h
75974 @@ -18,8 +18,13 @@
75975 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75976 #endif
75977
75978 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75979 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75980 +
75981 #define inc_preempt_count() add_preempt_count(1)
75982 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75983 #define dec_preempt_count() sub_preempt_count(1)
75984 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75985
75986 #define preempt_count() (current_thread_info()->preempt_count)
75987
75988 @@ -64,6 +69,12 @@ do { \
75989 barrier(); \
75990 } while (0)
75991
75992 +#define raw_preempt_disable() \
75993 +do { \
75994 + raw_inc_preempt_count(); \
75995 + barrier(); \
75996 +} while (0)
75997 +
75998 #define sched_preempt_enable_no_resched() \
75999 do { \
76000 barrier(); \
76001 @@ -72,6 +83,12 @@ do { \
76002
76003 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
76004
76005 +#define raw_preempt_enable_no_resched() \
76006 +do { \
76007 + barrier(); \
76008 + raw_dec_preempt_count(); \
76009 +} while (0)
76010 +
76011 #define preempt_enable() \
76012 do { \
76013 preempt_enable_no_resched(); \
76014 @@ -116,8 +133,10 @@ do { \
76015 * region.
76016 */
76017 #define preempt_disable() barrier()
76018 +#define raw_preempt_disable() barrier()
76019 #define sched_preempt_enable_no_resched() barrier()
76020 #define preempt_enable_no_resched() barrier()
76021 +#define raw_preempt_enable_no_resched() barrier()
76022 #define preempt_enable() barrier()
76023
76024 #define preempt_disable_notrace() barrier()
76025 diff --git a/include/linux/printk.h b/include/linux/printk.h
76026 index 22c7052..ad3fa0a 100644
76027 --- a/include/linux/printk.h
76028 +++ b/include/linux/printk.h
76029 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76030 void early_printk(const char *s, ...) { }
76031 #endif
76032
76033 +extern int kptr_restrict;
76034 +
76035 #ifdef CONFIG_PRINTK
76036 asmlinkage __printf(5, 0)
76037 int vprintk_emit(int facility, int level,
76038 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76039
76040 extern int printk_delay_msec;
76041 extern int dmesg_restrict;
76042 -extern int kptr_restrict;
76043
76044 extern void wake_up_klogd(void);
76045
76046 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76047 index 608e60a..c26f864 100644
76048 --- a/include/linux/proc_fs.h
76049 +++ b/include/linux/proc_fs.h
76050 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76051 return proc_create_data(name, mode, parent, proc_fops, NULL);
76052 }
76053
76054 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76055 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76056 +{
76057 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76058 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76059 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76060 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76061 +#else
76062 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76063 +#endif
76064 +}
76065 +
76066 +
76067 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76068 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76069 extern void *PDE_DATA(const struct inode *);
76070 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76071 index 34a1e10..03a6d03 100644
76072 --- a/include/linux/proc_ns.h
76073 +++ b/include/linux/proc_ns.h
76074 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76075 void (*put)(void *ns);
76076 int (*install)(struct nsproxy *nsproxy, void *ns);
76077 unsigned int (*inum)(void *ns);
76078 -};
76079 +} __do_const;
76080
76081 struct proc_ns {
76082 void *ns;
76083 diff --git a/include/linux/random.h b/include/linux/random.h
76084 index 6312dd9..2561947 100644
76085 --- a/include/linux/random.h
76086 +++ b/include/linux/random.h
76087 @@ -10,9 +10,19 @@
76088
76089
76090 extern void add_device_randomness(const void *, unsigned int);
76091 +
76092 +static inline void add_latent_entropy(void)
76093 +{
76094 +
76095 +#ifdef LATENT_ENTROPY_PLUGIN
76096 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76097 +#endif
76098 +
76099 +}
76100 +
76101 extern void add_input_randomness(unsigned int type, unsigned int code,
76102 - unsigned int value);
76103 -extern void add_interrupt_randomness(int irq, int irq_flags);
76104 + unsigned int value) __latent_entropy;
76105 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76106
76107 extern void get_random_bytes(void *buf, int nbytes);
76108 extern void get_random_bytes_arch(void *buf, int nbytes);
76109 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
76110 u32 prandom_u32_state(struct rnd_state *);
76111 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76112
76113 +static inline unsigned long pax_get_random_long(void)
76114 +{
76115 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76116 +}
76117 +
76118 /*
76119 * Handle minimum values for seeds
76120 */
76121 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76122 index 4106721..132d42c 100644
76123 --- a/include/linux/rculist.h
76124 +++ b/include/linux/rculist.h
76125 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76126 struct list_head *prev, struct list_head *next);
76127 #endif
76128
76129 +extern void __pax_list_add_rcu(struct list_head *new,
76130 + struct list_head *prev, struct list_head *next);
76131 +
76132 /**
76133 * list_add_rcu - add a new entry to rcu-protected list
76134 * @new: new entry to be added
76135 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76136 __list_add_rcu(new, head, head->next);
76137 }
76138
76139 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76140 +{
76141 + __pax_list_add_rcu(new, head, head->next);
76142 +}
76143 +
76144 /**
76145 * list_add_tail_rcu - add a new entry to rcu-protected list
76146 * @new: new entry to be added
76147 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76148 __list_add_rcu(new, head->prev, head);
76149 }
76150
76151 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76152 + struct list_head *head)
76153 +{
76154 + __pax_list_add_rcu(new, head->prev, head);
76155 +}
76156 +
76157 /**
76158 * list_del_rcu - deletes entry from list without re-initialization
76159 * @entry: the element to delete from the list.
76160 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76161 entry->prev = LIST_POISON2;
76162 }
76163
76164 +extern void pax_list_del_rcu(struct list_head *entry);
76165 +
76166 /**
76167 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76168 * @n: the element to delete from the hash list.
76169 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76170 index 8e00f9f..9449b55 100644
76171 --- a/include/linux/reboot.h
76172 +++ b/include/linux/reboot.h
76173 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76174 * Architecture-specific implementations of sys_reboot commands.
76175 */
76176
76177 -extern void machine_restart(char *cmd);
76178 -extern void machine_halt(void);
76179 -extern void machine_power_off(void);
76180 +extern void machine_restart(char *cmd) __noreturn;
76181 +extern void machine_halt(void) __noreturn;
76182 +extern void machine_power_off(void) __noreturn;
76183
76184 extern void machine_shutdown(void);
76185 struct pt_regs;
76186 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76187 */
76188
76189 extern void kernel_restart_prepare(char *cmd);
76190 -extern void kernel_restart(char *cmd);
76191 -extern void kernel_halt(void);
76192 -extern void kernel_power_off(void);
76193 +extern void kernel_restart(char *cmd) __noreturn;
76194 +extern void kernel_halt(void) __noreturn;
76195 +extern void kernel_power_off(void) __noreturn;
76196
76197 extern int C_A_D; /* for sysctl */
76198 void ctrl_alt_del(void);
76199 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76200 * Emergency restart, callable from an interrupt handler.
76201 */
76202
76203 -extern void emergency_restart(void);
76204 +extern void emergency_restart(void) __noreturn;
76205 #include <asm/emergency-restart.h>
76206
76207 #endif /* _LINUX_REBOOT_H */
76208 diff --git a/include/linux/regset.h b/include/linux/regset.h
76209 index 8e0c9fe..ac4d221 100644
76210 --- a/include/linux/regset.h
76211 +++ b/include/linux/regset.h
76212 @@ -161,7 +161,8 @@ struct user_regset {
76213 unsigned int align;
76214 unsigned int bias;
76215 unsigned int core_note_type;
76216 -};
76217 +} __do_const;
76218 +typedef struct user_regset __no_const user_regset_no_const;
76219
76220 /**
76221 * struct user_regset_view - available regsets
76222 diff --git a/include/linux/relay.h b/include/linux/relay.h
76223 index d7c8359..818daf5 100644
76224 --- a/include/linux/relay.h
76225 +++ b/include/linux/relay.h
76226 @@ -157,7 +157,7 @@ struct rchan_callbacks
76227 * The callback should return 0 if successful, negative if not.
76228 */
76229 int (*remove_buf_file)(struct dentry *dentry);
76230 -};
76231 +} __no_const;
76232
76233 /*
76234 * CONFIG_RELAY kernel API, kernel/relay.c
76235 diff --git a/include/linux/rio.h b/include/linux/rio.h
76236 index b71d573..2f940bd 100644
76237 --- a/include/linux/rio.h
76238 +++ b/include/linux/rio.h
76239 @@ -355,7 +355,7 @@ struct rio_ops {
76240 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76241 u64 rstart, u32 size, u32 flags);
76242 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76243 -};
76244 +} __no_const;
76245
76246 #define RIO_RESOURCE_MEM 0x00000100
76247 #define RIO_RESOURCE_DOORBELL 0x00000200
76248 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76249 index 6dacb93..6174423 100644
76250 --- a/include/linux/rmap.h
76251 +++ b/include/linux/rmap.h
76252 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76253 void anon_vma_init(void); /* create anon_vma_cachep */
76254 int anon_vma_prepare(struct vm_area_struct *);
76255 void unlink_anon_vmas(struct vm_area_struct *);
76256 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76257 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76258 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76259 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76260
76261 static inline void anon_vma_merge(struct vm_area_struct *vma,
76262 struct vm_area_struct *next)
76263 diff --git a/include/linux/sched.h b/include/linux/sched.h
76264 index 078066d..4090b3b 100644
76265 --- a/include/linux/sched.h
76266 +++ b/include/linux/sched.h
76267 @@ -62,6 +62,7 @@ struct bio_list;
76268 struct fs_struct;
76269 struct perf_event_context;
76270 struct blk_plug;
76271 +struct linux_binprm;
76272
76273 /*
76274 * List of flags we want to share for kernel threads,
76275 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76276 extern int in_sched_functions(unsigned long addr);
76277
76278 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76279 -extern signed long schedule_timeout(signed long timeout);
76280 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76281 extern signed long schedule_timeout_interruptible(signed long timeout);
76282 extern signed long schedule_timeout_killable(signed long timeout);
76283 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76284 @@ -314,6 +315,19 @@ struct nsproxy;
76285 struct user_namespace;
76286
76287 #ifdef CONFIG_MMU
76288 +
76289 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76290 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76291 +#else
76292 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76293 +{
76294 + return 0;
76295 +}
76296 +#endif
76297 +
76298 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76299 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76300 +
76301 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76302 extern unsigned long
76303 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76304 @@ -589,6 +603,17 @@ struct signal_struct {
76305 #ifdef CONFIG_TASKSTATS
76306 struct taskstats *stats;
76307 #endif
76308 +
76309 +#ifdef CONFIG_GRKERNSEC
76310 + u32 curr_ip;
76311 + u32 saved_ip;
76312 + u32 gr_saddr;
76313 + u32 gr_daddr;
76314 + u16 gr_sport;
76315 + u16 gr_dport;
76316 + u8 used_accept:1;
76317 +#endif
76318 +
76319 #ifdef CONFIG_AUDIT
76320 unsigned audit_tty;
76321 unsigned audit_tty_log_passwd;
76322 @@ -669,6 +694,14 @@ struct user_struct {
76323 struct key *session_keyring; /* UID's default session keyring */
76324 #endif
76325
76326 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76327 + unsigned char kernel_banned;
76328 +#endif
76329 +#ifdef CONFIG_GRKERNSEC_BRUTE
76330 + unsigned char suid_banned;
76331 + unsigned long suid_ban_expires;
76332 +#endif
76333 +
76334 /* Hash table maintenance information */
76335 struct hlist_node uidhash_node;
76336 kuid_t uid;
76337 @@ -1151,8 +1184,8 @@ struct task_struct {
76338 struct list_head thread_group;
76339
76340 struct completion *vfork_done; /* for vfork() */
76341 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76342 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76343 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76344 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76345
76346 cputime_t utime, stime, utimescaled, stimescaled;
76347 cputime_t gtime;
76348 @@ -1177,11 +1210,6 @@ struct task_struct {
76349 struct task_cputime cputime_expires;
76350 struct list_head cpu_timers[3];
76351
76352 -/* process credentials */
76353 - const struct cred __rcu *real_cred; /* objective and real subjective task
76354 - * credentials (COW) */
76355 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76356 - * credentials (COW) */
76357 char comm[TASK_COMM_LEN]; /* executable name excluding path
76358 - access with [gs]et_task_comm (which lock
76359 it with task_lock())
76360 @@ -1198,6 +1226,10 @@ struct task_struct {
76361 #endif
76362 /* CPU-specific state of this task */
76363 struct thread_struct thread;
76364 +/* thread_info moved to task_struct */
76365 +#ifdef CONFIG_X86
76366 + struct thread_info tinfo;
76367 +#endif
76368 /* filesystem information */
76369 struct fs_struct *fs;
76370 /* open file information */
76371 @@ -1271,6 +1303,10 @@ struct task_struct {
76372 gfp_t lockdep_reclaim_gfp;
76373 #endif
76374
76375 +/* process credentials */
76376 + const struct cred __rcu *real_cred; /* objective and real subjective task
76377 + * credentials (COW) */
76378 +
76379 /* journalling filesystem info */
76380 void *journal_info;
76381
76382 @@ -1309,6 +1345,10 @@ struct task_struct {
76383 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76384 struct list_head cg_list;
76385 #endif
76386 +
76387 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76388 + * credentials (COW) */
76389 +
76390 #ifdef CONFIG_FUTEX
76391 struct robust_list_head __user *robust_list;
76392 #ifdef CONFIG_COMPAT
76393 @@ -1406,8 +1446,76 @@ struct task_struct {
76394 unsigned int sequential_io;
76395 unsigned int sequential_io_avg;
76396 #endif
76397 +
76398 +#ifdef CONFIG_GRKERNSEC
76399 + /* grsecurity */
76400 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76401 + u64 exec_id;
76402 +#endif
76403 +#ifdef CONFIG_GRKERNSEC_SETXID
76404 + const struct cred *delayed_cred;
76405 +#endif
76406 + struct dentry *gr_chroot_dentry;
76407 + struct acl_subject_label *acl;
76408 + struct acl_role_label *role;
76409 + struct file *exec_file;
76410 + unsigned long brute_expires;
76411 + u16 acl_role_id;
76412 + /* is this the task that authenticated to the special role */
76413 + u8 acl_sp_role;
76414 + u8 is_writable;
76415 + u8 brute;
76416 + u8 gr_is_chrooted;
76417 +#endif
76418 +
76419 };
76420
76421 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76422 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76423 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76424 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76425 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76426 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76427 +
76428 +#ifdef CONFIG_PAX_SOFTMODE
76429 +extern int pax_softmode;
76430 +#endif
76431 +
76432 +extern int pax_check_flags(unsigned long *);
76433 +
76434 +/* if tsk != current then task_lock must be held on it */
76435 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76436 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76437 +{
76438 + if (likely(tsk->mm))
76439 + return tsk->mm->pax_flags;
76440 + else
76441 + return 0UL;
76442 +}
76443 +
76444 +/* if tsk != current then task_lock must be held on it */
76445 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76446 +{
76447 + if (likely(tsk->mm)) {
76448 + tsk->mm->pax_flags = flags;
76449 + return 0;
76450 + }
76451 + return -EINVAL;
76452 +}
76453 +#endif
76454 +
76455 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76456 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76457 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76458 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76459 +#endif
76460 +
76461 +struct path;
76462 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76463 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76464 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76465 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76466 +
76467 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76468 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76469
76470 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76471 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76472 struct pid_namespace *ns);
76473
76474 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76475 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76476 {
76477 return tsk->pid;
76478 }
76479 @@ -1916,7 +2024,9 @@ void yield(void);
76480 extern struct exec_domain default_exec_domain;
76481
76482 union thread_union {
76483 +#ifndef CONFIG_X86
76484 struct thread_info thread_info;
76485 +#endif
76486 unsigned long stack[THREAD_SIZE/sizeof(long)];
76487 };
76488
76489 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76490 */
76491
76492 extern struct task_struct *find_task_by_vpid(pid_t nr);
76493 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76494 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76495 struct pid_namespace *ns);
76496
76497 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76498 extern void exit_itimers(struct signal_struct *);
76499 extern void flush_itimer_signals(void);
76500
76501 -extern void do_group_exit(int);
76502 +extern __noreturn void do_group_exit(int);
76503
76504 extern int allow_signal(int);
76505 extern int disallow_signal(int);
76506 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76507
76508 #endif
76509
76510 -static inline int object_is_on_stack(void *obj)
76511 +static inline int object_starts_on_stack(void *obj)
76512 {
76513 - void *stack = task_stack_page(current);
76514 + const void *stack = task_stack_page(current);
76515
76516 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76517 }
76518 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76519 index bf8086b..962b035 100644
76520 --- a/include/linux/sched/sysctl.h
76521 +++ b/include/linux/sched/sysctl.h
76522 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76523 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76524
76525 extern int sysctl_max_map_count;
76526 +extern unsigned long sysctl_heap_stack_gap;
76527
76528 extern unsigned int sysctl_sched_latency;
76529 extern unsigned int sysctl_sched_min_granularity;
76530 diff --git a/include/linux/security.h b/include/linux/security.h
76531 index 7ce53ae..8ee24a5 100644
76532 --- a/include/linux/security.h
76533 +++ b/include/linux/security.h
76534 @@ -27,6 +27,7 @@
76535 #include <linux/slab.h>
76536 #include <linux/err.h>
76537 #include <linux/string.h>
76538 +#include <linux/grsecurity.h>
76539
76540 struct linux_binprm;
76541 struct cred;
76542 @@ -116,8 +117,6 @@ struct seq_file;
76543
76544 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76545
76546 -void reset_security_ops(void);
76547 -
76548 #ifdef CONFIG_MMU
76549 extern unsigned long mmap_min_addr;
76550 extern unsigned long dac_mmap_min_addr;
76551 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76552 index 4e32edc..f8f2d18 100644
76553 --- a/include/linux/seq_file.h
76554 +++ b/include/linux/seq_file.h
76555 @@ -26,6 +26,9 @@ struct seq_file {
76556 struct mutex lock;
76557 const struct seq_operations *op;
76558 int poll_event;
76559 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76560 + u64 exec_id;
76561 +#endif
76562 #ifdef CONFIG_USER_NS
76563 struct user_namespace *user_ns;
76564 #endif
76565 @@ -38,6 +41,7 @@ struct seq_operations {
76566 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76567 int (*show) (struct seq_file *m, void *v);
76568 };
76569 +typedef struct seq_operations __no_const seq_operations_no_const;
76570
76571 #define SEQ_SKIP 1
76572
76573 diff --git a/include/linux/shm.h b/include/linux/shm.h
76574 index 429c199..4d42e38 100644
76575 --- a/include/linux/shm.h
76576 +++ b/include/linux/shm.h
76577 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76578
76579 /* The task created the shm object. NULL if the task is dead. */
76580 struct task_struct *shm_creator;
76581 +#ifdef CONFIG_GRKERNSEC
76582 + time_t shm_createtime;
76583 + pid_t shm_lapid;
76584 +#endif
76585 };
76586
76587 /* shm_mode upper byte flags */
76588 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76589 index 3b71a4e..4823435 100644
76590 --- a/include/linux/skbuff.h
76591 +++ b/include/linux/skbuff.h
76592 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76593 extern struct sk_buff *__alloc_skb(unsigned int size,
76594 gfp_t priority, int flags, int node);
76595 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76596 -static inline struct sk_buff *alloc_skb(unsigned int size,
76597 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76598 gfp_t priority)
76599 {
76600 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76601 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76602 */
76603 static inline int skb_queue_empty(const struct sk_buff_head *list)
76604 {
76605 - return list->next == (struct sk_buff *)list;
76606 + return list->next == (const struct sk_buff *)list;
76607 }
76608
76609 /**
76610 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76611 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76612 const struct sk_buff *skb)
76613 {
76614 - return skb->next == (struct sk_buff *)list;
76615 + return skb->next == (const struct sk_buff *)list;
76616 }
76617
76618 /**
76619 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76620 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76621 const struct sk_buff *skb)
76622 {
76623 - return skb->prev == (struct sk_buff *)list;
76624 + return skb->prev == (const struct sk_buff *)list;
76625 }
76626
76627 /**
76628 @@ -1316,6 +1316,11 @@ static inline int skb_pagelen(const struct sk_buff *skb)
76629 return len + skb_headlen(skb);
76630 }
76631
76632 +static inline bool skb_has_frags(const struct sk_buff *skb)
76633 +{
76634 + return skb_shinfo(skb)->nr_frags;
76635 +}
76636 +
76637 /**
76638 * __skb_fill_page_desc - initialise a paged fragment in an skb
76639 * @skb: buffer containing fragment to be initialised
76640 @@ -1750,7 +1755,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76641 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76642 */
76643 #ifndef NET_SKB_PAD
76644 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76645 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76646 #endif
76647
76648 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76649 @@ -2345,7 +2350,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76650 int noblock, int *err);
76651 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76652 struct poll_table_struct *wait);
76653 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76654 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76655 int offset, struct iovec *to,
76656 int size);
76657 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76658 @@ -2636,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
76659 nf_bridge_put(skb->nf_bridge);
76660 skb->nf_bridge = NULL;
76661 #endif
76662 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76663 + skb->nf_trace = 0;
76664 +#endif
76665 }
76666
76667 static inline void nf_reset_trace(struct sk_buff *skb)
76668 diff --git a/include/linux/slab.h b/include/linux/slab.h
76669 index 6c5cc0e..9ca0fd6 100644
76670 --- a/include/linux/slab.h
76671 +++ b/include/linux/slab.h
76672 @@ -12,15 +12,29 @@
76673 #include <linux/gfp.h>
76674 #include <linux/types.h>
76675 #include <linux/workqueue.h>
76676 -
76677 +#include <linux/err.h>
76678
76679 /*
76680 * Flags to pass to kmem_cache_create().
76681 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76682 */
76683 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76684 +
76685 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76686 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76687 +#else
76688 +#define SLAB_USERCOPY 0x00000000UL
76689 +#endif
76690 +
76691 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76692 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76693 +
76694 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76695 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76696 +#else
76697 +#define SLAB_NO_SANITIZE 0x00000000UL
76698 +#endif
76699 +
76700 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76701 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76702 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76703 @@ -89,10 +103,13 @@
76704 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76705 * Both make kfree a no-op.
76706 */
76707 -#define ZERO_SIZE_PTR ((void *)16)
76708 +#define ZERO_SIZE_PTR \
76709 +({ \
76710 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76711 + (void *)(-MAX_ERRNO-1L); \
76712 +})
76713
76714 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76715 - (unsigned long)ZERO_SIZE_PTR)
76716 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76717
76718
76719 struct mem_cgroup;
76720 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76721 void kfree(const void *);
76722 void kzfree(const void *);
76723 size_t ksize(const void *);
76724 +const char *check_heap_object(const void *ptr, unsigned long n);
76725 +bool is_usercopy_object(const void *ptr);
76726
76727 /*
76728 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76729 @@ -164,7 +183,7 @@ struct kmem_cache {
76730 unsigned int align; /* Alignment as calculated */
76731 unsigned long flags; /* Active flags on the slab */
76732 const char *name; /* Slab name for sysfs */
76733 - int refcount; /* Use counter */
76734 + atomic_t refcount; /* Use counter */
76735 void (*ctor)(void *); /* Called on object slot creation */
76736 struct list_head list; /* List of all slab caches on the system */
76737 };
76738 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76739 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76740 #endif
76741
76742 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76743 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76744 +#endif
76745 +
76746 /*
76747 * Figure out which kmalloc slab an allocation of a certain size
76748 * belongs to.
76749 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76750 * 2 = 120 .. 192 bytes
76751 * n = 2^(n-1) .. 2^n -1
76752 */
76753 -static __always_inline int kmalloc_index(size_t size)
76754 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76755 {
76756 if (!size)
76757 return 0;
76758 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76759 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76760 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76761 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76762 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76763 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76764 #define kmalloc_track_caller(size, flags) \
76765 __kmalloc_track_caller(size, flags, _RET_IP_)
76766 #else
76767 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76768 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76769 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76770 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76771 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76772 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76773 #define kmalloc_node_track_caller(size, flags, node) \
76774 __kmalloc_node_track_caller(size, flags, node, \
76775 _RET_IP_)
76776 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76777 index cd40158..4e2f7af 100644
76778 --- a/include/linux/slab_def.h
76779 +++ b/include/linux/slab_def.h
76780 @@ -50,7 +50,7 @@ struct kmem_cache {
76781 /* 4) cache creation/removal */
76782 const char *name;
76783 struct list_head list;
76784 - int refcount;
76785 + atomic_t refcount;
76786 int object_size;
76787 int align;
76788
76789 @@ -66,10 +66,14 @@ struct kmem_cache {
76790 unsigned long node_allocs;
76791 unsigned long node_frees;
76792 unsigned long node_overflow;
76793 - atomic_t allochit;
76794 - atomic_t allocmiss;
76795 - atomic_t freehit;
76796 - atomic_t freemiss;
76797 + atomic_unchecked_t allochit;
76798 + atomic_unchecked_t allocmiss;
76799 + atomic_unchecked_t freehit;
76800 + atomic_unchecked_t freemiss;
76801 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76802 + atomic_unchecked_t sanitized;
76803 + atomic_unchecked_t not_sanitized;
76804 +#endif
76805
76806 /*
76807 * If debugging is enabled, then the allocator can add additional
76808 @@ -103,7 +107,7 @@ struct kmem_cache {
76809 };
76810
76811 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76812 -void *__kmalloc(size_t size, gfp_t flags);
76813 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76814
76815 #ifdef CONFIG_TRACING
76816 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76817 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76818 cachep = kmalloc_dma_caches[i];
76819 else
76820 #endif
76821 +
76822 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76823 + if (flags & GFP_USERCOPY)
76824 + cachep = kmalloc_usercopy_caches[i];
76825 + else
76826 +#endif
76827 +
76828 cachep = kmalloc_caches[i];
76829
76830 ret = kmem_cache_alloc_trace(cachep, flags, size);
76831 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76832 }
76833
76834 #ifdef CONFIG_NUMA
76835 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76836 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76837 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76838
76839 #ifdef CONFIG_TRACING
76840 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76841 cachep = kmalloc_dma_caches[i];
76842 else
76843 #endif
76844 +
76845 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76846 + if (flags & GFP_USERCOPY)
76847 + cachep = kmalloc_usercopy_caches[i];
76848 + else
76849 +#endif
76850 +
76851 cachep = kmalloc_caches[i];
76852
76853 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76854 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76855 index 095a5a4..4b82027 100644
76856 --- a/include/linux/slob_def.h
76857 +++ b/include/linux/slob_def.h
76858 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76859 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76860 }
76861
76862 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76863 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76864
76865 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76866 {
76867 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76868 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76869 }
76870
76871 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76872 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76873 {
76874 return kmalloc(size, flags);
76875 }
76876 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76877 index 027276f..092bfe8 100644
76878 --- a/include/linux/slub_def.h
76879 +++ b/include/linux/slub_def.h
76880 @@ -80,7 +80,7 @@ struct kmem_cache {
76881 struct kmem_cache_order_objects max;
76882 struct kmem_cache_order_objects min;
76883 gfp_t allocflags; /* gfp flags to use on each alloc */
76884 - int refcount; /* Refcount for slab cache destroy */
76885 + atomic_t refcount; /* Refcount for slab cache destroy */
76886 void (*ctor)(void *);
76887 int inuse; /* Offset to metadata */
76888 int align; /* Alignment */
76889 @@ -105,7 +105,7 @@ struct kmem_cache {
76890 };
76891
76892 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76893 -void *__kmalloc(size_t size, gfp_t flags);
76894 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76895
76896 static __always_inline void *
76897 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76898 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76899 }
76900 #endif
76901
76902 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76903 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76904 {
76905 unsigned int order = get_order(size);
76906 return kmalloc_order_trace(size, flags, order);
76907 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76908 }
76909
76910 #ifdef CONFIG_NUMA
76911 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76912 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76913 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76914
76915 #ifdef CONFIG_TRACING
76916 diff --git a/include/linux/smp.h b/include/linux/smp.h
76917 index c181399..09d7b92 100644
76918 --- a/include/linux/smp.h
76919 +++ b/include/linux/smp.h
76920 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76921 #endif
76922
76923 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76924 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76925 #define put_cpu() preempt_enable()
76926 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76927
76928 /*
76929 * Callback to arch code if there's nosmp or maxcpus=0 on the
76930 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76931 index 54f91d3..be2c379 100644
76932 --- a/include/linux/sock_diag.h
76933 +++ b/include/linux/sock_diag.h
76934 @@ -11,7 +11,7 @@ struct sock;
76935 struct sock_diag_handler {
76936 __u8 family;
76937 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76938 -};
76939 +} __do_const;
76940
76941 int sock_diag_register(const struct sock_diag_handler *h);
76942 void sock_diag_unregister(const struct sock_diag_handler *h);
76943 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76944 index 680f9a3..f13aeb0 100644
76945 --- a/include/linux/sonet.h
76946 +++ b/include/linux/sonet.h
76947 @@ -7,7 +7,7 @@
76948 #include <uapi/linux/sonet.h>
76949
76950 struct k_sonet_stats {
76951 -#define __HANDLE_ITEM(i) atomic_t i
76952 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76953 __SONET_ITEMS
76954 #undef __HANDLE_ITEM
76955 };
76956 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76957 index 07d8e53..dc934c9 100644
76958 --- a/include/linux/sunrpc/addr.h
76959 +++ b/include/linux/sunrpc/addr.h
76960 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76961 {
76962 switch (sap->sa_family) {
76963 case AF_INET:
76964 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76965 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76966 case AF_INET6:
76967 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76968 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76969 }
76970 return 0;
76971 }
76972 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76973 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76974 const struct sockaddr *src)
76975 {
76976 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76977 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76978 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76979
76980 dsin->sin_family = ssin->sin_family;
76981 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76982 if (sa->sa_family != AF_INET6)
76983 return 0;
76984
76985 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76986 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76987 }
76988
76989 #endif /* _LINUX_SUNRPC_ADDR_H */
76990 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76991 index bfe11be..12bc8c4 100644
76992 --- a/include/linux/sunrpc/clnt.h
76993 +++ b/include/linux/sunrpc/clnt.h
76994 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76995 unsigned int p_timer; /* Which RTT timer to use */
76996 u32 p_statidx; /* Which procedure to account */
76997 const char * p_name; /* name of procedure */
76998 -};
76999 +} __do_const;
77000
77001 #ifdef __KERNEL__
77002
77003 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
77004 index 1f0216b..6a4fa50 100644
77005 --- a/include/linux/sunrpc/svc.h
77006 +++ b/include/linux/sunrpc/svc.h
77007 @@ -411,7 +411,7 @@ struct svc_procedure {
77008 unsigned int pc_count; /* call count */
77009 unsigned int pc_cachetype; /* cache info (NFS) */
77010 unsigned int pc_xdrressize; /* maximum size of XDR reply */
77011 -};
77012 +} __do_const;
77013
77014 /*
77015 * Function prototypes.
77016 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
77017 index 0b8e3e6..33e0a01 100644
77018 --- a/include/linux/sunrpc/svc_rdma.h
77019 +++ b/include/linux/sunrpc/svc_rdma.h
77020 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
77021 extern unsigned int svcrdma_max_requests;
77022 extern unsigned int svcrdma_max_req_size;
77023
77024 -extern atomic_t rdma_stat_recv;
77025 -extern atomic_t rdma_stat_read;
77026 -extern atomic_t rdma_stat_write;
77027 -extern atomic_t rdma_stat_sq_starve;
77028 -extern atomic_t rdma_stat_rq_starve;
77029 -extern atomic_t rdma_stat_rq_poll;
77030 -extern atomic_t rdma_stat_rq_prod;
77031 -extern atomic_t rdma_stat_sq_poll;
77032 -extern atomic_t rdma_stat_sq_prod;
77033 +extern atomic_unchecked_t rdma_stat_recv;
77034 +extern atomic_unchecked_t rdma_stat_read;
77035 +extern atomic_unchecked_t rdma_stat_write;
77036 +extern atomic_unchecked_t rdma_stat_sq_starve;
77037 +extern atomic_unchecked_t rdma_stat_rq_starve;
77038 +extern atomic_unchecked_t rdma_stat_rq_poll;
77039 +extern atomic_unchecked_t rdma_stat_rq_prod;
77040 +extern atomic_unchecked_t rdma_stat_sq_poll;
77041 +extern atomic_unchecked_t rdma_stat_sq_prod;
77042
77043 #define RPCRDMA_VERSION 1
77044
77045 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77046 index 8d71d65..f79586e 100644
77047 --- a/include/linux/sunrpc/svcauth.h
77048 +++ b/include/linux/sunrpc/svcauth.h
77049 @@ -120,7 +120,7 @@ struct auth_ops {
77050 int (*release)(struct svc_rqst *rq);
77051 void (*domain_release)(struct auth_domain *);
77052 int (*set_client)(struct svc_rqst *rq);
77053 -};
77054 +} __do_const;
77055
77056 #define SVC_GARBAGE 1
77057 #define SVC_SYSERR 2
77058 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77059 index a5ffd32..0935dea 100644
77060 --- a/include/linux/swiotlb.h
77061 +++ b/include/linux/swiotlb.h
77062 @@ -60,7 +60,8 @@ extern void
77063
77064 extern void
77065 swiotlb_free_coherent(struct device *hwdev, size_t size,
77066 - void *vaddr, dma_addr_t dma_handle);
77067 + void *vaddr, dma_addr_t dma_handle,
77068 + struct dma_attrs *attrs);
77069
77070 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77071 unsigned long offset, size_t size,
77072 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77073 index 84662ec..5271947 100644
77074 --- a/include/linux/syscalls.h
77075 +++ b/include/linux/syscalls.h
77076 @@ -97,8 +97,14 @@ struct sigaltstack;
77077 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77078
77079 #define __SC_DECL(t, a) t a
77080 +#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))
77081 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77082 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77083 +#define __SC_LONG(t, a) __typeof( \
77084 + __builtin_choose_expr( \
77085 + sizeof(t) > sizeof(int), \
77086 + (t) 0, \
77087 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77088 + )) a
77089 #define __SC_CAST(t, a) (t) a
77090 #define __SC_ARGS(t, a) a
77091 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77092 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77093 asmlinkage long sys_fsync(unsigned int fd);
77094 asmlinkage long sys_fdatasync(unsigned int fd);
77095 asmlinkage long sys_bdflush(int func, long data);
77096 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77097 - char __user *type, unsigned long flags,
77098 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77099 + const char __user *type, unsigned long flags,
77100 void __user *data);
77101 -asmlinkage long sys_umount(char __user *name, int flags);
77102 -asmlinkage long sys_oldumount(char __user *name);
77103 +asmlinkage long sys_umount(const char __user *name, int flags);
77104 +asmlinkage long sys_oldumount(const char __user *name);
77105 asmlinkage long sys_truncate(const char __user *path, long length);
77106 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77107 asmlinkage long sys_stat(const char __user *filename,
77108 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77109 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77110 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77111 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77112 - struct sockaddr __user *, int);
77113 + struct sockaddr __user *, int) __intentional_overflow(0);
77114 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77115 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77116 unsigned int vlen, unsigned flags);
77117 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77118 index 27b3b0b..e093dd9 100644
77119 --- a/include/linux/syscore_ops.h
77120 +++ b/include/linux/syscore_ops.h
77121 @@ -16,7 +16,7 @@ struct syscore_ops {
77122 int (*suspend)(void);
77123 void (*resume)(void);
77124 void (*shutdown)(void);
77125 -};
77126 +} __do_const;
77127
77128 extern void register_syscore_ops(struct syscore_ops *ops);
77129 extern void unregister_syscore_ops(struct syscore_ops *ops);
77130 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77131 index 14a8ff2..af52bad 100644
77132 --- a/include/linux/sysctl.h
77133 +++ b/include/linux/sysctl.h
77134 @@ -34,13 +34,13 @@ struct ctl_table_root;
77135 struct ctl_table_header;
77136 struct ctl_dir;
77137
77138 -typedef struct ctl_table ctl_table;
77139 -
77140 typedef int proc_handler (struct ctl_table *ctl, int write,
77141 void __user *buffer, size_t *lenp, loff_t *ppos);
77142
77143 extern int proc_dostring(struct ctl_table *, int,
77144 void __user *, size_t *, loff_t *);
77145 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77146 + void __user *, size_t *, loff_t *);
77147 extern int proc_dointvec(struct ctl_table *, int,
77148 void __user *, size_t *, loff_t *);
77149 extern int proc_dointvec_minmax(struct ctl_table *, int,
77150 @@ -115,7 +115,9 @@ struct ctl_table
77151 struct ctl_table_poll *poll;
77152 void *extra1;
77153 void *extra2;
77154 -};
77155 +} __do_const;
77156 +typedef struct ctl_table __no_const ctl_table_no_const;
77157 +typedef struct ctl_table ctl_table;
77158
77159 struct ctl_node {
77160 struct rb_node node;
77161 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77162 index 9e8a9b5..753de68 100644
77163 --- a/include/linux/sysfs.h
77164 +++ b/include/linux/sysfs.h
77165 @@ -33,7 +33,8 @@ struct attribute {
77166 struct lock_class_key *key;
77167 struct lock_class_key skey;
77168 #endif
77169 -};
77170 +} __do_const;
77171 +typedef struct attribute __no_const attribute_no_const;
77172
77173 /**
77174 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77175 @@ -62,7 +63,8 @@ struct attribute_group {
77176 struct attribute *, int);
77177 struct attribute **attrs;
77178 struct bin_attribute **bin_attrs;
77179 -};
77180 +} __do_const;
77181 +typedef struct attribute_group __no_const attribute_group_no_const;
77182
77183 /**
77184 * Use these macros to make defining attributes easier. See include/linux/device.h
77185 @@ -123,7 +125,8 @@ struct bin_attribute {
77186 char *, loff_t, size_t);
77187 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77188 struct vm_area_struct *vma);
77189 -};
77190 +} __do_const;
77191 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77192
77193 /**
77194 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77195 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77196 index 7faf933..9b85a0c 100644
77197 --- a/include/linux/sysrq.h
77198 +++ b/include/linux/sysrq.h
77199 @@ -16,6 +16,7 @@
77200
77201 #include <linux/errno.h>
77202 #include <linux/types.h>
77203 +#include <linux/compiler.h>
77204
77205 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77206 #define SYSRQ_DEFAULT_ENABLE 1
77207 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77208 char *help_msg;
77209 char *action_msg;
77210 int enable_mask;
77211 -};
77212 +} __do_const;
77213
77214 #ifdef CONFIG_MAGIC_SYSRQ
77215
77216 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77217 index e7e0473..7989295 100644
77218 --- a/include/linux/thread_info.h
77219 +++ b/include/linux/thread_info.h
77220 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77221 #error "no set_restore_sigmask() provided and default one won't work"
77222 #endif
77223
77224 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77225 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77226 +{
77227 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77228 + if (!__builtin_constant_p(n))
77229 +#endif
77230 + __check_object_size(ptr, n, to_user);
77231 +}
77232 +
77233 #endif /* __KERNEL__ */
77234
77235 #endif /* _LINUX_THREAD_INFO_H */
77236 diff --git a/include/linux/tty.h b/include/linux/tty.h
77237 index 01ac30e..bf18a71 100644
77238 --- a/include/linux/tty.h
77239 +++ b/include/linux/tty.h
77240 @@ -194,7 +194,7 @@ struct tty_port {
77241 const struct tty_port_operations *ops; /* Port operations */
77242 spinlock_t lock; /* Lock protecting tty field */
77243 int blocked_open; /* Waiting to open */
77244 - int count; /* Usage count */
77245 + atomic_t count; /* Usage count */
77246 wait_queue_head_t open_wait; /* Open waiters */
77247 wait_queue_head_t close_wait; /* Close waiters */
77248 wait_queue_head_t delta_msr_wait; /* Modem status change */
77249 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77250 struct tty_struct *tty, struct file *filp);
77251 static inline int tty_port_users(struct tty_port *port)
77252 {
77253 - return port->count + port->blocked_open;
77254 + return atomic_read(&port->count) + port->blocked_open;
77255 }
77256
77257 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77258 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77259 index 756a609..b302dd6 100644
77260 --- a/include/linux/tty_driver.h
77261 +++ b/include/linux/tty_driver.h
77262 @@ -285,7 +285,7 @@ struct tty_operations {
77263 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77264 #endif
77265 const struct file_operations *proc_fops;
77266 -};
77267 +} __do_const;
77268
77269 struct tty_driver {
77270 int magic; /* magic number for this structure */
77271 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77272 index a1b0489..f02e17c 100644
77273 --- a/include/linux/tty_ldisc.h
77274 +++ b/include/linux/tty_ldisc.h
77275 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77276
77277 struct module *owner;
77278
77279 - int refcount;
77280 + atomic_t refcount;
77281 };
77282
77283 struct tty_ldisc {
77284 diff --git a/include/linux/types.h b/include/linux/types.h
77285 index 4d118ba..c3ee9bf 100644
77286 --- a/include/linux/types.h
77287 +++ b/include/linux/types.h
77288 @@ -176,10 +176,26 @@ typedef struct {
77289 int counter;
77290 } atomic_t;
77291
77292 +#ifdef CONFIG_PAX_REFCOUNT
77293 +typedef struct {
77294 + int counter;
77295 +} atomic_unchecked_t;
77296 +#else
77297 +typedef atomic_t atomic_unchecked_t;
77298 +#endif
77299 +
77300 #ifdef CONFIG_64BIT
77301 typedef struct {
77302 long counter;
77303 } atomic64_t;
77304 +
77305 +#ifdef CONFIG_PAX_REFCOUNT
77306 +typedef struct {
77307 + long counter;
77308 +} atomic64_unchecked_t;
77309 +#else
77310 +typedef atomic64_t atomic64_unchecked_t;
77311 +#endif
77312 #endif
77313
77314 struct list_head {
77315 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77316 index 5ca0951..ab496a5 100644
77317 --- a/include/linux/uaccess.h
77318 +++ b/include/linux/uaccess.h
77319 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77320 long ret; \
77321 mm_segment_t old_fs = get_fs(); \
77322 \
77323 - set_fs(KERNEL_DS); \
77324 pagefault_disable(); \
77325 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77326 - pagefault_enable(); \
77327 + set_fs(KERNEL_DS); \
77328 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77329 set_fs(old_fs); \
77330 + pagefault_enable(); \
77331 ret; \
77332 })
77333
77334 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77335 index 8e522cbc..aa8572d 100644
77336 --- a/include/linux/uidgid.h
77337 +++ b/include/linux/uidgid.h
77338 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77339
77340 #endif /* CONFIG_USER_NS */
77341
77342 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77343 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77344 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77345 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77346 +
77347 #endif /* _LINUX_UIDGID_H */
77348 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77349 index 99c1b4d..562e6f3 100644
77350 --- a/include/linux/unaligned/access_ok.h
77351 +++ b/include/linux/unaligned/access_ok.h
77352 @@ -4,34 +4,34 @@
77353 #include <linux/kernel.h>
77354 #include <asm/byteorder.h>
77355
77356 -static inline u16 get_unaligned_le16(const void *p)
77357 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77358 {
77359 - return le16_to_cpup((__le16 *)p);
77360 + return le16_to_cpup((const __le16 *)p);
77361 }
77362
77363 -static inline u32 get_unaligned_le32(const void *p)
77364 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77365 {
77366 - return le32_to_cpup((__le32 *)p);
77367 + return le32_to_cpup((const __le32 *)p);
77368 }
77369
77370 -static inline u64 get_unaligned_le64(const void *p)
77371 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77372 {
77373 - return le64_to_cpup((__le64 *)p);
77374 + return le64_to_cpup((const __le64 *)p);
77375 }
77376
77377 -static inline u16 get_unaligned_be16(const void *p)
77378 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77379 {
77380 - return be16_to_cpup((__be16 *)p);
77381 + return be16_to_cpup((const __be16 *)p);
77382 }
77383
77384 -static inline u32 get_unaligned_be32(const void *p)
77385 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77386 {
77387 - return be32_to_cpup((__be32 *)p);
77388 + return be32_to_cpup((const __be32 *)p);
77389 }
77390
77391 -static inline u64 get_unaligned_be64(const void *p)
77392 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77393 {
77394 - return be64_to_cpup((__be64 *)p);
77395 + return be64_to_cpup((const __be64 *)p);
77396 }
77397
77398 static inline void put_unaligned_le16(u16 val, void *p)
77399 diff --git a/include/linux/usb.h b/include/linux/usb.h
77400 index 0eec268..4496526 100644
77401 --- a/include/linux/usb.h
77402 +++ b/include/linux/usb.h
77403 @@ -560,7 +560,7 @@ struct usb_device {
77404 int maxchild;
77405
77406 u32 quirks;
77407 - atomic_t urbnum;
77408 + atomic_unchecked_t urbnum;
77409
77410 unsigned long active_duration;
77411
77412 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77413
77414 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77415 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77416 - void *data, __u16 size, int timeout);
77417 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77418 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77419 void *data, int len, int *actual_length, int timeout);
77420 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77421 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77422 index e452ba6..78f8e80 100644
77423 --- a/include/linux/usb/renesas_usbhs.h
77424 +++ b/include/linux/usb/renesas_usbhs.h
77425 @@ -39,7 +39,7 @@ enum {
77426 */
77427 struct renesas_usbhs_driver_callback {
77428 int (*notify_hotplug)(struct platform_device *pdev);
77429 -};
77430 +} __no_const;
77431
77432 /*
77433 * callback functions for platform
77434 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77435 index 6f8fbcf..8259001 100644
77436 --- a/include/linux/vermagic.h
77437 +++ b/include/linux/vermagic.h
77438 @@ -25,9 +25,35 @@
77439 #define MODULE_ARCH_VERMAGIC ""
77440 #endif
77441
77442 +#ifdef CONFIG_PAX_REFCOUNT
77443 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77444 +#else
77445 +#define MODULE_PAX_REFCOUNT ""
77446 +#endif
77447 +
77448 +#ifdef CONSTIFY_PLUGIN
77449 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77450 +#else
77451 +#define MODULE_CONSTIFY_PLUGIN ""
77452 +#endif
77453 +
77454 +#ifdef STACKLEAK_PLUGIN
77455 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77456 +#else
77457 +#define MODULE_STACKLEAK_PLUGIN ""
77458 +#endif
77459 +
77460 +#ifdef CONFIG_GRKERNSEC
77461 +#define MODULE_GRSEC "GRSEC "
77462 +#else
77463 +#define MODULE_GRSEC ""
77464 +#endif
77465 +
77466 #define VERMAGIC_STRING \
77467 UTS_RELEASE " " \
77468 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77469 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77470 - MODULE_ARCH_VERMAGIC
77471 + MODULE_ARCH_VERMAGIC \
77472 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77473 + MODULE_GRSEC
77474
77475 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77476 index 4b8a891..c20e936 100644
77477 --- a/include/linux/vmalloc.h
77478 +++ b/include/linux/vmalloc.h
77479 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77480 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77481 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77482 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77483 +
77484 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77485 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77486 +#endif
77487 +
77488 /* bits [20..32] reserved for arch specific ioremap internals */
77489
77490 /*
77491 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77492 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77493 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77494 unsigned long start, unsigned long end, gfp_t gfp_mask,
77495 - pgprot_t prot, int node, const void *caller);
77496 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77497 extern void vfree(const void *addr);
77498
77499 extern void *vmap(struct page **pages, unsigned int count,
77500 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77501 extern void free_vm_area(struct vm_struct *area);
77502
77503 /* for /dev/kmem */
77504 -extern long vread(char *buf, char *addr, unsigned long count);
77505 -extern long vwrite(char *buf, char *addr, unsigned long count);
77506 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77507 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77508
77509 /*
77510 * Internals. Dont't use..
77511 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77512 index c586679..f06b389 100644
77513 --- a/include/linux/vmstat.h
77514 +++ b/include/linux/vmstat.h
77515 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77516 /*
77517 * Zone based page accounting with per cpu differentials.
77518 */
77519 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77520 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77521
77522 static inline void zone_page_state_add(long x, struct zone *zone,
77523 enum zone_stat_item item)
77524 {
77525 - atomic_long_add(x, &zone->vm_stat[item]);
77526 - atomic_long_add(x, &vm_stat[item]);
77527 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77528 + atomic_long_add_unchecked(x, &vm_stat[item]);
77529 }
77530
77531 static inline unsigned long global_page_state(enum zone_stat_item item)
77532 {
77533 - long x = atomic_long_read(&vm_stat[item]);
77534 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77535 #ifdef CONFIG_SMP
77536 if (x < 0)
77537 x = 0;
77538 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77539 static inline unsigned long zone_page_state(struct zone *zone,
77540 enum zone_stat_item item)
77541 {
77542 - long x = atomic_long_read(&zone->vm_stat[item]);
77543 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77544 #ifdef CONFIG_SMP
77545 if (x < 0)
77546 x = 0;
77547 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77548 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77549 enum zone_stat_item item)
77550 {
77551 - long x = atomic_long_read(&zone->vm_stat[item]);
77552 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77553
77554 #ifdef CONFIG_SMP
77555 int cpu;
77556 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77557
77558 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77559 {
77560 - atomic_long_inc(&zone->vm_stat[item]);
77561 - atomic_long_inc(&vm_stat[item]);
77562 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77563 + atomic_long_inc_unchecked(&vm_stat[item]);
77564 }
77565
77566 static inline void __inc_zone_page_state(struct page *page,
77567 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77568
77569 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77570 {
77571 - atomic_long_dec(&zone->vm_stat[item]);
77572 - atomic_long_dec(&vm_stat[item]);
77573 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77574 + atomic_long_dec_unchecked(&vm_stat[item]);
77575 }
77576
77577 static inline void __dec_zone_page_state(struct page *page,
77578 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77579 index fdbafc6..49dfe4f 100644
77580 --- a/include/linux/xattr.h
77581 +++ b/include/linux/xattr.h
77582 @@ -28,7 +28,7 @@ struct xattr_handler {
77583 size_t size, int handler_flags);
77584 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77585 size_t size, int flags, int handler_flags);
77586 -};
77587 +} __do_const;
77588
77589 struct xattr {
77590 char *name;
77591 @@ -37,6 +37,9 @@ struct xattr {
77592 };
77593
77594 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77595 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77596 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77597 +#endif
77598 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77599 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77600 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77601 diff --git a/include/linux/yam.h b/include/linux/yam.h
77602 index 7fe2822..512cdc2 100644
77603 --- a/include/linux/yam.h
77604 +++ b/include/linux/yam.h
77605 @@ -77,6 +77,6 @@ struct yamdrv_ioctl_cfg {
77606
77607 struct yamdrv_ioctl_mcs {
77608 int cmd;
77609 - int bitrate;
77610 + unsigned int bitrate;
77611 unsigned char bits[YAM_FPGA_SIZE];
77612 };
77613 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77614 index 9c5a6b4..09c9438 100644
77615 --- a/include/linux/zlib.h
77616 +++ b/include/linux/zlib.h
77617 @@ -31,6 +31,7 @@
77618 #define _ZLIB_H
77619
77620 #include <linux/zconf.h>
77621 +#include <linux/compiler.h>
77622
77623 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77624 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77625 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77626
77627 /* basic functions */
77628
77629 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77630 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77631 /*
77632 Returns the number of bytes that needs to be allocated for a per-
77633 stream workspace with the specified parameters. A pointer to this
77634 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77635 index c768c9f..bdcaa5a 100644
77636 --- a/include/media/v4l2-dev.h
77637 +++ b/include/media/v4l2-dev.h
77638 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77639 int (*mmap) (struct file *, struct vm_area_struct *);
77640 int (*open) (struct file *);
77641 int (*release) (struct file *);
77642 -};
77643 +} __do_const;
77644
77645 /*
77646 * Newer version of video_device, handled by videodev2.c
77647 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77648 index c9b1593..a572459 100644
77649 --- a/include/media/v4l2-device.h
77650 +++ b/include/media/v4l2-device.h
77651 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77652 this function returns 0. If the name ends with a digit (e.g. cx18),
77653 then the name will be set to cx18-0 since cx180 looks really odd. */
77654 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77655 - atomic_t *instance);
77656 + atomic_unchecked_t *instance);
77657
77658 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77659 Since the parent disappears this ensures that v4l2_dev doesn't have an
77660 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77661 index d9fa68f..45c88d1 100644
77662 --- a/include/net/9p/transport.h
77663 +++ b/include/net/9p/transport.h
77664 @@ -63,7 +63,7 @@ struct p9_trans_module {
77665 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77666 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77667 char *, char *, int , int, int, int);
77668 -};
77669 +} __do_const;
77670
77671 void v9fs_register_trans(struct p9_trans_module *m);
77672 void v9fs_unregister_trans(struct p9_trans_module *m);
77673 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77674 index 1a966af..2767cf6 100644
77675 --- a/include/net/bluetooth/l2cap.h
77676 +++ b/include/net/bluetooth/l2cap.h
77677 @@ -551,7 +551,7 @@ struct l2cap_ops {
77678 void (*defer) (struct l2cap_chan *chan);
77679 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77680 unsigned long len, int nb);
77681 -};
77682 +} __do_const;
77683
77684 struct l2cap_conn {
77685 struct hci_conn *hcon;
77686 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77687 index f2ae33d..c457cf0 100644
77688 --- a/include/net/caif/cfctrl.h
77689 +++ b/include/net/caif/cfctrl.h
77690 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77691 void (*radioset_rsp)(void);
77692 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77693 struct cflayer *client_layer);
77694 -};
77695 +} __no_const;
77696
77697 /* Link Setup Parameters for CAIF-Links. */
77698 struct cfctrl_link_param {
77699 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77700 struct cfctrl {
77701 struct cfsrvl serv;
77702 struct cfctrl_rsp res;
77703 - atomic_t req_seq_no;
77704 - atomic_t rsp_seq_no;
77705 + atomic_unchecked_t req_seq_no;
77706 + atomic_unchecked_t rsp_seq_no;
77707 struct list_head list;
77708 /* Protects from simultaneous access to first_req list */
77709 spinlock_t info_list_lock;
77710 diff --git a/include/net/flow.h b/include/net/flow.h
77711 index 628e11b..4c475df 100644
77712 --- a/include/net/flow.h
77713 +++ b/include/net/flow.h
77714 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77715
77716 extern void flow_cache_flush(void);
77717 extern void flow_cache_flush_deferred(void);
77718 -extern atomic_t flow_cache_genid;
77719 +extern atomic_unchecked_t flow_cache_genid;
77720
77721 #endif
77722 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77723 index 8e0b6c8..73cf605 100644
77724 --- a/include/net/genetlink.h
77725 +++ b/include/net/genetlink.h
77726 @@ -120,7 +120,7 @@ struct genl_ops {
77727 struct netlink_callback *cb);
77728 int (*done)(struct netlink_callback *cb);
77729 struct list_head ops_list;
77730 -};
77731 +} __do_const;
77732
77733 extern int __genl_register_family(struct genl_family *family);
77734
77735 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77736 index 734d9b5..48a9a4b 100644
77737 --- a/include/net/gro_cells.h
77738 +++ b/include/net/gro_cells.h
77739 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77740 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77741
77742 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77743 - atomic_long_inc(&dev->rx_dropped);
77744 + atomic_long_inc_unchecked(&dev->rx_dropped);
77745 kfree_skb(skb);
77746 return;
77747 }
77748 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77749 index de2c785..0588a6b 100644
77750 --- a/include/net/inet_connection_sock.h
77751 +++ b/include/net/inet_connection_sock.h
77752 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77753 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77754 int (*bind_conflict)(const struct sock *sk,
77755 const struct inet_bind_bucket *tb, bool relax);
77756 -};
77757 +} __do_const;
77758
77759 /** inet_connection_sock - INET connection oriented sock
77760 *
77761 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77762 index 53f464d..0bd0b49 100644
77763 --- a/include/net/inetpeer.h
77764 +++ b/include/net/inetpeer.h
77765 @@ -47,8 +47,8 @@ struct inet_peer {
77766 */
77767 union {
77768 struct {
77769 - atomic_t rid; /* Frag reception counter */
77770 - atomic_t ip_id_count; /* IP ID for the next packet */
77771 + atomic_unchecked_t rid; /* Frag reception counter */
77772 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77773 };
77774 struct rcu_head rcu;
77775 struct inet_peer *gc_next;
77776 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77777 /* can be called with or without local BH being disabled */
77778 static inline int inet_getid(struct inet_peer *p, int more)
77779 {
77780 - int old, new;
77781 + int id;
77782 more++;
77783 inet_peer_refcheck(p);
77784 - do {
77785 - old = atomic_read(&p->ip_id_count);
77786 - new = old + more;
77787 - if (!new)
77788 - new = 1;
77789 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77790 - return new;
77791 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77792 + if (!id)
77793 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77794 + return id;
77795 }
77796
77797 #endif /* _NET_INETPEER_H */
77798 diff --git a/include/net/ip.h b/include/net/ip.h
77799 index edfa591..a643b82 100644
77800 --- a/include/net/ip.h
77801 +++ b/include/net/ip.h
77802 @@ -202,7 +202,7 @@ extern struct local_ports {
77803 } sysctl_local_ports;
77804 extern void inet_get_local_port_range(int *low, int *high);
77805
77806 -extern unsigned long *sysctl_local_reserved_ports;
77807 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77808 static inline int inet_is_reserved_local_port(int port)
77809 {
77810 return test_bit(port, sysctl_local_reserved_ports);
77811 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77812 index cbf2be3..3683f6d 100644
77813 --- a/include/net/ip_fib.h
77814 +++ b/include/net/ip_fib.h
77815 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77816
77817 #define FIB_RES_SADDR(net, res) \
77818 ((FIB_RES_NH(res).nh_saddr_genid == \
77819 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77820 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77821 FIB_RES_NH(res).nh_saddr : \
77822 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77823 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77824 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77825 index f0d70f0..185f15b 100644
77826 --- a/include/net/ip_vs.h
77827 +++ b/include/net/ip_vs.h
77828 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77829 struct ip_vs_conn *control; /* Master control connection */
77830 atomic_t n_control; /* Number of controlled ones */
77831 struct ip_vs_dest *dest; /* real server */
77832 - atomic_t in_pkts; /* incoming packet counter */
77833 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77834
77835 /* packet transmitter for different forwarding methods. If it
77836 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77837 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77838 __be16 port; /* port number of the server */
77839 union nf_inet_addr addr; /* IP address of the server */
77840 volatile unsigned int flags; /* dest status flags */
77841 - atomic_t conn_flags; /* flags to copy to conn */
77842 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77843 atomic_t weight; /* server weight */
77844
77845 atomic_t refcnt; /* reference counter */
77846 @@ -993,11 +993,11 @@ struct netns_ipvs {
77847 /* ip_vs_lblc */
77848 int sysctl_lblc_expiration;
77849 struct ctl_table_header *lblc_ctl_header;
77850 - struct ctl_table *lblc_ctl_table;
77851 + ctl_table_no_const *lblc_ctl_table;
77852 /* ip_vs_lblcr */
77853 int sysctl_lblcr_expiration;
77854 struct ctl_table_header *lblcr_ctl_header;
77855 - struct ctl_table *lblcr_ctl_table;
77856 + ctl_table_no_const *lblcr_ctl_table;
77857 /* ip_vs_est */
77858 struct list_head est_list; /* estimator list */
77859 spinlock_t est_lock;
77860 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77861 index 80ffde3..968b0f4 100644
77862 --- a/include/net/irda/ircomm_tty.h
77863 +++ b/include/net/irda/ircomm_tty.h
77864 @@ -35,6 +35,7 @@
77865 #include <linux/termios.h>
77866 #include <linux/timer.h>
77867 #include <linux/tty.h> /* struct tty_struct */
77868 +#include <asm/local.h>
77869
77870 #include <net/irda/irias_object.h>
77871 #include <net/irda/ircomm_core.h>
77872 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77873 index 714cc9a..ea05f3e 100644
77874 --- a/include/net/iucv/af_iucv.h
77875 +++ b/include/net/iucv/af_iucv.h
77876 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77877 struct iucv_sock_list {
77878 struct hlist_head head;
77879 rwlock_t lock;
77880 - atomic_t autobind_name;
77881 + atomic_unchecked_t autobind_name;
77882 };
77883
77884 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77885 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77886 index df83f69..9b640b8 100644
77887 --- a/include/net/llc_c_ac.h
77888 +++ b/include/net/llc_c_ac.h
77889 @@ -87,7 +87,7 @@
77890 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77891 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77892
77893 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77894 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77895
77896 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77897 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77898 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77899 index 6ca3113..f8026dd 100644
77900 --- a/include/net/llc_c_ev.h
77901 +++ b/include/net/llc_c_ev.h
77902 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77903 return (struct llc_conn_state_ev *)skb->cb;
77904 }
77905
77906 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77907 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77908 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77909 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77910
77911 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77912 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77913 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77914 index 0e79cfb..f46db31 100644
77915 --- a/include/net/llc_c_st.h
77916 +++ b/include/net/llc_c_st.h
77917 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77918 u8 next_state;
77919 llc_conn_ev_qfyr_t *ev_qualifiers;
77920 llc_conn_action_t *ev_actions;
77921 -};
77922 +} __do_const;
77923
77924 struct llc_conn_state {
77925 u8 current_state;
77926 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77927 index 37a3bbd..55a4241 100644
77928 --- a/include/net/llc_s_ac.h
77929 +++ b/include/net/llc_s_ac.h
77930 @@ -23,7 +23,7 @@
77931 #define SAP_ACT_TEST_IND 9
77932
77933 /* All action functions must look like this */
77934 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77935 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77936
77937 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77938 struct sk_buff *skb);
77939 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77940 index 567c681..cd73ac0 100644
77941 --- a/include/net/llc_s_st.h
77942 +++ b/include/net/llc_s_st.h
77943 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77944 llc_sap_ev_t ev;
77945 u8 next_state;
77946 llc_sap_action_t *ev_actions;
77947 -};
77948 +} __do_const;
77949
77950 struct llc_sap_state {
77951 u8 curr_state;
77952 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77953 index 551ba6a..11c99c1 100644
77954 --- a/include/net/mac80211.h
77955 +++ b/include/net/mac80211.h
77956 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77957 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77958 struct dentry *dir);
77959 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77960 -};
77961 +} __do_const;
77962
77963 static inline int rate_supported(struct ieee80211_sta *sta,
77964 enum ieee80211_band band,
77965 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77966 index 7e748ad..5c6229b 100644
77967 --- a/include/net/neighbour.h
77968 +++ b/include/net/neighbour.h
77969 @@ -123,7 +123,7 @@ struct neigh_ops {
77970 void (*error_report)(struct neighbour *, struct sk_buff *);
77971 int (*output)(struct neighbour *, struct sk_buff *);
77972 int (*connected_output)(struct neighbour *, struct sk_buff *);
77973 -};
77974 +} __do_const;
77975
77976 struct pneigh_entry {
77977 struct pneigh_entry *next;
77978 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77979 index 84e37b1..8eba19a 100644
77980 --- a/include/net/net_namespace.h
77981 +++ b/include/net/net_namespace.h
77982 @@ -119,8 +119,8 @@ struct net {
77983 struct netns_ipvs *ipvs;
77984 #endif
77985 struct sock *diag_nlsk;
77986 - atomic_t rt_genid;
77987 - atomic_t fnhe_genid;
77988 + atomic_unchecked_t rt_genid;
77989 + atomic_unchecked_t fnhe_genid;
77990 };
77991
77992 /*
77993 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77994 #define __net_init __init
77995 #define __net_exit __exit_refok
77996 #define __net_initdata __initdata
77997 +#ifdef CONSTIFY_PLUGIN
77998 #define __net_initconst __initconst
77999 +#else
78000 +#define __net_initconst __initdata
78001 +#endif
78002 #endif
78003
78004 struct pernet_operations {
78005 @@ -287,7 +291,7 @@ struct pernet_operations {
78006 void (*exit_batch)(struct list_head *net_exit_list);
78007 int *id;
78008 size_t size;
78009 -};
78010 +} __do_const;
78011
78012 /*
78013 * Use these carefully. If you implement a network device and it
78014 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
78015
78016 static inline int rt_genid(struct net *net)
78017 {
78018 - return atomic_read(&net->rt_genid);
78019 + return atomic_read_unchecked(&net->rt_genid);
78020 }
78021
78022 static inline void rt_genid_bump(struct net *net)
78023 {
78024 - atomic_inc(&net->rt_genid);
78025 + atomic_inc_unchecked(&net->rt_genid);
78026 }
78027
78028 static inline int fnhe_genid(struct net *net)
78029 {
78030 - return atomic_read(&net->fnhe_genid);
78031 + return atomic_read_unchecked(&net->fnhe_genid);
78032 }
78033
78034 static inline void fnhe_genid_bump(struct net *net)
78035 {
78036 - atomic_inc(&net->fnhe_genid);
78037 + atomic_inc_unchecked(&net->fnhe_genid);
78038 }
78039
78040 #endif /* __NET_NET_NAMESPACE_H */
78041 diff --git a/include/net/netdma.h b/include/net/netdma.h
78042 index 8ba8ce2..99b7fff 100644
78043 --- a/include/net/netdma.h
78044 +++ b/include/net/netdma.h
78045 @@ -24,7 +24,7 @@
78046 #include <linux/dmaengine.h>
78047 #include <linux/skbuff.h>
78048
78049 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78050 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78051 struct sk_buff *skb, int offset, struct iovec *to,
78052 size_t len, struct dma_pinned_list *pinned_list);
78053
78054 diff --git a/include/net/netlink.h b/include/net/netlink.h
78055 index 9690b0f..87aded7 100644
78056 --- a/include/net/netlink.h
78057 +++ b/include/net/netlink.h
78058 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78059 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78060 {
78061 if (mark)
78062 - skb_trim(skb, (unsigned char *) mark - skb->data);
78063 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78064 }
78065
78066 /**
78067 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78068 index c9c0c53..53f24c3 100644
78069 --- a/include/net/netns/conntrack.h
78070 +++ b/include/net/netns/conntrack.h
78071 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78072 struct nf_proto_net {
78073 #ifdef CONFIG_SYSCTL
78074 struct ctl_table_header *ctl_table_header;
78075 - struct ctl_table *ctl_table;
78076 + ctl_table_no_const *ctl_table;
78077 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78078 struct ctl_table_header *ctl_compat_header;
78079 - struct ctl_table *ctl_compat_table;
78080 + ctl_table_no_const *ctl_compat_table;
78081 #endif
78082 #endif
78083 unsigned int users;
78084 @@ -58,7 +58,7 @@ struct nf_ip_net {
78085 struct nf_icmp_net icmpv6;
78086 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78087 struct ctl_table_header *ctl_table_header;
78088 - struct ctl_table *ctl_table;
78089 + ctl_table_no_const *ctl_table;
78090 #endif
78091 };
78092
78093 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78094 index 2ba9de8..47bd6c7 100644
78095 --- a/include/net/netns/ipv4.h
78096 +++ b/include/net/netns/ipv4.h
78097 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78098 kgid_t sysctl_ping_group_range[2];
78099 long sysctl_tcp_mem[3];
78100
78101 - atomic_t dev_addr_genid;
78102 + atomic_unchecked_t dev_addr_genid;
78103
78104 #ifdef CONFIG_IP_MROUTE
78105 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78106 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78107 index 005e2c2..023d340 100644
78108 --- a/include/net/netns/ipv6.h
78109 +++ b/include/net/netns/ipv6.h
78110 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78111 struct fib_rules_ops *mr6_rules_ops;
78112 #endif
78113 #endif
78114 - atomic_t dev_addr_genid;
78115 + atomic_unchecked_t dev_addr_genid;
78116 };
78117
78118 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78119 diff --git a/include/net/ping.h b/include/net/ping.h
78120 index 5db0224..0d65365 100644
78121 --- a/include/net/ping.h
78122 +++ b/include/net/ping.h
78123 @@ -55,7 +55,7 @@ struct ping_iter_state {
78124 extern struct proto ping_prot;
78125 extern struct ping_table ping_table;
78126 #if IS_ENABLED(CONFIG_IPV6)
78127 -extern struct pingv6_ops pingv6_ops;
78128 +extern struct pingv6_ops *pingv6_ops;
78129 #endif
78130
78131 struct pingfakehdr {
78132 diff --git a/include/net/protocol.h b/include/net/protocol.h
78133 index 047c047..b9dad15 100644
78134 --- a/include/net/protocol.h
78135 +++ b/include/net/protocol.h
78136 @@ -44,7 +44,7 @@ struct net_protocol {
78137 void (*err_handler)(struct sk_buff *skb, u32 info);
78138 unsigned int no_policy:1,
78139 netns_ok:1;
78140 -};
78141 +} __do_const;
78142
78143 #if IS_ENABLED(CONFIG_IPV6)
78144 struct inet6_protocol {
78145 @@ -57,7 +57,7 @@ struct inet6_protocol {
78146 u8 type, u8 code, int offset,
78147 __be32 info);
78148 unsigned int flags; /* INET6_PROTO_xxx */
78149 -};
78150 +} __do_const;
78151
78152 #define INET6_PROTO_NOPOLICY 0x1
78153 #define INET6_PROTO_FINAL 0x2
78154 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78155 index 7026648..584cc8c 100644
78156 --- a/include/net/rtnetlink.h
78157 +++ b/include/net/rtnetlink.h
78158 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78159 const struct net_device *dev);
78160 unsigned int (*get_num_tx_queues)(void);
78161 unsigned int (*get_num_rx_queues)(void);
78162 -};
78163 +} __do_const;
78164
78165 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78166 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78167 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78168 index 2a82d13..62a31c2 100644
78169 --- a/include/net/sctp/sm.h
78170 +++ b/include/net/sctp/sm.h
78171 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78172 typedef struct {
78173 sctp_state_fn_t *fn;
78174 const char *name;
78175 -} sctp_sm_table_entry_t;
78176 +} __do_const sctp_sm_table_entry_t;
78177
78178 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78179 * currently in use.
78180 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78181 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78182
78183 /* Extern declarations for major data structures. */
78184 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78185 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78186
78187
78188 /* Get the size of a DATA chunk payload. */
78189 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78190 index e745c92..3641448 100644
78191 --- a/include/net/sctp/structs.h
78192 +++ b/include/net/sctp/structs.h
78193 @@ -516,7 +516,7 @@ struct sctp_pf {
78194 struct sctp_association *asoc);
78195 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78196 struct sctp_af *af;
78197 -};
78198 +} __do_const;
78199
78200
78201 /* Structure to track chunk fragments that have been acked, but peer
78202 diff --git a/include/net/sock.h b/include/net/sock.h
78203 index 31d5cfb..9ee0602 100644
78204 --- a/include/net/sock.h
78205 +++ b/include/net/sock.h
78206 @@ -331,7 +331,7 @@ struct sock {
78207 unsigned int sk_napi_id;
78208 unsigned int sk_ll_usec;
78209 #endif
78210 - atomic_t sk_drops;
78211 + atomic_unchecked_t sk_drops;
78212 int sk_rcvbuf;
78213
78214 struct sk_filter __rcu *sk_filter;
78215 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78216 }
78217
78218 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78219 - char __user *from, char *to,
78220 + char __user *from, unsigned char *to,
78221 int copy, int offset)
78222 {
78223 if (skb->ip_summed == CHECKSUM_NONE) {
78224 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78225 }
78226 }
78227
78228 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78229 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78230
78231 /**
78232 * sk_page_frag - return an appropriate page_frag
78233 diff --git a/include/net/tcp.h b/include/net/tcp.h
78234 index d198005..c974a393 100644
78235 --- a/include/net/tcp.h
78236 +++ b/include/net/tcp.h
78237 @@ -521,7 +521,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78238 extern void tcp_xmit_retransmit_queue(struct sock *);
78239 extern void tcp_simple_retransmit(struct sock *);
78240 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78241 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78242 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78243
78244 extern void tcp_send_probe0(struct sock *);
78245 extern void tcp_send_partial(struct sock *);
78246 @@ -694,8 +694,8 @@ struct tcp_skb_cb {
78247 struct inet6_skb_parm h6;
78248 #endif
78249 } header; /* For incoming frames */
78250 - __u32 seq; /* Starting sequence number */
78251 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78252 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78253 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78254 __u32 when; /* used to compute rtt's */
78255 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78256
78257 @@ -709,7 +709,7 @@ struct tcp_skb_cb {
78258
78259 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78260 /* 1 byte hole */
78261 - __u32 ack_seq; /* Sequence number ACK'd */
78262 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78263 };
78264
78265 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78266 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78267 index e823786..53b0608 100644
78268 --- a/include/net/xfrm.h
78269 +++ b/include/net/xfrm.h
78270 @@ -287,7 +287,6 @@ struct xfrm_dst;
78271 struct xfrm_policy_afinfo {
78272 unsigned short family;
78273 struct dst_ops *dst_ops;
78274 - void (*garbage_collect)(struct net *net);
78275 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78276 const xfrm_address_t *saddr,
78277 const xfrm_address_t *daddr);
78278 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78279 struct net_device *dev,
78280 const struct flowi *fl);
78281 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78282 -};
78283 +} __do_const;
78284
78285 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78286 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78287 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78288 int (*transport_finish)(struct sk_buff *skb,
78289 int async);
78290 void (*local_error)(struct sk_buff *skb, u32 mtu);
78291 -};
78292 +} __do_const;
78293
78294 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78295 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78296 @@ -427,7 +426,7 @@ struct xfrm_mode {
78297 struct module *owner;
78298 unsigned int encap;
78299 int flags;
78300 -};
78301 +} __do_const;
78302
78303 /* Flags for xfrm_mode. */
78304 enum {
78305 @@ -524,7 +523,7 @@ struct xfrm_policy {
78306 struct timer_list timer;
78307
78308 struct flow_cache_object flo;
78309 - atomic_t genid;
78310 + atomic_unchecked_t genid;
78311 u32 priority;
78312 u32 index;
78313 struct xfrm_mark mark;
78314 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78315 }
78316
78317 extern void xfrm_garbage_collect(struct net *net);
78318 +extern void xfrm_garbage_collect_deferred(struct net *net);
78319
78320 #else
78321
78322 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78323 static inline void xfrm_garbage_collect(struct net *net)
78324 {
78325 }
78326 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78327 +{
78328 +}
78329 #endif
78330
78331 static __inline__
78332 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78333 index 1a046b1..ee0bef0 100644
78334 --- a/include/rdma/iw_cm.h
78335 +++ b/include/rdma/iw_cm.h
78336 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78337 int backlog);
78338
78339 int (*destroy_listen)(struct iw_cm_id *cm_id);
78340 -};
78341 +} __no_const;
78342
78343 /**
78344 * iw_create_cm_id - Create an IW CM identifier.
78345 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78346 index e1379b4..67eafbe 100644
78347 --- a/include/scsi/libfc.h
78348 +++ b/include/scsi/libfc.h
78349 @@ -762,6 +762,7 @@ struct libfc_function_template {
78350 */
78351 void (*disc_stop_final) (struct fc_lport *);
78352 };
78353 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78354
78355 /**
78356 * struct fc_disc - Discovery context
78357 @@ -866,7 +867,7 @@ struct fc_lport {
78358 struct fc_vport *vport;
78359
78360 /* Operational Information */
78361 - struct libfc_function_template tt;
78362 + libfc_function_template_no_const tt;
78363 u8 link_up;
78364 u8 qfull;
78365 enum fc_lport_state state;
78366 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78367 index a44954c..5da04b2 100644
78368 --- a/include/scsi/scsi_device.h
78369 +++ b/include/scsi/scsi_device.h
78370 @@ -172,9 +172,9 @@ struct scsi_device {
78371 unsigned int max_device_blocked; /* what device_blocked counts down from */
78372 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78373
78374 - atomic_t iorequest_cnt;
78375 - atomic_t iodone_cnt;
78376 - atomic_t ioerr_cnt;
78377 + atomic_unchecked_t iorequest_cnt;
78378 + atomic_unchecked_t iodone_cnt;
78379 + atomic_unchecked_t ioerr_cnt;
78380
78381 struct device sdev_gendev,
78382 sdev_dev;
78383 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78384 index b797e8f..8e2c3aa 100644
78385 --- a/include/scsi/scsi_transport_fc.h
78386 +++ b/include/scsi/scsi_transport_fc.h
78387 @@ -751,7 +751,8 @@ struct fc_function_template {
78388 unsigned long show_host_system_hostname:1;
78389
78390 unsigned long disable_target_scan:1;
78391 -};
78392 +} __do_const;
78393 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78394
78395
78396 /**
78397 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78398 index 9031a26..750d592 100644
78399 --- a/include/sound/compress_driver.h
78400 +++ b/include/sound/compress_driver.h
78401 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78402 struct snd_compr_caps *caps);
78403 int (*get_codec_caps) (struct snd_compr_stream *stream,
78404 struct snd_compr_codec_caps *codec);
78405 -};
78406 +} __no_const;
78407
78408 /**
78409 * struct snd_compr: Compressed device
78410 diff --git a/include/sound/soc.h b/include/sound/soc.h
78411 index 6eabee7..58afb50 100644
78412 --- a/include/sound/soc.h
78413 +++ b/include/sound/soc.h
78414 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78415 /* probe ordering - for components with runtime dependencies */
78416 int probe_order;
78417 int remove_order;
78418 -};
78419 +} __do_const;
78420
78421 /* SoC platform interface */
78422 struct snd_soc_platform_driver {
78423 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78424 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78425 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78426 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78427 -};
78428 +} __do_const;
78429
78430 struct snd_soc_platform {
78431 const char *name;
78432 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78433 index e34fc90..ecefa2c 100644
78434 --- a/include/target/target_core_base.h
78435 +++ b/include/target/target_core_base.h
78436 @@ -643,7 +643,7 @@ struct se_device {
78437 spinlock_t stats_lock;
78438 /* Active commands on this virtual SE device */
78439 atomic_t simple_cmds;
78440 - atomic_t dev_ordered_id;
78441 + atomic_unchecked_t dev_ordered_id;
78442 atomic_t dev_ordered_sync;
78443 atomic_t dev_qf_count;
78444 int export_count;
78445 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78446 new file mode 100644
78447 index 0000000..fb634b7
78448 --- /dev/null
78449 +++ b/include/trace/events/fs.h
78450 @@ -0,0 +1,53 @@
78451 +#undef TRACE_SYSTEM
78452 +#define TRACE_SYSTEM fs
78453 +
78454 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78455 +#define _TRACE_FS_H
78456 +
78457 +#include <linux/fs.h>
78458 +#include <linux/tracepoint.h>
78459 +
78460 +TRACE_EVENT(do_sys_open,
78461 +
78462 + TP_PROTO(const char *filename, int flags, int mode),
78463 +
78464 + TP_ARGS(filename, flags, mode),
78465 +
78466 + TP_STRUCT__entry(
78467 + __string( filename, filename )
78468 + __field( int, flags )
78469 + __field( int, mode )
78470 + ),
78471 +
78472 + TP_fast_assign(
78473 + __assign_str(filename, filename);
78474 + __entry->flags = flags;
78475 + __entry->mode = mode;
78476 + ),
78477 +
78478 + TP_printk("\"%s\" %x %o",
78479 + __get_str(filename), __entry->flags, __entry->mode)
78480 +);
78481 +
78482 +TRACE_EVENT(open_exec,
78483 +
78484 + TP_PROTO(const char *filename),
78485 +
78486 + TP_ARGS(filename),
78487 +
78488 + TP_STRUCT__entry(
78489 + __string( filename, filename )
78490 + ),
78491 +
78492 + TP_fast_assign(
78493 + __assign_str(filename, filename);
78494 + ),
78495 +
78496 + TP_printk("\"%s\"",
78497 + __get_str(filename))
78498 +);
78499 +
78500 +#endif /* _TRACE_FS_H */
78501 +
78502 +/* This part must be outside protection */
78503 +#include <trace/define_trace.h>
78504 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78505 index 1c09820..7f5ec79 100644
78506 --- a/include/trace/events/irq.h
78507 +++ b/include/trace/events/irq.h
78508 @@ -36,7 +36,7 @@ struct softirq_action;
78509 */
78510 TRACE_EVENT(irq_handler_entry,
78511
78512 - TP_PROTO(int irq, struct irqaction *action),
78513 + TP_PROTO(int irq, const struct irqaction *action),
78514
78515 TP_ARGS(irq, action),
78516
78517 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78518 */
78519 TRACE_EVENT(irq_handler_exit,
78520
78521 - TP_PROTO(int irq, struct irqaction *action, int ret),
78522 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78523
78524 TP_ARGS(irq, action, ret),
78525
78526 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78527 index 7caf44c..23c6f27 100644
78528 --- a/include/uapi/linux/a.out.h
78529 +++ b/include/uapi/linux/a.out.h
78530 @@ -39,6 +39,14 @@ enum machine_type {
78531 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78532 };
78533
78534 +/* Constants for the N_FLAGS field */
78535 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78536 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78537 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78538 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78539 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78540 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78541 +
78542 #if !defined (N_MAGIC)
78543 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78544 #endif
78545 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78546 index d876736..ccce5c0 100644
78547 --- a/include/uapi/linux/byteorder/little_endian.h
78548 +++ b/include/uapi/linux/byteorder/little_endian.h
78549 @@ -42,51 +42,51 @@
78550
78551 static inline __le64 __cpu_to_le64p(const __u64 *p)
78552 {
78553 - return (__force __le64)*p;
78554 + return (__force const __le64)*p;
78555 }
78556 -static inline __u64 __le64_to_cpup(const __le64 *p)
78557 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78558 {
78559 - return (__force __u64)*p;
78560 + return (__force const __u64)*p;
78561 }
78562 static inline __le32 __cpu_to_le32p(const __u32 *p)
78563 {
78564 - return (__force __le32)*p;
78565 + return (__force const __le32)*p;
78566 }
78567 static inline __u32 __le32_to_cpup(const __le32 *p)
78568 {
78569 - return (__force __u32)*p;
78570 + return (__force const __u32)*p;
78571 }
78572 static inline __le16 __cpu_to_le16p(const __u16 *p)
78573 {
78574 - return (__force __le16)*p;
78575 + return (__force const __le16)*p;
78576 }
78577 static inline __u16 __le16_to_cpup(const __le16 *p)
78578 {
78579 - return (__force __u16)*p;
78580 + return (__force const __u16)*p;
78581 }
78582 static inline __be64 __cpu_to_be64p(const __u64 *p)
78583 {
78584 - return (__force __be64)__swab64p(p);
78585 + return (__force const __be64)__swab64p(p);
78586 }
78587 static inline __u64 __be64_to_cpup(const __be64 *p)
78588 {
78589 - return __swab64p((__u64 *)p);
78590 + return __swab64p((const __u64 *)p);
78591 }
78592 static inline __be32 __cpu_to_be32p(const __u32 *p)
78593 {
78594 - return (__force __be32)__swab32p(p);
78595 + return (__force const __be32)__swab32p(p);
78596 }
78597 -static inline __u32 __be32_to_cpup(const __be32 *p)
78598 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78599 {
78600 - return __swab32p((__u32 *)p);
78601 + return __swab32p((const __u32 *)p);
78602 }
78603 static inline __be16 __cpu_to_be16p(const __u16 *p)
78604 {
78605 - return (__force __be16)__swab16p(p);
78606 + return (__force const __be16)__swab16p(p);
78607 }
78608 static inline __u16 __be16_to_cpup(const __be16 *p)
78609 {
78610 - return __swab16p((__u16 *)p);
78611 + return __swab16p((const __u16 *)p);
78612 }
78613 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78614 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78615 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78616 index ef6103b..d4e65dd 100644
78617 --- a/include/uapi/linux/elf.h
78618 +++ b/include/uapi/linux/elf.h
78619 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78620 #define PT_GNU_EH_FRAME 0x6474e550
78621
78622 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78623 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78624 +
78625 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78626 +
78627 +/* Constants for the e_flags field */
78628 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78629 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78630 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78631 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78632 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78633 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78634
78635 /*
78636 * Extended Numbering
78637 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78638 #define DT_DEBUG 21
78639 #define DT_TEXTREL 22
78640 #define DT_JMPREL 23
78641 +#define DT_FLAGS 30
78642 + #define DF_TEXTREL 0x00000004
78643 #define DT_ENCODING 32
78644 #define OLD_DT_LOOS 0x60000000
78645 #define DT_LOOS 0x6000000d
78646 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78647 #define PF_W 0x2
78648 #define PF_X 0x1
78649
78650 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78651 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78652 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78653 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78654 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78655 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78656 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78657 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78658 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78659 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78660 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78661 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78662 +
78663 typedef struct elf32_phdr{
78664 Elf32_Word p_type;
78665 Elf32_Off p_offset;
78666 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78667 #define EI_OSABI 7
78668 #define EI_PAD 8
78669
78670 +#define EI_PAX 14
78671 +
78672 #define ELFMAG0 0x7f /* EI_MAG */
78673 #define ELFMAG1 'E'
78674 #define ELFMAG2 'L'
78675 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78676 index aa169c4..6a2771d 100644
78677 --- a/include/uapi/linux/personality.h
78678 +++ b/include/uapi/linux/personality.h
78679 @@ -30,6 +30,7 @@ enum {
78680 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78681 ADDR_NO_RANDOMIZE | \
78682 ADDR_COMPAT_LAYOUT | \
78683 + ADDR_LIMIT_3GB | \
78684 MMAP_PAGE_ZERO)
78685
78686 /*
78687 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78688 index 7530e74..e714828 100644
78689 --- a/include/uapi/linux/screen_info.h
78690 +++ b/include/uapi/linux/screen_info.h
78691 @@ -43,7 +43,8 @@ struct screen_info {
78692 __u16 pages; /* 0x32 */
78693 __u16 vesa_attributes; /* 0x34 */
78694 __u32 capabilities; /* 0x36 */
78695 - __u8 _reserved[6]; /* 0x3a */
78696 + __u16 vesapm_size; /* 0x3a */
78697 + __u8 _reserved[4]; /* 0x3c */
78698 } __attribute__((packed));
78699
78700 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78701 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78702 index 0e011eb..82681b1 100644
78703 --- a/include/uapi/linux/swab.h
78704 +++ b/include/uapi/linux/swab.h
78705 @@ -43,7 +43,7 @@
78706 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78707 */
78708
78709 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78710 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78711 {
78712 #ifdef __HAVE_BUILTIN_BSWAP16__
78713 return __builtin_bswap16(val);
78714 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78715 #endif
78716 }
78717
78718 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78719 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78720 {
78721 #ifdef __HAVE_BUILTIN_BSWAP32__
78722 return __builtin_bswap32(val);
78723 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78724 #endif
78725 }
78726
78727 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78728 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78729 {
78730 #ifdef __HAVE_BUILTIN_BSWAP64__
78731 return __builtin_bswap64(val);
78732 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78733 index 6d67213..8dab561 100644
78734 --- a/include/uapi/linux/sysctl.h
78735 +++ b/include/uapi/linux/sysctl.h
78736 @@ -155,7 +155,11 @@ enum
78737 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78738 };
78739
78740 -
78741 +#ifdef CONFIG_PAX_SOFTMODE
78742 +enum {
78743 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78744 +};
78745 +#endif
78746
78747 /* CTL_VM names: */
78748 enum
78749 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78750 index e4629b9..6958086 100644
78751 --- a/include/uapi/linux/xattr.h
78752 +++ b/include/uapi/linux/xattr.h
78753 @@ -63,5 +63,9 @@
78754 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78755 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78756
78757 +/* User namespace */
78758 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78759 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78760 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78761
78762 #endif /* _UAPI_LINUX_XATTR_H */
78763 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78764 index f9466fa..f4e2b81 100644
78765 --- a/include/video/udlfb.h
78766 +++ b/include/video/udlfb.h
78767 @@ -53,10 +53,10 @@ struct dlfb_data {
78768 u32 pseudo_palette[256];
78769 int blank_mode; /*one of FB_BLANK_ */
78770 /* blit-only rendering path metrics, exposed through sysfs */
78771 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78772 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78773 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78774 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78775 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78776 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78777 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78778 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78779 };
78780
78781 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78782 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78783 index 30f5362..8ed8ac9 100644
78784 --- a/include/video/uvesafb.h
78785 +++ b/include/video/uvesafb.h
78786 @@ -122,6 +122,7 @@ struct uvesafb_par {
78787 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78788 u8 pmi_setpal; /* PMI for palette changes */
78789 u16 *pmi_base; /* protected mode interface location */
78790 + u8 *pmi_code; /* protected mode code location */
78791 void *pmi_start;
78792 void *pmi_pal;
78793 u8 *vbe_state_orig; /*
78794 diff --git a/init/Kconfig b/init/Kconfig
78795 index fed81b5..0d3b964 100644
78796 --- a/init/Kconfig
78797 +++ b/init/Kconfig
78798 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78799
78800 config CHECKPOINT_RESTORE
78801 bool "Checkpoint/restore support" if EXPERT
78802 + depends on !GRKERNSEC
78803 default n
78804 help
78805 Enables additional kernel features in a sake of checkpoint/restore.
78806 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78807
78808 config COMPAT_BRK
78809 bool "Disable heap randomization"
78810 - default y
78811 + default n
78812 help
78813 Randomizing heap placement makes heap exploits harder, but it
78814 also breaks ancient binaries (including anything libc5 based).
78815 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78816 config STOP_MACHINE
78817 bool
78818 default y
78819 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78820 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78821 help
78822 Need stop_machine() primitive.
78823
78824 diff --git a/init/Makefile b/init/Makefile
78825 index 7bc47ee..6da2dc7 100644
78826 --- a/init/Makefile
78827 +++ b/init/Makefile
78828 @@ -2,6 +2,9 @@
78829 # Makefile for the linux kernel.
78830 #
78831
78832 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78833 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78834 +
78835 obj-y := main.o version.o mounts.o
78836 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78837 obj-y += noinitramfs.o
78838 diff --git a/init/do_mounts.c b/init/do_mounts.c
78839 index 816014c..c2054db 100644
78840 --- a/init/do_mounts.c
78841 +++ b/init/do_mounts.c
78842 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78843 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78844 {
78845 struct super_block *s;
78846 - int err = sys_mount(name, "/root", fs, flags, data);
78847 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78848 if (err)
78849 return err;
78850
78851 - sys_chdir("/root");
78852 + sys_chdir((const char __force_user *)"/root");
78853 s = current->fs->pwd.dentry->d_sb;
78854 ROOT_DEV = s->s_dev;
78855 printk(KERN_INFO
78856 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78857 va_start(args, fmt);
78858 vsprintf(buf, fmt, args);
78859 va_end(args);
78860 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78861 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78862 if (fd >= 0) {
78863 sys_ioctl(fd, FDEJECT, 0);
78864 sys_close(fd);
78865 }
78866 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78867 - fd = sys_open("/dev/console", O_RDWR, 0);
78868 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78869 if (fd >= 0) {
78870 sys_ioctl(fd, TCGETS, (long)&termios);
78871 termios.c_lflag &= ~ICANON;
78872 sys_ioctl(fd, TCSETSF, (long)&termios);
78873 - sys_read(fd, &c, 1);
78874 + sys_read(fd, (char __user *)&c, 1);
78875 termios.c_lflag |= ICANON;
78876 sys_ioctl(fd, TCSETSF, (long)&termios);
78877 sys_close(fd);
78878 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78879 mount_root();
78880 out:
78881 devtmpfs_mount("dev");
78882 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78883 - sys_chroot(".");
78884 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78885 + sys_chroot((const char __force_user *)".");
78886 }
78887 diff --git a/init/do_mounts.h b/init/do_mounts.h
78888 index f5b978a..69dbfe8 100644
78889 --- a/init/do_mounts.h
78890 +++ b/init/do_mounts.h
78891 @@ -15,15 +15,15 @@ extern int root_mountflags;
78892
78893 static inline int create_dev(char *name, dev_t dev)
78894 {
78895 - sys_unlink(name);
78896 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78897 + sys_unlink((char __force_user *)name);
78898 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78899 }
78900
78901 #if BITS_PER_LONG == 32
78902 static inline u32 bstat(char *name)
78903 {
78904 struct stat64 stat;
78905 - if (sys_stat64(name, &stat) != 0)
78906 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78907 return 0;
78908 if (!S_ISBLK(stat.st_mode))
78909 return 0;
78910 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78911 static inline u32 bstat(char *name)
78912 {
78913 struct stat stat;
78914 - if (sys_newstat(name, &stat) != 0)
78915 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78916 return 0;
78917 if (!S_ISBLK(stat.st_mode))
78918 return 0;
78919 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78920 index 3e0878e..8a9d7a0 100644
78921 --- a/init/do_mounts_initrd.c
78922 +++ b/init/do_mounts_initrd.c
78923 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78924 {
78925 sys_unshare(CLONE_FS | CLONE_FILES);
78926 /* stdin/stdout/stderr for /linuxrc */
78927 - sys_open("/dev/console", O_RDWR, 0);
78928 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78929 sys_dup(0);
78930 sys_dup(0);
78931 /* move initrd over / and chdir/chroot in initrd root */
78932 - sys_chdir("/root");
78933 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78934 - sys_chroot(".");
78935 + sys_chdir((const char __force_user *)"/root");
78936 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78937 + sys_chroot((const char __force_user *)".");
78938 sys_setsid();
78939 return 0;
78940 }
78941 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78942 create_dev("/dev/root.old", Root_RAM0);
78943 /* mount initrd on rootfs' /root */
78944 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78945 - sys_mkdir("/old", 0700);
78946 - sys_chdir("/old");
78947 + sys_mkdir((const char __force_user *)"/old", 0700);
78948 + sys_chdir((const char __force_user *)"/old");
78949
78950 /* try loading default modules from initrd */
78951 load_default_modules();
78952 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78953 current->flags &= ~PF_FREEZER_SKIP;
78954
78955 /* move initrd to rootfs' /old */
78956 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78957 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78958 /* switch root and cwd back to / of rootfs */
78959 - sys_chroot("..");
78960 + sys_chroot((const char __force_user *)"..");
78961
78962 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78963 - sys_chdir("/old");
78964 + sys_chdir((const char __force_user *)"/old");
78965 return;
78966 }
78967
78968 - sys_chdir("/");
78969 + sys_chdir((const char __force_user *)"/");
78970 ROOT_DEV = new_decode_dev(real_root_dev);
78971 mount_root();
78972
78973 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78974 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78975 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78976 if (!error)
78977 printk("okay\n");
78978 else {
78979 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78980 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78981 if (error == -ENOENT)
78982 printk("/initrd does not exist. Ignored.\n");
78983 else
78984 printk("failed\n");
78985 printk(KERN_NOTICE "Unmounting old root\n");
78986 - sys_umount("/old", MNT_DETACH);
78987 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78988 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78989 if (fd < 0) {
78990 error = fd;
78991 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78992 * mounted in the normal path.
78993 */
78994 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78995 - sys_unlink("/initrd.image");
78996 + sys_unlink((const char __force_user *)"/initrd.image");
78997 handle_initrd();
78998 return 1;
78999 }
79000 }
79001 - sys_unlink("/initrd.image");
79002 + sys_unlink((const char __force_user *)"/initrd.image");
79003 return 0;
79004 }
79005 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
79006 index 8cb6db5..d729f50 100644
79007 --- a/init/do_mounts_md.c
79008 +++ b/init/do_mounts_md.c
79009 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
79010 partitioned ? "_d" : "", minor,
79011 md_setup_args[ent].device_names);
79012
79013 - fd = sys_open(name, 0, 0);
79014 + fd = sys_open((char __force_user *)name, 0, 0);
79015 if (fd < 0) {
79016 printk(KERN_ERR "md: open failed - cannot start "
79017 "array %s\n", name);
79018 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
79019 * array without it
79020 */
79021 sys_close(fd);
79022 - fd = sys_open(name, 0, 0);
79023 + fd = sys_open((char __force_user *)name, 0, 0);
79024 sys_ioctl(fd, BLKRRPART, 0);
79025 }
79026 sys_close(fd);
79027 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
79028
79029 wait_for_device_probe();
79030
79031 - fd = sys_open("/dev/md0", 0, 0);
79032 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
79033 if (fd >= 0) {
79034 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
79035 sys_close(fd);
79036 diff --git a/init/init_task.c b/init/init_task.c
79037 index ba0a7f36..2bcf1d5 100644
79038 --- a/init/init_task.c
79039 +++ b/init/init_task.c
79040 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79041 * Initial thread structure. Alignment of this is handled by a special
79042 * linker map entry.
79043 */
79044 +#ifdef CONFIG_X86
79045 +union thread_union init_thread_union __init_task_data;
79046 +#else
79047 union thread_union init_thread_union __init_task_data =
79048 { INIT_THREAD_INFO(init_task) };
79049 +#endif
79050 diff --git a/init/initramfs.c b/init/initramfs.c
79051 index a67ef9d..2d17ed9 100644
79052 --- a/init/initramfs.c
79053 +++ b/init/initramfs.c
79054 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79055 }
79056 }
79057
79058 -static long __init do_utime(char *filename, time_t mtime)
79059 +static long __init do_utime(char __force_user *filename, time_t mtime)
79060 {
79061 struct timespec t[2];
79062
79063 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79064 struct dir_entry *de, *tmp;
79065 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79066 list_del(&de->list);
79067 - do_utime(de->name, de->mtime);
79068 + do_utime((char __force_user *)de->name, de->mtime);
79069 kfree(de->name);
79070 kfree(de);
79071 }
79072 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79073 if (nlink >= 2) {
79074 char *old = find_link(major, minor, ino, mode, collected);
79075 if (old)
79076 - return (sys_link(old, collected) < 0) ? -1 : 1;
79077 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79078 }
79079 return 0;
79080 }
79081 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79082 {
79083 struct stat st;
79084
79085 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79086 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79087 if (S_ISDIR(st.st_mode))
79088 - sys_rmdir(path);
79089 + sys_rmdir((char __force_user *)path);
79090 else
79091 - sys_unlink(path);
79092 + sys_unlink((char __force_user *)path);
79093 }
79094 }
79095
79096 @@ -315,7 +315,7 @@ static int __init do_name(void)
79097 int openflags = O_WRONLY|O_CREAT;
79098 if (ml != 1)
79099 openflags |= O_TRUNC;
79100 - wfd = sys_open(collected, openflags, mode);
79101 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79102
79103 if (wfd >= 0) {
79104 sys_fchown(wfd, uid, gid);
79105 @@ -327,17 +327,17 @@ static int __init do_name(void)
79106 }
79107 }
79108 } else if (S_ISDIR(mode)) {
79109 - sys_mkdir(collected, mode);
79110 - sys_chown(collected, uid, gid);
79111 - sys_chmod(collected, mode);
79112 + sys_mkdir((char __force_user *)collected, mode);
79113 + sys_chown((char __force_user *)collected, uid, gid);
79114 + sys_chmod((char __force_user *)collected, mode);
79115 dir_add(collected, mtime);
79116 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79117 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79118 if (maybe_link() == 0) {
79119 - sys_mknod(collected, mode, rdev);
79120 - sys_chown(collected, uid, gid);
79121 - sys_chmod(collected, mode);
79122 - do_utime(collected, mtime);
79123 + sys_mknod((char __force_user *)collected, mode, rdev);
79124 + sys_chown((char __force_user *)collected, uid, gid);
79125 + sys_chmod((char __force_user *)collected, mode);
79126 + do_utime((char __force_user *)collected, mtime);
79127 }
79128 }
79129 return 0;
79130 @@ -346,15 +346,15 @@ static int __init do_name(void)
79131 static int __init do_copy(void)
79132 {
79133 if (count >= body_len) {
79134 - sys_write(wfd, victim, body_len);
79135 + sys_write(wfd, (char __force_user *)victim, body_len);
79136 sys_close(wfd);
79137 - do_utime(vcollected, mtime);
79138 + do_utime((char __force_user *)vcollected, mtime);
79139 kfree(vcollected);
79140 eat(body_len);
79141 state = SkipIt;
79142 return 0;
79143 } else {
79144 - sys_write(wfd, victim, count);
79145 + sys_write(wfd, (char __force_user *)victim, count);
79146 body_len -= count;
79147 eat(count);
79148 return 1;
79149 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79150 {
79151 collected[N_ALIGN(name_len) + body_len] = '\0';
79152 clean_path(collected, 0);
79153 - sys_symlink(collected + N_ALIGN(name_len), collected);
79154 - sys_lchown(collected, uid, gid);
79155 - do_utime(collected, mtime);
79156 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79157 + sys_lchown((char __force_user *)collected, uid, gid);
79158 + do_utime((char __force_user *)collected, mtime);
79159 state = SkipIt;
79160 next_state = Reset;
79161 return 0;
79162 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79163 {
79164 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79165 if (err)
79166 - panic(err); /* Failed to decompress INTERNAL initramfs */
79167 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79168 if (initrd_start) {
79169 #ifdef CONFIG_BLK_DEV_RAM
79170 int fd;
79171 diff --git a/init/main.c b/init/main.c
79172 index 586cd33..f1af30f 100644
79173 --- a/init/main.c
79174 +++ b/init/main.c
79175 @@ -102,6 +102,8 @@ static inline void mark_rodata_ro(void) { }
79176 extern void tc_init(void);
79177 #endif
79178
79179 +extern void grsecurity_init(void);
79180 +
79181 /*
79182 * Debug helper: via this flag we know that we are in 'early bootup code'
79183 * where only the boot processor is running with IRQ disabled. This means
79184 @@ -155,6 +157,74 @@ static int __init set_reset_devices(char *str)
79185
79186 __setup("reset_devices", set_reset_devices);
79187
79188 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79189 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79190 +static int __init setup_grsec_proc_gid(char *str)
79191 +{
79192 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79193 + return 1;
79194 +}
79195 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79196 +#endif
79197 +
79198 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79199 +unsigned long pax_user_shadow_base __read_only;
79200 +EXPORT_SYMBOL(pax_user_shadow_base);
79201 +extern char pax_enter_kernel_user[];
79202 +extern char pax_exit_kernel_user[];
79203 +#endif
79204 +
79205 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79206 +static int __init setup_pax_nouderef(char *str)
79207 +{
79208 +#ifdef CONFIG_X86_32
79209 + unsigned int cpu;
79210 + struct desc_struct *gdt;
79211 +
79212 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79213 + gdt = get_cpu_gdt_table(cpu);
79214 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79215 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79216 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79217 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79218 + }
79219 + loadsegment(ds, __KERNEL_DS);
79220 + loadsegment(es, __KERNEL_DS);
79221 + loadsegment(ss, __KERNEL_DS);
79222 +#else
79223 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79224 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79225 + clone_pgd_mask = ~(pgdval_t)0UL;
79226 + pax_user_shadow_base = 0UL;
79227 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79228 +#endif
79229 +
79230 + return 0;
79231 +}
79232 +early_param("pax_nouderef", setup_pax_nouderef);
79233 +
79234 +#ifdef CONFIG_X86_64
79235 +static int __init setup_pax_weakuderef(char *str)
79236 +{
79237 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79238 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79239 + return 1;
79240 +}
79241 +__setup("pax_weakuderef", setup_pax_weakuderef);
79242 +#endif
79243 +#endif
79244 +
79245 +#ifdef CONFIG_PAX_SOFTMODE
79246 +int pax_softmode;
79247 +
79248 +static int __init setup_pax_softmode(char *str)
79249 +{
79250 + get_option(&str, &pax_softmode);
79251 + return 1;
79252 +}
79253 +__setup("pax_softmode=", setup_pax_softmode);
79254 +#endif
79255 +
79256 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79257 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79258 static const char *panic_later, *panic_param;
79259 @@ -680,25 +750,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79260 {
79261 int count = preempt_count();
79262 int ret;
79263 - char msgbuf[64];
79264 + const char *msg1 = "", *msg2 = "";
79265
79266 if (initcall_debug)
79267 ret = do_one_initcall_debug(fn);
79268 else
79269 ret = fn();
79270
79271 - msgbuf[0] = 0;
79272 -
79273 if (preempt_count() != count) {
79274 - sprintf(msgbuf, "preemption imbalance ");
79275 + msg1 = " preemption imbalance";
79276 preempt_count() = count;
79277 }
79278 if (irqs_disabled()) {
79279 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79280 + msg2 = " disabled interrupts";
79281 local_irq_enable();
79282 }
79283 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79284 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79285
79286 + add_latent_entropy();
79287 return ret;
79288 }
79289
79290 @@ -805,8 +874,8 @@ static int run_init_process(const char *init_filename)
79291 {
79292 argv_init[0] = init_filename;
79293 return do_execve(init_filename,
79294 - (const char __user *const __user *)argv_init,
79295 - (const char __user *const __user *)envp_init);
79296 + (const char __user *const __force_user *)argv_init,
79297 + (const char __user *const __force_user *)envp_init);
79298 }
79299
79300 static noinline void __init kernel_init_freeable(void);
79301 @@ -883,7 +952,7 @@ static noinline void __init kernel_init_freeable(void)
79302 do_basic_setup();
79303
79304 /* Open the /dev/console on the rootfs, this should never fail */
79305 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79306 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79307 pr_err("Warning: unable to open an initial console.\n");
79308
79309 (void) sys_dup(0);
79310 @@ -896,11 +965,13 @@ static noinline void __init kernel_init_freeable(void)
79311 if (!ramdisk_execute_command)
79312 ramdisk_execute_command = "/init";
79313
79314 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79315 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79316 ramdisk_execute_command = NULL;
79317 prepare_namespace();
79318 }
79319
79320 + grsecurity_init();
79321 +
79322 /*
79323 * Ok, we have completed the initial bootup, and
79324 * we're essentially up and running. Get rid of the
79325 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79326 index 130dfec..cc88451 100644
79327 --- a/ipc/ipc_sysctl.c
79328 +++ b/ipc/ipc_sysctl.c
79329 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79330 static int proc_ipc_dointvec(ctl_table *table, int write,
79331 void __user *buffer, size_t *lenp, loff_t *ppos)
79332 {
79333 - struct ctl_table ipc_table;
79334 + ctl_table_no_const ipc_table;
79335
79336 memcpy(&ipc_table, table, sizeof(ipc_table));
79337 ipc_table.data = get_ipc(table);
79338 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79339 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79340 void __user *buffer, size_t *lenp, loff_t *ppos)
79341 {
79342 - struct ctl_table ipc_table;
79343 + ctl_table_no_const ipc_table;
79344
79345 memcpy(&ipc_table, table, sizeof(ipc_table));
79346 ipc_table.data = get_ipc(table);
79347 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79348 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79349 void __user *buffer, size_t *lenp, loff_t *ppos)
79350 {
79351 - struct ctl_table ipc_table;
79352 + ctl_table_no_const ipc_table;
79353 size_t lenp_bef = *lenp;
79354 int rc;
79355
79356 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79357 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79358 void __user *buffer, size_t *lenp, loff_t *ppos)
79359 {
79360 - struct ctl_table ipc_table;
79361 + ctl_table_no_const ipc_table;
79362 memcpy(&ipc_table, table, sizeof(ipc_table));
79363 ipc_table.data = get_ipc(table);
79364
79365 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79366 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79367 void __user *buffer, size_t *lenp, loff_t *ppos)
79368 {
79369 - struct ctl_table ipc_table;
79370 + ctl_table_no_const ipc_table;
79371 size_t lenp_bef = *lenp;
79372 int oldval;
79373 int rc;
79374 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79375 index 383d638..943fdbb 100644
79376 --- a/ipc/mq_sysctl.c
79377 +++ b/ipc/mq_sysctl.c
79378 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79379 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79380 void __user *buffer, size_t *lenp, loff_t *ppos)
79381 {
79382 - struct ctl_table mq_table;
79383 + ctl_table_no_const mq_table;
79384 memcpy(&mq_table, table, sizeof(mq_table));
79385 mq_table.data = get_mq(table);
79386
79387 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79388 index ae1996d..a35f2cc 100644
79389 --- a/ipc/mqueue.c
79390 +++ b/ipc/mqueue.c
79391 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79392 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79393 info->attr.mq_msgsize);
79394
79395 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79396 spin_lock(&mq_lock);
79397 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79398 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79399 diff --git a/ipc/msg.c b/ipc/msg.c
79400 index 558aa91..359e718 100644
79401 --- a/ipc/msg.c
79402 +++ b/ipc/msg.c
79403 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79404 return security_msg_queue_associate(msq, msgflg);
79405 }
79406
79407 +static struct ipc_ops msg_ops = {
79408 + .getnew = newque,
79409 + .associate = msg_security,
79410 + .more_checks = NULL
79411 +};
79412 +
79413 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79414 {
79415 struct ipc_namespace *ns;
79416 - struct ipc_ops msg_ops;
79417 struct ipc_params msg_params;
79418
79419 ns = current->nsproxy->ipc_ns;
79420
79421 - msg_ops.getnew = newque;
79422 - msg_ops.associate = msg_security;
79423 - msg_ops.more_checks = NULL;
79424 -
79425 msg_params.key = key;
79426 msg_params.flg = msgflg;
79427
79428 diff --git a/ipc/sem.c b/ipc/sem.c
79429 index 8e2bf30..a711151 100644
79430 --- a/ipc/sem.c
79431 +++ b/ipc/sem.c
79432 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79433 return 0;
79434 }
79435
79436 +static struct ipc_ops sem_ops = {
79437 + .getnew = newary,
79438 + .associate = sem_security,
79439 + .more_checks = sem_more_checks
79440 +};
79441 +
79442 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79443 {
79444 struct ipc_namespace *ns;
79445 - struct ipc_ops sem_ops;
79446 struct ipc_params sem_params;
79447
79448 ns = current->nsproxy->ipc_ns;
79449 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79450 if (nsems < 0 || nsems > ns->sc_semmsl)
79451 return -EINVAL;
79452
79453 - sem_ops.getnew = newary;
79454 - sem_ops.associate = sem_security;
79455 - sem_ops.more_checks = sem_more_checks;
79456 -
79457 sem_params.key = key;
79458 sem_params.flg = semflg;
79459 sem_params.u.nsems = nsems;
79460 diff --git a/ipc/shm.c b/ipc/shm.c
79461 index d697396..40e887d 100644
79462 --- a/ipc/shm.c
79463 +++ b/ipc/shm.c
79464 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79465 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79466 #endif
79467
79468 +#ifdef CONFIG_GRKERNSEC
79469 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79470 + const time_t shm_createtime, const kuid_t cuid,
79471 + const int shmid);
79472 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79473 + const time_t shm_createtime);
79474 +#endif
79475 +
79476 void shm_init_ns(struct ipc_namespace *ns)
79477 {
79478 ns->shm_ctlmax = SHMMAX;
79479 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79480 shp->shm_lprid = 0;
79481 shp->shm_atim = shp->shm_dtim = 0;
79482 shp->shm_ctim = get_seconds();
79483 +#ifdef CONFIG_GRKERNSEC
79484 + {
79485 + struct timespec timeval;
79486 + do_posix_clock_monotonic_gettime(&timeval);
79487 +
79488 + shp->shm_createtime = timeval.tv_sec;
79489 + }
79490 +#endif
79491 shp->shm_segsz = size;
79492 shp->shm_nattch = 0;
79493 shp->shm_file = file;
79494 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79495 return 0;
79496 }
79497
79498 +static struct ipc_ops shm_ops = {
79499 + .getnew = newseg,
79500 + .associate = shm_security,
79501 + .more_checks = shm_more_checks
79502 +};
79503 +
79504 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79505 {
79506 struct ipc_namespace *ns;
79507 - struct ipc_ops shm_ops;
79508 struct ipc_params shm_params;
79509
79510 ns = current->nsproxy->ipc_ns;
79511
79512 - shm_ops.getnew = newseg;
79513 - shm_ops.associate = shm_security;
79514 - shm_ops.more_checks = shm_more_checks;
79515 -
79516 shm_params.key = key;
79517 shm_params.flg = shmflg;
79518 shm_params.u.size = size;
79519 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79520 f_mode = FMODE_READ | FMODE_WRITE;
79521 }
79522 if (shmflg & SHM_EXEC) {
79523 +
79524 +#ifdef CONFIG_PAX_MPROTECT
79525 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79526 + goto out;
79527 +#endif
79528 +
79529 prot |= PROT_EXEC;
79530 acc_mode |= S_IXUGO;
79531 }
79532 @@ -1100,10 +1123,22 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79533 if (err)
79534 goto out_unlock;
79535
79536 +#ifdef CONFIG_GRKERNSEC
79537 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79538 + shp->shm_perm.cuid, shmid) ||
79539 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79540 + err = -EACCES;
79541 + goto out_unlock;
79542 + }
79543 +#endif
79544 +
79545 ipc_lock_object(&shp->shm_perm);
79546 path = shp->shm_file->f_path;
79547 path_get(&path);
79548 shp->shm_nattch++;
79549 +#ifdef CONFIG_GRKERNSEC
79550 + shp->shm_lapid = current->pid;
79551 +#endif
79552 size = i_size_read(path.dentry->d_inode);
79553 ipc_unlock_object(&shp->shm_perm);
79554 rcu_read_unlock();
79555 diff --git a/kernel/acct.c b/kernel/acct.c
79556 index 8d6e145..33e0b1e 100644
79557 --- a/kernel/acct.c
79558 +++ b/kernel/acct.c
79559 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79560 */
79561 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79562 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79563 - file->f_op->write(file, (char *)&ac,
79564 + file->f_op->write(file, (char __force_user *)&ac,
79565 sizeof(acct_t), &file->f_pos);
79566 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79567 set_fs(fs);
79568 diff --git a/kernel/audit.c b/kernel/audit.c
79569 index 7b0e23a..5b27ab9 100644
79570 --- a/kernel/audit.c
79571 +++ b/kernel/audit.c
79572 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79573 3) suppressed due to audit_rate_limit
79574 4) suppressed due to audit_backlog_limit
79575 */
79576 -static atomic_t audit_lost = ATOMIC_INIT(0);
79577 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79578
79579 /* The netlink socket. */
79580 static struct sock *audit_sock;
79581 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79582 unsigned long now;
79583 int print;
79584
79585 - atomic_inc(&audit_lost);
79586 + atomic_inc_unchecked(&audit_lost);
79587
79588 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79589
79590 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79591 printk(KERN_WARNING
79592 "audit: audit_lost=%d audit_rate_limit=%d "
79593 "audit_backlog_limit=%d\n",
79594 - atomic_read(&audit_lost),
79595 + atomic_read_unchecked(&audit_lost),
79596 audit_rate_limit,
79597 audit_backlog_limit);
79598 audit_panic(message);
79599 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79600
79601 switch (msg_type) {
79602 case AUDIT_GET:
79603 + status_set.mask = 0;
79604 status_set.enabled = audit_enabled;
79605 status_set.failure = audit_failure;
79606 status_set.pid = audit_pid;
79607 status_set.rate_limit = audit_rate_limit;
79608 status_set.backlog_limit = audit_backlog_limit;
79609 - status_set.lost = atomic_read(&audit_lost);
79610 + status_set.lost = atomic_read_unchecked(&audit_lost);
79611 status_set.backlog = skb_queue_len(&audit_skb_queue);
79612 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79613 &status_set, sizeof(status_set));
79614 break;
79615 case AUDIT_SET:
79616 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79617 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79618 return -EINVAL;
79619 status_get = (struct audit_status *)data;
79620 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79621 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79622
79623 memset(&s, 0, sizeof(s));
79624 /* guard against past and future API changes */
79625 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79626 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79627 if ((s.enabled != 0 && s.enabled != 1) ||
79628 (s.log_passwd != 0 && s.log_passwd != 1))
79629 return -EINVAL;
79630 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79631 index 9845cb3..3ec9369 100644
79632 --- a/kernel/auditsc.c
79633 +++ b/kernel/auditsc.c
79634 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79635 }
79636
79637 /* global counter which is incremented every time something logs in */
79638 -static atomic_t session_id = ATOMIC_INIT(0);
79639 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79640
79641 /**
79642 * audit_set_loginuid - set current task's audit_context loginuid
79643 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79644 return -EPERM;
79645 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79646
79647 - sessionid = atomic_inc_return(&session_id);
79648 + sessionid = atomic_inc_return_unchecked(&session_id);
79649 if (context && context->in_syscall) {
79650 struct audit_buffer *ab;
79651
79652 diff --git a/kernel/capability.c b/kernel/capability.c
79653 index f6c2ce5..982c0f9 100644
79654 --- a/kernel/capability.c
79655 +++ b/kernel/capability.c
79656 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79657 * before modification is attempted and the application
79658 * fails.
79659 */
79660 + if (tocopy > ARRAY_SIZE(kdata))
79661 + return -EFAULT;
79662 +
79663 if (copy_to_user(dataptr, kdata, tocopy
79664 * sizeof(struct __user_cap_data_struct))) {
79665 return -EFAULT;
79666 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79667 int ret;
79668
79669 rcu_read_lock();
79670 - ret = security_capable(__task_cred(t), ns, cap);
79671 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79672 + gr_task_is_capable(t, __task_cred(t), cap);
79673 rcu_read_unlock();
79674
79675 - return (ret == 0);
79676 + return ret;
79677 }
79678
79679 /**
79680 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79681 int ret;
79682
79683 rcu_read_lock();
79684 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79685 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79686 rcu_read_unlock();
79687
79688 - return (ret == 0);
79689 + return ret;
79690 }
79691
79692 /**
79693 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79694 BUG();
79695 }
79696
79697 - if (security_capable(current_cred(), ns, cap) == 0) {
79698 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79699 current->flags |= PF_SUPERPRIV;
79700 return true;
79701 }
79702 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79703 }
79704 EXPORT_SYMBOL(ns_capable);
79705
79706 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79707 +{
79708 + if (unlikely(!cap_valid(cap))) {
79709 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79710 + BUG();
79711 + }
79712 +
79713 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79714 + current->flags |= PF_SUPERPRIV;
79715 + return true;
79716 + }
79717 + return false;
79718 +}
79719 +EXPORT_SYMBOL(ns_capable_nolog);
79720 +
79721 /**
79722 * file_ns_capable - Determine if the file's opener had a capability in effect
79723 * @file: The file we want to check
79724 @@ -432,6 +451,12 @@ bool capable(int cap)
79725 }
79726 EXPORT_SYMBOL(capable);
79727
79728 +bool capable_nolog(int cap)
79729 +{
79730 + return ns_capable_nolog(&init_user_ns, cap);
79731 +}
79732 +EXPORT_SYMBOL(capable_nolog);
79733 +
79734 /**
79735 * nsown_capable - Check superior capability to one's own user_ns
79736 * @cap: The capability in question
79737 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79738
79739 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79740 }
79741 +
79742 +bool inode_capable_nolog(const struct inode *inode, int cap)
79743 +{
79744 + struct user_namespace *ns = current_user_ns();
79745 +
79746 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79747 +}
79748 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79749 index e919633..f46b08f 100644
79750 --- a/kernel/cgroup.c
79751 +++ b/kernel/cgroup.c
79752 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79753 struct css_set *cset = link->cset;
79754 struct task_struct *task;
79755 int count = 0;
79756 - seq_printf(seq, "css_set %p\n", cset);
79757 + seq_printf(seq, "css_set %pK\n", cset);
79758 list_for_each_entry(task, &cset->tasks, cg_list) {
79759 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79760 seq_puts(seq, " ...\n");
79761 diff --git a/kernel/compat.c b/kernel/compat.c
79762 index 0a09e48..f44f3f0 100644
79763 --- a/kernel/compat.c
79764 +++ b/kernel/compat.c
79765 @@ -13,6 +13,7 @@
79766
79767 #include <linux/linkage.h>
79768 #include <linux/compat.h>
79769 +#include <linux/module.h>
79770 #include <linux/errno.h>
79771 #include <linux/time.h>
79772 #include <linux/signal.h>
79773 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79774 mm_segment_t oldfs;
79775 long ret;
79776
79777 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79778 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79779 oldfs = get_fs();
79780 set_fs(KERNEL_DS);
79781 ret = hrtimer_nanosleep_restart(restart);
79782 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79783 oldfs = get_fs();
79784 set_fs(KERNEL_DS);
79785 ret = hrtimer_nanosleep(&tu,
79786 - rmtp ? (struct timespec __user *)&rmt : NULL,
79787 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79788 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79789 set_fs(oldfs);
79790
79791 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79792 mm_segment_t old_fs = get_fs();
79793
79794 set_fs(KERNEL_DS);
79795 - ret = sys_sigpending((old_sigset_t __user *) &s);
79796 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79797 set_fs(old_fs);
79798 if (ret == 0)
79799 ret = put_user(s, set);
79800 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79801 mm_segment_t old_fs = get_fs();
79802
79803 set_fs(KERNEL_DS);
79804 - ret = sys_old_getrlimit(resource, &r);
79805 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79806 set_fs(old_fs);
79807
79808 if (!ret) {
79809 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79810 set_fs (KERNEL_DS);
79811 ret = sys_wait4(pid,
79812 (stat_addr ?
79813 - (unsigned int __user *) &status : NULL),
79814 - options, (struct rusage __user *) &r);
79815 + (unsigned int __force_user *) &status : NULL),
79816 + options, (struct rusage __force_user *) &r);
79817 set_fs (old_fs);
79818
79819 if (ret > 0) {
79820 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79821 memset(&info, 0, sizeof(info));
79822
79823 set_fs(KERNEL_DS);
79824 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79825 - uru ? (struct rusage __user *)&ru : NULL);
79826 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79827 + uru ? (struct rusage __force_user *)&ru : NULL);
79828 set_fs(old_fs);
79829
79830 if ((ret < 0) || (info.si_signo == 0))
79831 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79832 oldfs = get_fs();
79833 set_fs(KERNEL_DS);
79834 err = sys_timer_settime(timer_id, flags,
79835 - (struct itimerspec __user *) &newts,
79836 - (struct itimerspec __user *) &oldts);
79837 + (struct itimerspec __force_user *) &newts,
79838 + (struct itimerspec __force_user *) &oldts);
79839 set_fs(oldfs);
79840 if (!err && old && put_compat_itimerspec(old, &oldts))
79841 return -EFAULT;
79842 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79843 oldfs = get_fs();
79844 set_fs(KERNEL_DS);
79845 err = sys_timer_gettime(timer_id,
79846 - (struct itimerspec __user *) &ts);
79847 + (struct itimerspec __force_user *) &ts);
79848 set_fs(oldfs);
79849 if (!err && put_compat_itimerspec(setting, &ts))
79850 return -EFAULT;
79851 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79852 oldfs = get_fs();
79853 set_fs(KERNEL_DS);
79854 err = sys_clock_settime(which_clock,
79855 - (struct timespec __user *) &ts);
79856 + (struct timespec __force_user *) &ts);
79857 set_fs(oldfs);
79858 return err;
79859 }
79860 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79861 oldfs = get_fs();
79862 set_fs(KERNEL_DS);
79863 err = sys_clock_gettime(which_clock,
79864 - (struct timespec __user *) &ts);
79865 + (struct timespec __force_user *) &ts);
79866 set_fs(oldfs);
79867 if (!err && put_compat_timespec(&ts, tp))
79868 return -EFAULT;
79869 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79870
79871 oldfs = get_fs();
79872 set_fs(KERNEL_DS);
79873 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79874 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79875 set_fs(oldfs);
79876
79877 err = compat_put_timex(utp, &txc);
79878 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79879 oldfs = get_fs();
79880 set_fs(KERNEL_DS);
79881 err = sys_clock_getres(which_clock,
79882 - (struct timespec __user *) &ts);
79883 + (struct timespec __force_user *) &ts);
79884 set_fs(oldfs);
79885 if (!err && tp && put_compat_timespec(&ts, tp))
79886 return -EFAULT;
79887 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79888 long err;
79889 mm_segment_t oldfs;
79890 struct timespec tu;
79891 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79892 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79893
79894 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79895 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79896 oldfs = get_fs();
79897 set_fs(KERNEL_DS);
79898 err = clock_nanosleep_restart(restart);
79899 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79900 oldfs = get_fs();
79901 set_fs(KERNEL_DS);
79902 err = sys_clock_nanosleep(which_clock, flags,
79903 - (struct timespec __user *) &in,
79904 - (struct timespec __user *) &out);
79905 + (struct timespec __force_user *) &in,
79906 + (struct timespec __force_user *) &out);
79907 set_fs(oldfs);
79908
79909 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79910 diff --git a/kernel/configs.c b/kernel/configs.c
79911 index c18b1f1..b9a0132 100644
79912 --- a/kernel/configs.c
79913 +++ b/kernel/configs.c
79914 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79915 struct proc_dir_entry *entry;
79916
79917 /* create the current config file */
79918 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79919 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79920 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79921 + &ikconfig_file_ops);
79922 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79923 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79924 + &ikconfig_file_ops);
79925 +#endif
79926 +#else
79927 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79928 &ikconfig_file_ops);
79929 +#endif
79930 +
79931 if (!entry)
79932 return -ENOMEM;
79933
79934 diff --git a/kernel/cred.c b/kernel/cred.c
79935 index e0573a4..3874e41 100644
79936 --- a/kernel/cred.c
79937 +++ b/kernel/cred.c
79938 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79939 validate_creds(cred);
79940 alter_cred_subscribers(cred, -1);
79941 put_cred(cred);
79942 +
79943 +#ifdef CONFIG_GRKERNSEC_SETXID
79944 + cred = (struct cred *) tsk->delayed_cred;
79945 + if (cred != NULL) {
79946 + tsk->delayed_cred = NULL;
79947 + validate_creds(cred);
79948 + alter_cred_subscribers(cred, -1);
79949 + put_cred(cred);
79950 + }
79951 +#endif
79952 }
79953
79954 /**
79955 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79956 * Always returns 0 thus allowing this function to be tail-called at the end
79957 * of, say, sys_setgid().
79958 */
79959 -int commit_creds(struct cred *new)
79960 +static int __commit_creds(struct cred *new)
79961 {
79962 struct task_struct *task = current;
79963 const struct cred *old = task->real_cred;
79964 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79965
79966 get_cred(new); /* we will require a ref for the subj creds too */
79967
79968 + gr_set_role_label(task, new->uid, new->gid);
79969 +
79970 /* dumpability changes */
79971 if (!uid_eq(old->euid, new->euid) ||
79972 !gid_eq(old->egid, new->egid) ||
79973 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79974 put_cred(old);
79975 return 0;
79976 }
79977 +#ifdef CONFIG_GRKERNSEC_SETXID
79978 +extern int set_user(struct cred *new);
79979 +
79980 +void gr_delayed_cred_worker(void)
79981 +{
79982 + const struct cred *new = current->delayed_cred;
79983 + struct cred *ncred;
79984 +
79985 + current->delayed_cred = NULL;
79986 +
79987 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79988 + // from doing get_cred on it when queueing this
79989 + put_cred(new);
79990 + return;
79991 + } else if (new == NULL)
79992 + return;
79993 +
79994 + ncred = prepare_creds();
79995 + if (!ncred)
79996 + goto die;
79997 + // uids
79998 + ncred->uid = new->uid;
79999 + ncred->euid = new->euid;
80000 + ncred->suid = new->suid;
80001 + ncred->fsuid = new->fsuid;
80002 + // gids
80003 + ncred->gid = new->gid;
80004 + ncred->egid = new->egid;
80005 + ncred->sgid = new->sgid;
80006 + ncred->fsgid = new->fsgid;
80007 + // groups
80008 + if (set_groups(ncred, new->group_info) < 0) {
80009 + abort_creds(ncred);
80010 + goto die;
80011 + }
80012 + // caps
80013 + ncred->securebits = new->securebits;
80014 + ncred->cap_inheritable = new->cap_inheritable;
80015 + ncred->cap_permitted = new->cap_permitted;
80016 + ncred->cap_effective = new->cap_effective;
80017 + ncred->cap_bset = new->cap_bset;
80018 +
80019 + if (set_user(ncred)) {
80020 + abort_creds(ncred);
80021 + goto die;
80022 + }
80023 +
80024 + // from doing get_cred on it when queueing this
80025 + put_cred(new);
80026 +
80027 + __commit_creds(ncred);
80028 + return;
80029 +die:
80030 + // from doing get_cred on it when queueing this
80031 + put_cred(new);
80032 + do_group_exit(SIGKILL);
80033 +}
80034 +#endif
80035 +
80036 +int commit_creds(struct cred *new)
80037 +{
80038 +#ifdef CONFIG_GRKERNSEC_SETXID
80039 + int ret;
80040 + int schedule_it = 0;
80041 + struct task_struct *t;
80042 +
80043 + /* we won't get called with tasklist_lock held for writing
80044 + and interrupts disabled as the cred struct in that case is
80045 + init_cred
80046 + */
80047 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80048 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80049 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80050 + schedule_it = 1;
80051 + }
80052 + ret = __commit_creds(new);
80053 + if (schedule_it) {
80054 + rcu_read_lock();
80055 + read_lock(&tasklist_lock);
80056 + for (t = next_thread(current); t != current;
80057 + t = next_thread(t)) {
80058 + if (t->delayed_cred == NULL) {
80059 + t->delayed_cred = get_cred(new);
80060 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80061 + set_tsk_need_resched(t);
80062 + }
80063 + }
80064 + read_unlock(&tasklist_lock);
80065 + rcu_read_unlock();
80066 + }
80067 + return ret;
80068 +#else
80069 + return __commit_creds(new);
80070 +#endif
80071 +}
80072 +
80073 EXPORT_SYMBOL(commit_creds);
80074
80075 /**
80076 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80077 index 0506d44..2c20034 100644
80078 --- a/kernel/debug/debug_core.c
80079 +++ b/kernel/debug/debug_core.c
80080 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80081 */
80082 static atomic_t masters_in_kgdb;
80083 static atomic_t slaves_in_kgdb;
80084 -static atomic_t kgdb_break_tasklet_var;
80085 +static atomic_unchecked_t kgdb_break_tasklet_var;
80086 atomic_t kgdb_setting_breakpoint;
80087
80088 struct task_struct *kgdb_usethread;
80089 @@ -133,7 +133,7 @@ int kgdb_single_step;
80090 static pid_t kgdb_sstep_pid;
80091
80092 /* to keep track of the CPU which is doing the single stepping*/
80093 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80094 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80095
80096 /*
80097 * If you are debugging a problem where roundup (the collection of
80098 @@ -541,7 +541,7 @@ return_normal:
80099 * kernel will only try for the value of sstep_tries before
80100 * giving up and continuing on.
80101 */
80102 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80103 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80104 (kgdb_info[cpu].task &&
80105 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80106 atomic_set(&kgdb_active, -1);
80107 @@ -635,8 +635,8 @@ cpu_master_loop:
80108 }
80109
80110 kgdb_restore:
80111 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80112 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80113 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80114 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80115 if (kgdb_info[sstep_cpu].task)
80116 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80117 else
80118 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80119 static void kgdb_tasklet_bpt(unsigned long ing)
80120 {
80121 kgdb_breakpoint();
80122 - atomic_set(&kgdb_break_tasklet_var, 0);
80123 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80124 }
80125
80126 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80127
80128 void kgdb_schedule_breakpoint(void)
80129 {
80130 - if (atomic_read(&kgdb_break_tasklet_var) ||
80131 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80132 atomic_read(&kgdb_active) != -1 ||
80133 atomic_read(&kgdb_setting_breakpoint))
80134 return;
80135 - atomic_inc(&kgdb_break_tasklet_var);
80136 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80137 tasklet_schedule(&kgdb_tasklet_breakpoint);
80138 }
80139 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80140 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80141 index 00eb8f7..d7e3244 100644
80142 --- a/kernel/debug/kdb/kdb_main.c
80143 +++ b/kernel/debug/kdb/kdb_main.c
80144 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80145 continue;
80146
80147 kdb_printf("%-20s%8u 0x%p ", mod->name,
80148 - mod->core_size, (void *)mod);
80149 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80150 #ifdef CONFIG_MODULE_UNLOAD
80151 kdb_printf("%4ld ", module_refcount(mod));
80152 #endif
80153 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80154 kdb_printf(" (Loading)");
80155 else
80156 kdb_printf(" (Live)");
80157 - kdb_printf(" 0x%p", mod->module_core);
80158 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80159
80160 #ifdef CONFIG_MODULE_UNLOAD
80161 {
80162 diff --git a/kernel/events/core.c b/kernel/events/core.c
80163 index f86599e..b18b180 100644
80164 --- a/kernel/events/core.c
80165 +++ b/kernel/events/core.c
80166 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80167 * 0 - disallow raw tracepoint access for unpriv
80168 * 1 - disallow cpu events for unpriv
80169 * 2 - disallow kernel profiling for unpriv
80170 + * 3 - disallow all unpriv perf event use
80171 */
80172 -int sysctl_perf_event_paranoid __read_mostly = 1;
80173 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80174 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80175 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80176 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80177 +#else
80178 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80179 +#endif
80180
80181 /* Minimum for 512 kiB + 1 user control page */
80182 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80183 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80184 update_perf_cpu_limits();
80185 }
80186
80187 -static atomic64_t perf_event_id;
80188 +static atomic64_unchecked_t perf_event_id;
80189
80190 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80191 enum event_type_t event_type);
80192 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80193
80194 static inline u64 perf_event_count(struct perf_event *event)
80195 {
80196 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80197 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80198 }
80199
80200 static u64 perf_event_read(struct perf_event *event)
80201 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80202 mutex_lock(&event->child_mutex);
80203 total += perf_event_read(event);
80204 *enabled += event->total_time_enabled +
80205 - atomic64_read(&event->child_total_time_enabled);
80206 + atomic64_read_unchecked(&event->child_total_time_enabled);
80207 *running += event->total_time_running +
80208 - atomic64_read(&event->child_total_time_running);
80209 + atomic64_read_unchecked(&event->child_total_time_running);
80210
80211 list_for_each_entry(child, &event->child_list, child_list) {
80212 total += perf_event_read(child);
80213 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80214 userpg->offset -= local64_read(&event->hw.prev_count);
80215
80216 userpg->time_enabled = enabled +
80217 - atomic64_read(&event->child_total_time_enabled);
80218 + atomic64_read_unchecked(&event->child_total_time_enabled);
80219
80220 userpg->time_running = running +
80221 - atomic64_read(&event->child_total_time_running);
80222 + atomic64_read_unchecked(&event->child_total_time_running);
80223
80224 arch_perf_update_userpage(userpg, now);
80225
80226 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80227
80228 /* Data. */
80229 sp = perf_user_stack_pointer(regs);
80230 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80231 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80232 dyn_size = dump_size - rem;
80233
80234 perf_output_skip(handle, rem);
80235 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80236 values[n++] = perf_event_count(event);
80237 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80238 values[n++] = enabled +
80239 - atomic64_read(&event->child_total_time_enabled);
80240 + atomic64_read_unchecked(&event->child_total_time_enabled);
80241 }
80242 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80243 values[n++] = running +
80244 - atomic64_read(&event->child_total_time_running);
80245 + atomic64_read_unchecked(&event->child_total_time_running);
80246 }
80247 if (read_format & PERF_FORMAT_ID)
80248 values[n++] = primary_event_id(event);
80249 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80250 * need to add enough zero bytes after the string to handle
80251 * the 64bit alignment we do later.
80252 */
80253 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80254 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80255 if (!buf) {
80256 name = strncpy(tmp, "//enomem", sizeof(tmp));
80257 goto got_name;
80258 }
80259 - name = d_path(&file->f_path, buf, PATH_MAX);
80260 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80261 if (IS_ERR(name)) {
80262 name = strncpy(tmp, "//toolong", sizeof(tmp));
80263 goto got_name;
80264 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80265 event->parent = parent_event;
80266
80267 event->ns = get_pid_ns(task_active_pid_ns(current));
80268 - event->id = atomic64_inc_return(&perf_event_id);
80269 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80270
80271 event->state = PERF_EVENT_STATE_INACTIVE;
80272
80273 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80274 if (flags & ~PERF_FLAG_ALL)
80275 return -EINVAL;
80276
80277 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80278 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80279 + return -EACCES;
80280 +#endif
80281 +
80282 err = perf_copy_attr(attr_uptr, &attr);
80283 if (err)
80284 return err;
80285 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80286 /*
80287 * Add back the child's count to the parent's count:
80288 */
80289 - atomic64_add(child_val, &parent_event->child_count);
80290 - atomic64_add(child_event->total_time_enabled,
80291 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80292 + atomic64_add_unchecked(child_event->total_time_enabled,
80293 &parent_event->child_total_time_enabled);
80294 - atomic64_add(child_event->total_time_running,
80295 + atomic64_add_unchecked(child_event->total_time_running,
80296 &parent_event->child_total_time_running);
80297
80298 /*
80299 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80300 index ca65997..60df03d 100644
80301 --- a/kernel/events/internal.h
80302 +++ b/kernel/events/internal.h
80303 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80304 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80305 }
80306
80307 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80308 -static inline unsigned int \
80309 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80310 +static inline unsigned long \
80311 func_name(struct perf_output_handle *handle, \
80312 - const void *buf, unsigned int len) \
80313 + const void user *buf, unsigned long len) \
80314 { \
80315 unsigned long size, written; \
80316 \
80317 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80318 return n;
80319 }
80320
80321 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80322 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80323
80324 #define MEMCPY_SKIP(dst, src, n) (n)
80325
80326 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80327 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80328
80329 #ifndef arch_perf_out_copy_user
80330 #define arch_perf_out_copy_user __copy_from_user_inatomic
80331 #endif
80332
80333 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80334 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80335
80336 /* Callchain handling */
80337 extern struct perf_callchain_entry *
80338 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80339 index ad8e1bd..fed7ba9 100644
80340 --- a/kernel/events/uprobes.c
80341 +++ b/kernel/events/uprobes.c
80342 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80343 {
80344 struct page *page;
80345 uprobe_opcode_t opcode;
80346 - int result;
80347 + long result;
80348
80349 pagefault_disable();
80350 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80351 diff --git a/kernel/exit.c b/kernel/exit.c
80352 index a949819..a5f127d 100644
80353 --- a/kernel/exit.c
80354 +++ b/kernel/exit.c
80355 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80356 struct task_struct *leader;
80357 int zap_leader;
80358 repeat:
80359 +#ifdef CONFIG_NET
80360 + gr_del_task_from_ip_table(p);
80361 +#endif
80362 +
80363 /* don't need to get the RCU readlock here - the process is dead and
80364 * can't be modifying its own credentials. But shut RCU-lockdep up */
80365 rcu_read_lock();
80366 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80367 * know it'll be handled, so that they don't get converted to
80368 * SIGKILL or just silently dropped.
80369 */
80370 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80371 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80372 recalc_sigpending();
80373 spin_unlock_irq(&current->sighand->siglock);
80374 return 0;
80375 @@ -698,6 +702,8 @@ void do_exit(long code)
80376 struct task_struct *tsk = current;
80377 int group_dead;
80378
80379 + set_fs(USER_DS);
80380 +
80381 profile_task_exit(tsk);
80382
80383 WARN_ON(blk_needs_flush_plug(tsk));
80384 @@ -714,7 +720,6 @@ void do_exit(long code)
80385 * mm_release()->clear_child_tid() from writing to a user-controlled
80386 * kernel address.
80387 */
80388 - set_fs(USER_DS);
80389
80390 ptrace_event(PTRACE_EVENT_EXIT, code);
80391
80392 @@ -773,6 +778,9 @@ void do_exit(long code)
80393 tsk->exit_code = code;
80394 taskstats_exit(tsk, group_dead);
80395
80396 + gr_acl_handle_psacct(tsk, code);
80397 + gr_acl_handle_exit();
80398 +
80399 exit_mm(tsk);
80400
80401 if (group_dead)
80402 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80403 * Take down every thread in the group. This is called by fatal signals
80404 * as well as by sys_exit_group (below).
80405 */
80406 -void
80407 +__noreturn void
80408 do_group_exit(int exit_code)
80409 {
80410 struct signal_struct *sig = current->signal;
80411 diff --git a/kernel/fork.c b/kernel/fork.c
80412 index 200a7a2..43e52da 100644
80413 --- a/kernel/fork.c
80414 +++ b/kernel/fork.c
80415 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80416 *stackend = STACK_END_MAGIC; /* for overflow detection */
80417
80418 #ifdef CONFIG_CC_STACKPROTECTOR
80419 - tsk->stack_canary = get_random_int();
80420 + tsk->stack_canary = pax_get_random_long();
80421 #endif
80422
80423 /*
80424 @@ -345,13 +345,81 @@ free_tsk:
80425 }
80426
80427 #ifdef CONFIG_MMU
80428 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80429 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80430 {
80431 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80432 - struct rb_node **rb_link, *rb_parent;
80433 - int retval;
80434 + struct vm_area_struct *tmp;
80435 unsigned long charge;
80436 struct mempolicy *pol;
80437 + struct file *file;
80438 +
80439 + charge = 0;
80440 + if (mpnt->vm_flags & VM_ACCOUNT) {
80441 + unsigned long len = vma_pages(mpnt);
80442 +
80443 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80444 + goto fail_nomem;
80445 + charge = len;
80446 + }
80447 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80448 + if (!tmp)
80449 + goto fail_nomem;
80450 + *tmp = *mpnt;
80451 + tmp->vm_mm = mm;
80452 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80453 + pol = mpol_dup(vma_policy(mpnt));
80454 + if (IS_ERR(pol))
80455 + goto fail_nomem_policy;
80456 + vma_set_policy(tmp, pol);
80457 + if (anon_vma_fork(tmp, mpnt))
80458 + goto fail_nomem_anon_vma_fork;
80459 + tmp->vm_flags &= ~VM_LOCKED;
80460 + tmp->vm_next = tmp->vm_prev = NULL;
80461 + tmp->vm_mirror = NULL;
80462 + file = tmp->vm_file;
80463 + if (file) {
80464 + struct inode *inode = file_inode(file);
80465 + struct address_space *mapping = file->f_mapping;
80466 +
80467 + get_file(file);
80468 + if (tmp->vm_flags & VM_DENYWRITE)
80469 + atomic_dec(&inode->i_writecount);
80470 + mutex_lock(&mapping->i_mmap_mutex);
80471 + if (tmp->vm_flags & VM_SHARED)
80472 + mapping->i_mmap_writable++;
80473 + flush_dcache_mmap_lock(mapping);
80474 + /* insert tmp into the share list, just after mpnt */
80475 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80476 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80477 + else
80478 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80479 + flush_dcache_mmap_unlock(mapping);
80480 + mutex_unlock(&mapping->i_mmap_mutex);
80481 + }
80482 +
80483 + /*
80484 + * Clear hugetlb-related page reserves for children. This only
80485 + * affects MAP_PRIVATE mappings. Faults generated by the child
80486 + * are not guaranteed to succeed, even if read-only
80487 + */
80488 + if (is_vm_hugetlb_page(tmp))
80489 + reset_vma_resv_huge_pages(tmp);
80490 +
80491 + return tmp;
80492 +
80493 +fail_nomem_anon_vma_fork:
80494 + mpol_put(pol);
80495 +fail_nomem_policy:
80496 + kmem_cache_free(vm_area_cachep, tmp);
80497 +fail_nomem:
80498 + vm_unacct_memory(charge);
80499 + return NULL;
80500 +}
80501 +
80502 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80503 +{
80504 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80505 + struct rb_node **rb_link, *rb_parent;
80506 + int retval;
80507
80508 uprobe_start_dup_mmap();
80509 down_write(&oldmm->mmap_sem);
80510 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80511
80512 prev = NULL;
80513 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80514 - struct file *file;
80515 -
80516 if (mpnt->vm_flags & VM_DONTCOPY) {
80517 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80518 -vma_pages(mpnt));
80519 continue;
80520 }
80521 - charge = 0;
80522 - if (mpnt->vm_flags & VM_ACCOUNT) {
80523 - unsigned long len = vma_pages(mpnt);
80524 -
80525 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80526 - goto fail_nomem;
80527 - charge = len;
80528 - }
80529 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80530 - if (!tmp)
80531 - goto fail_nomem;
80532 - *tmp = *mpnt;
80533 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80534 - pol = mpol_dup(vma_policy(mpnt));
80535 - retval = PTR_ERR(pol);
80536 - if (IS_ERR(pol))
80537 - goto fail_nomem_policy;
80538 - vma_set_policy(tmp, pol);
80539 - tmp->vm_mm = mm;
80540 - if (anon_vma_fork(tmp, mpnt))
80541 - goto fail_nomem_anon_vma_fork;
80542 - tmp->vm_flags &= ~VM_LOCKED;
80543 - tmp->vm_next = tmp->vm_prev = NULL;
80544 - file = tmp->vm_file;
80545 - if (file) {
80546 - struct inode *inode = file_inode(file);
80547 - struct address_space *mapping = file->f_mapping;
80548 -
80549 - get_file(file);
80550 - if (tmp->vm_flags & VM_DENYWRITE)
80551 - atomic_dec(&inode->i_writecount);
80552 - mutex_lock(&mapping->i_mmap_mutex);
80553 - if (tmp->vm_flags & VM_SHARED)
80554 - mapping->i_mmap_writable++;
80555 - flush_dcache_mmap_lock(mapping);
80556 - /* insert tmp into the share list, just after mpnt */
80557 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80558 - vma_nonlinear_insert(tmp,
80559 - &mapping->i_mmap_nonlinear);
80560 - else
80561 - vma_interval_tree_insert_after(tmp, mpnt,
80562 - &mapping->i_mmap);
80563 - flush_dcache_mmap_unlock(mapping);
80564 - mutex_unlock(&mapping->i_mmap_mutex);
80565 + tmp = dup_vma(mm, oldmm, mpnt);
80566 + if (!tmp) {
80567 + retval = -ENOMEM;
80568 + goto out;
80569 }
80570
80571 /*
80572 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80573 if (retval)
80574 goto out;
80575 }
80576 +
80577 +#ifdef CONFIG_PAX_SEGMEXEC
80578 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80579 + struct vm_area_struct *mpnt_m;
80580 +
80581 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80582 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80583 +
80584 + if (!mpnt->vm_mirror)
80585 + continue;
80586 +
80587 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80588 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80589 + mpnt->vm_mirror = mpnt_m;
80590 + } else {
80591 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80592 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80593 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80594 + mpnt->vm_mirror->vm_mirror = mpnt;
80595 + }
80596 + }
80597 + BUG_ON(mpnt_m);
80598 + }
80599 +#endif
80600 +
80601 /* a new mm has just been created */
80602 arch_dup_mmap(oldmm, mm);
80603 retval = 0;
80604 @@ -471,14 +522,6 @@ out:
80605 up_write(&oldmm->mmap_sem);
80606 uprobe_end_dup_mmap();
80607 return retval;
80608 -fail_nomem_anon_vma_fork:
80609 - mpol_put(pol);
80610 -fail_nomem_policy:
80611 - kmem_cache_free(vm_area_cachep, tmp);
80612 -fail_nomem:
80613 - retval = -ENOMEM;
80614 - vm_unacct_memory(charge);
80615 - goto out;
80616 }
80617
80618 static inline int mm_alloc_pgd(struct mm_struct *mm)
80619 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80620 return ERR_PTR(err);
80621
80622 mm = get_task_mm(task);
80623 - if (mm && mm != current->mm &&
80624 - !ptrace_may_access(task, mode)) {
80625 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80626 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80627 mmput(mm);
80628 mm = ERR_PTR(-EACCES);
80629 }
80630 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80631 spin_unlock(&fs->lock);
80632 return -EAGAIN;
80633 }
80634 - fs->users++;
80635 + atomic_inc(&fs->users);
80636 spin_unlock(&fs->lock);
80637 return 0;
80638 }
80639 tsk->fs = copy_fs_struct(fs);
80640 if (!tsk->fs)
80641 return -ENOMEM;
80642 + /* Carry through gr_chroot_dentry and is_chrooted instead
80643 + of recomputing it here. Already copied when the task struct
80644 + is duplicated. This allows pivot_root to not be treated as
80645 + a chroot
80646 + */
80647 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80648 +
80649 return 0;
80650 }
80651
80652 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80653 * parts of the process environment (as per the clone
80654 * flags). The actual kick-off is left to the caller.
80655 */
80656 -static struct task_struct *copy_process(unsigned long clone_flags,
80657 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80658 unsigned long stack_start,
80659 unsigned long stack_size,
80660 int __user *child_tidptr,
80661 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80662 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80663 #endif
80664 retval = -EAGAIN;
80665 +
80666 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80667 +
80668 if (atomic_read(&p->real_cred->user->processes) >=
80669 task_rlimit(p, RLIMIT_NPROC)) {
80670 if (p->real_cred->user != INIT_USER &&
80671 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80672 goto bad_fork_free_pid;
80673 }
80674
80675 + /* synchronizes with gr_set_acls()
80676 + we need to call this past the point of no return for fork()
80677 + */
80678 + gr_copy_label(p);
80679 +
80680 if (likely(p->pid)) {
80681 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80682
80683 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80684 bad_fork_free:
80685 free_task(p);
80686 fork_out:
80687 + gr_log_forkfail(retval);
80688 +
80689 return ERR_PTR(retval);
80690 }
80691
80692 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80693
80694 p = copy_process(clone_flags, stack_start, stack_size,
80695 child_tidptr, NULL, trace);
80696 + add_latent_entropy();
80697 /*
80698 * Do this prior waking up the new thread - the thread pointer
80699 * might get invalid after that point, if the thread exits quickly.
80700 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80701 if (clone_flags & CLONE_PARENT_SETTID)
80702 put_user(nr, parent_tidptr);
80703
80704 + gr_handle_brute_check();
80705 +
80706 if (clone_flags & CLONE_VFORK) {
80707 p->vfork_done = &vfork;
80708 init_completion(&vfork);
80709 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80710 mm_cachep = kmem_cache_create("mm_struct",
80711 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80712 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80713 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80714 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80715 mmap_init();
80716 nsproxy_cache_init();
80717 }
80718 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80719 return 0;
80720
80721 /* don't need lock here; in the worst case we'll do useless copy */
80722 - if (fs->users == 1)
80723 + if (atomic_read(&fs->users) == 1)
80724 return 0;
80725
80726 *new_fsp = copy_fs_struct(fs);
80727 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80728 fs = current->fs;
80729 spin_lock(&fs->lock);
80730 current->fs = new_fs;
80731 - if (--fs->users)
80732 + gr_set_chroot_entries(current, &current->fs->root);
80733 + if (atomic_dec_return(&fs->users))
80734 new_fs = NULL;
80735 else
80736 new_fs = fs;
80737 diff --git a/kernel/futex.c b/kernel/futex.c
80738 index c3a1a55..e32b4a98 100644
80739 --- a/kernel/futex.c
80740 +++ b/kernel/futex.c
80741 @@ -54,6 +54,7 @@
80742 #include <linux/mount.h>
80743 #include <linux/pagemap.h>
80744 #include <linux/syscalls.h>
80745 +#include <linux/ptrace.h>
80746 #include <linux/signal.h>
80747 #include <linux/export.h>
80748 #include <linux/magic.h>
80749 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80750 struct page *page, *page_head;
80751 int err, ro = 0;
80752
80753 +#ifdef CONFIG_PAX_SEGMEXEC
80754 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80755 + return -EFAULT;
80756 +#endif
80757 +
80758 /*
80759 * The futex address must be "naturally" aligned.
80760 */
80761 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80762
80763 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80764 {
80765 - int ret;
80766 + unsigned long ret;
80767
80768 pagefault_disable();
80769 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80770 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80771 {
80772 u32 curval;
80773 int i;
80774 + mm_segment_t oldfs;
80775
80776 /*
80777 * This will fail and we want it. Some arch implementations do
80778 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80779 * implementation, the non-functional ones will return
80780 * -ENOSYS.
80781 */
80782 + oldfs = get_fs();
80783 + set_fs(USER_DS);
80784 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80785 futex_cmpxchg_enabled = 1;
80786 + set_fs(oldfs);
80787
80788 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80789 plist_head_init(&futex_queues[i].chain);
80790 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80791 index f9f44fd..29885e4 100644
80792 --- a/kernel/futex_compat.c
80793 +++ b/kernel/futex_compat.c
80794 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80795 return 0;
80796 }
80797
80798 -static void __user *futex_uaddr(struct robust_list __user *entry,
80799 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80800 compat_long_t futex_offset)
80801 {
80802 compat_uptr_t base = ptr_to_compat(entry);
80803 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80804 index 9b22d03..6295b62 100644
80805 --- a/kernel/gcov/base.c
80806 +++ b/kernel/gcov/base.c
80807 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80808 }
80809
80810 #ifdef CONFIG_MODULES
80811 -static inline int within(void *addr, void *start, unsigned long size)
80812 -{
80813 - return ((addr >= start) && (addr < start + size));
80814 -}
80815 -
80816 /* Update list and generate events when modules are unloaded. */
80817 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80818 void *data)
80819 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80820 prev = NULL;
80821 /* Remove entries located in module from linked list. */
80822 for (info = gcov_info_head; info; info = info->next) {
80823 - if (within(info, mod->module_core, mod->core_size)) {
80824 + if (within_module_core_rw((unsigned long)info, mod)) {
80825 if (prev)
80826 prev->next = info->next;
80827 else
80828 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80829 index 383319b..56ebb13 100644
80830 --- a/kernel/hrtimer.c
80831 +++ b/kernel/hrtimer.c
80832 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80833 local_irq_restore(flags);
80834 }
80835
80836 -static void run_hrtimer_softirq(struct softirq_action *h)
80837 +static __latent_entropy void run_hrtimer_softirq(void)
80838 {
80839 hrtimer_peek_ahead_timers();
80840 }
80841 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80842 index 55fcce6..0e4cf34 100644
80843 --- a/kernel/irq_work.c
80844 +++ b/kernel/irq_work.c
80845 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80846 return NOTIFY_OK;
80847 }
80848
80849 -static struct notifier_block cpu_notify;
80850 +static struct notifier_block cpu_notify = {
80851 + .notifier_call = irq_work_cpu_notify,
80852 + .priority = 0,
80853 +};
80854
80855 static __init int irq_work_init_cpu_notifier(void)
80856 {
80857 - cpu_notify.notifier_call = irq_work_cpu_notify;
80858 - cpu_notify.priority = 0;
80859 register_cpu_notifier(&cpu_notify);
80860 return 0;
80861 }
80862 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80863 index 60f48fa..7f3a770 100644
80864 --- a/kernel/jump_label.c
80865 +++ b/kernel/jump_label.c
80866 @@ -13,6 +13,7 @@
80867 #include <linux/sort.h>
80868 #include <linux/err.h>
80869 #include <linux/static_key.h>
80870 +#include <linux/mm.h>
80871
80872 #ifdef HAVE_JUMP_LABEL
80873
80874 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80875
80876 size = (((unsigned long)stop - (unsigned long)start)
80877 / sizeof(struct jump_entry));
80878 + pax_open_kernel();
80879 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80880 + pax_close_kernel();
80881 }
80882
80883 static void jump_label_update(struct static_key *key, int enable);
80884 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80885 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80886 struct jump_entry *iter;
80887
80888 + pax_open_kernel();
80889 for (iter = iter_start; iter < iter_stop; iter++) {
80890 if (within_module_init(iter->code, mod))
80891 iter->code = 0;
80892 }
80893 + pax_close_kernel();
80894 }
80895
80896 static int
80897 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80898 index 3127ad5..159d880 100644
80899 --- a/kernel/kallsyms.c
80900 +++ b/kernel/kallsyms.c
80901 @@ -11,6 +11,9 @@
80902 * Changed the compression method from stem compression to "table lookup"
80903 * compression (see scripts/kallsyms.c for a more complete description)
80904 */
80905 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80906 +#define __INCLUDED_BY_HIDESYM 1
80907 +#endif
80908 #include <linux/kallsyms.h>
80909 #include <linux/module.h>
80910 #include <linux/init.h>
80911 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80912
80913 static inline int is_kernel_inittext(unsigned long addr)
80914 {
80915 + if (system_state != SYSTEM_BOOTING)
80916 + return 0;
80917 +
80918 if (addr >= (unsigned long)_sinittext
80919 && addr <= (unsigned long)_einittext)
80920 return 1;
80921 return 0;
80922 }
80923
80924 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80925 +#ifdef CONFIG_MODULES
80926 +static inline int is_module_text(unsigned long addr)
80927 +{
80928 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80929 + return 1;
80930 +
80931 + addr = ktla_ktva(addr);
80932 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80933 +}
80934 +#else
80935 +static inline int is_module_text(unsigned long addr)
80936 +{
80937 + return 0;
80938 +}
80939 +#endif
80940 +#endif
80941 +
80942 static inline int is_kernel_text(unsigned long addr)
80943 {
80944 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80945 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80946
80947 static inline int is_kernel(unsigned long addr)
80948 {
80949 +
80950 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80951 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80952 + return 1;
80953 +
80954 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80955 +#else
80956 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80957 +#endif
80958 +
80959 return 1;
80960 return in_gate_area_no_mm(addr);
80961 }
80962
80963 static int is_ksym_addr(unsigned long addr)
80964 {
80965 +
80966 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80967 + if (is_module_text(addr))
80968 + return 0;
80969 +#endif
80970 +
80971 if (all_var)
80972 return is_kernel(addr);
80973
80974 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80975
80976 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80977 {
80978 - iter->name[0] = '\0';
80979 iter->nameoff = get_symbol_offset(new_pos);
80980 iter->pos = new_pos;
80981 }
80982 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80983 {
80984 struct kallsym_iter *iter = m->private;
80985
80986 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80987 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80988 + return 0;
80989 +#endif
80990 +
80991 /* Some debugging symbols have no name. Ignore them. */
80992 if (!iter->name[0])
80993 return 0;
80994 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80995 */
80996 type = iter->exported ? toupper(iter->type) :
80997 tolower(iter->type);
80998 +
80999 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
81000 type, iter->name, iter->module_name);
81001 } else
81002 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
81003 struct kallsym_iter *iter;
81004 int ret;
81005
81006 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81007 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81008 if (!iter)
81009 return -ENOMEM;
81010 reset_iter(iter, 0);
81011 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81012 index e30ac0f..3528cac 100644
81013 --- a/kernel/kcmp.c
81014 +++ b/kernel/kcmp.c
81015 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81016 struct task_struct *task1, *task2;
81017 int ret;
81018
81019 +#ifdef CONFIG_GRKERNSEC
81020 + return -ENOSYS;
81021 +#endif
81022 +
81023 rcu_read_lock();
81024
81025 /*
81026 diff --git a/kernel/kexec.c b/kernel/kexec.c
81027 index 59f7b55..4022f65 100644
81028 --- a/kernel/kexec.c
81029 +++ b/kernel/kexec.c
81030 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81031 unsigned long flags)
81032 {
81033 struct compat_kexec_segment in;
81034 - struct kexec_segment out, __user *ksegments;
81035 + struct kexec_segment out;
81036 + struct kexec_segment __user *ksegments;
81037 unsigned long i, result;
81038
81039 /* Don't allow clients that don't understand the native
81040 diff --git a/kernel/kmod.c b/kernel/kmod.c
81041 index b086006..a27913b 100644
81042 --- a/kernel/kmod.c
81043 +++ b/kernel/kmod.c
81044 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81045 kfree(info->argv);
81046 }
81047
81048 -static int call_modprobe(char *module_name, int wait)
81049 +static int call_modprobe(char *module_name, char *module_param, int wait)
81050 {
81051 struct subprocess_info *info;
81052 static char *envp[] = {
81053 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81054 NULL
81055 };
81056
81057 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81058 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81059 if (!argv)
81060 goto out;
81061
81062 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81063 argv[1] = "-q";
81064 argv[2] = "--";
81065 argv[3] = module_name; /* check free_modprobe_argv() */
81066 - argv[4] = NULL;
81067 + argv[4] = module_param;
81068 + argv[5] = NULL;
81069
81070 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81071 NULL, free_modprobe_argv, NULL);
81072 @@ -129,9 +130,8 @@ out:
81073 * If module auto-loading support is disabled then this function
81074 * becomes a no-operation.
81075 */
81076 -int __request_module(bool wait, const char *fmt, ...)
81077 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81078 {
81079 - va_list args;
81080 char module_name[MODULE_NAME_LEN];
81081 unsigned int max_modprobes;
81082 int ret;
81083 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81084 if (!modprobe_path[0])
81085 return 0;
81086
81087 - va_start(args, fmt);
81088 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81089 - va_end(args);
81090 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81091 if (ret >= MODULE_NAME_LEN)
81092 return -ENAMETOOLONG;
81093
81094 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81095 if (ret)
81096 return ret;
81097
81098 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81099 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81100 + /* hack to workaround consolekit/udisks stupidity */
81101 + read_lock(&tasklist_lock);
81102 + if (!strcmp(current->comm, "mount") &&
81103 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81104 + read_unlock(&tasklist_lock);
81105 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81106 + return -EPERM;
81107 + }
81108 + read_unlock(&tasklist_lock);
81109 + }
81110 +#endif
81111 +
81112 /* If modprobe needs a service that is in a module, we get a recursive
81113 * loop. Limit the number of running kmod threads to max_threads/2 or
81114 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81115 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81116
81117 trace_module_request(module_name, wait, _RET_IP_);
81118
81119 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81120 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81121
81122 atomic_dec(&kmod_concurrent);
81123 return ret;
81124 }
81125 +
81126 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81127 +{
81128 + va_list args;
81129 + int ret;
81130 +
81131 + va_start(args, fmt);
81132 + ret = ____request_module(wait, module_param, fmt, args);
81133 + va_end(args);
81134 +
81135 + return ret;
81136 +}
81137 +
81138 +int __request_module(bool wait, const char *fmt, ...)
81139 +{
81140 + va_list args;
81141 + int ret;
81142 +
81143 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81144 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81145 + char module_param[MODULE_NAME_LEN];
81146 +
81147 + memset(module_param, 0, sizeof(module_param));
81148 +
81149 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81150 +
81151 + va_start(args, fmt);
81152 + ret = ____request_module(wait, module_param, fmt, args);
81153 + va_end(args);
81154 +
81155 + return ret;
81156 + }
81157 +#endif
81158 +
81159 + va_start(args, fmt);
81160 + ret = ____request_module(wait, NULL, fmt, args);
81161 + va_end(args);
81162 +
81163 + return ret;
81164 +}
81165 +
81166 EXPORT_SYMBOL(__request_module);
81167 #endif /* CONFIG_MODULES */
81168
81169 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81170 *
81171 * Thus the __user pointer cast is valid here.
81172 */
81173 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81174 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81175
81176 /*
81177 * If ret is 0, either ____call_usermodehelper failed and the
81178 @@ -650,7 +703,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81179 static int proc_cap_handler(struct ctl_table *table, int write,
81180 void __user *buffer, size_t *lenp, loff_t *ppos)
81181 {
81182 - struct ctl_table t;
81183 + ctl_table_no_const t;
81184 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81185 kernel_cap_t new_cap;
81186 int err, i;
81187 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81188 index 6e33498..3133bd3 100644
81189 --- a/kernel/kprobes.c
81190 +++ b/kernel/kprobes.c
81191 @@ -31,6 +31,9 @@
81192 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81193 * <prasanna@in.ibm.com> added function-return probes.
81194 */
81195 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81196 +#define __INCLUDED_BY_HIDESYM 1
81197 +#endif
81198 #include <linux/kprobes.h>
81199 #include <linux/hash.h>
81200 #include <linux/init.h>
81201 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81202 * kernel image and loaded module images reside. This is required
81203 * so x86_64 can correctly handle the %rip-relative fixups.
81204 */
81205 - kip->insns = module_alloc(PAGE_SIZE);
81206 + kip->insns = module_alloc_exec(PAGE_SIZE);
81207 if (!kip->insns) {
81208 kfree(kip);
81209 return NULL;
81210 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81211 */
81212 if (!list_is_singular(&kip->list)) {
81213 list_del(&kip->list);
81214 - module_free(NULL, kip->insns);
81215 + module_free_exec(NULL, kip->insns);
81216 kfree(kip);
81217 }
81218 return 1;
81219 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81220 {
81221 int i, err = 0;
81222 unsigned long offset = 0, size = 0;
81223 - char *modname, namebuf[128];
81224 + char *modname, namebuf[KSYM_NAME_LEN];
81225 const char *symbol_name;
81226 void *addr;
81227 struct kprobe_blackpoint *kb;
81228 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81229 kprobe_type = "k";
81230
81231 if (sym)
81232 - seq_printf(pi, "%p %s %s+0x%x %s ",
81233 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81234 p->addr, kprobe_type, sym, offset,
81235 (modname ? modname : " "));
81236 else
81237 - seq_printf(pi, "%p %s %p ",
81238 + seq_printf(pi, "%pK %s %pK ",
81239 p->addr, kprobe_type, p->addr);
81240
81241 if (!pp)
81242 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81243 const char *sym = NULL;
81244 unsigned int i = *(loff_t *) v;
81245 unsigned long offset = 0;
81246 - char *modname, namebuf[128];
81247 + char *modname, namebuf[KSYM_NAME_LEN];
81248
81249 head = &kprobe_table[i];
81250 preempt_disable();
81251 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81252 index 6ada93c..dce7d5d 100644
81253 --- a/kernel/ksysfs.c
81254 +++ b/kernel/ksysfs.c
81255 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81256 {
81257 if (count+1 > UEVENT_HELPER_PATH_LEN)
81258 return -ENOENT;
81259 + if (!capable(CAP_SYS_ADMIN))
81260 + return -EPERM;
81261 memcpy(uevent_helper, buf, count);
81262 uevent_helper[count] = '\0';
81263 if (count && uevent_helper[count-1] == '\n')
81264 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81265 return count;
81266 }
81267
81268 -static struct bin_attribute notes_attr = {
81269 +static bin_attribute_no_const notes_attr __read_only = {
81270 .attr = {
81271 .name = "notes",
81272 .mode = S_IRUGO,
81273 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81274 index e16c45b..6f49c48 100644
81275 --- a/kernel/lockdep.c
81276 +++ b/kernel/lockdep.c
81277 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81278 end = (unsigned long) &_end,
81279 addr = (unsigned long) obj;
81280
81281 +#ifdef CONFIG_PAX_KERNEXEC
81282 + start = ktla_ktva(start);
81283 +#endif
81284 +
81285 /*
81286 * static variable?
81287 */
81288 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81289 if (!static_obj(lock->key)) {
81290 debug_locks_off();
81291 printk("INFO: trying to register non-static key.\n");
81292 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81293 printk("the code is fine but needs lockdep annotation.\n");
81294 printk("turning off the locking correctness validator.\n");
81295 dump_stack();
81296 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81297 if (!class)
81298 return 0;
81299 }
81300 - atomic_inc((atomic_t *)&class->ops);
81301 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81302 if (very_verbose(class)) {
81303 printk("\nacquire class [%p] %s", class->key, class->name);
81304 if (class->name_version > 1)
81305 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81306 index b2c71c5..7b88d63 100644
81307 --- a/kernel/lockdep_proc.c
81308 +++ b/kernel/lockdep_proc.c
81309 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81310 return 0;
81311 }
81312
81313 - seq_printf(m, "%p", class->key);
81314 + seq_printf(m, "%pK", class->key);
81315 #ifdef CONFIG_DEBUG_LOCKDEP
81316 seq_printf(m, " OPS:%8ld", class->ops);
81317 #endif
81318 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81319
81320 list_for_each_entry(entry, &class->locks_after, entry) {
81321 if (entry->distance == 1) {
81322 - seq_printf(m, " -> [%p] ", entry->class->key);
81323 + seq_printf(m, " -> [%pK] ", entry->class->key);
81324 print_name(m, entry->class);
81325 seq_puts(m, "\n");
81326 }
81327 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81328 if (!class->key)
81329 continue;
81330
81331 - seq_printf(m, "[%p] ", class->key);
81332 + seq_printf(m, "[%pK] ", class->key);
81333 print_name(m, class);
81334 seq_puts(m, "\n");
81335 }
81336 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81337 if (!i)
81338 seq_line(m, '-', 40-namelen, namelen);
81339
81340 - snprintf(ip, sizeof(ip), "[<%p>]",
81341 + snprintf(ip, sizeof(ip), "[<%pK>]",
81342 (void *)class->contention_point[i]);
81343 seq_printf(m, "%40s %14lu %29s %pS\n",
81344 name, stats->contention_point[i],
81345 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81346 if (!i)
81347 seq_line(m, '-', 40-namelen, namelen);
81348
81349 - snprintf(ip, sizeof(ip), "[<%p>]",
81350 + snprintf(ip, sizeof(ip), "[<%pK>]",
81351 (void *)class->contending_point[i]);
81352 seq_printf(m, "%40s %14lu %29s %pS\n",
81353 name, stats->contending_point[i],
81354 diff --git a/kernel/module.c b/kernel/module.c
81355 index 2069158..71101bb 100644
81356 --- a/kernel/module.c
81357 +++ b/kernel/module.c
81358 @@ -61,6 +61,7 @@
81359 #include <linux/pfn.h>
81360 #include <linux/bsearch.h>
81361 #include <linux/fips.h>
81362 +#include <linux/grsecurity.h>
81363 #include <uapi/linux/module.h>
81364 #include "module-internal.h"
81365
81366 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81367
81368 /* Bounds of module allocation, for speeding __module_address.
81369 * Protected by module_mutex. */
81370 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81371 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81372 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81373
81374 int register_module_notifier(struct notifier_block * nb)
81375 {
81376 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81377 return true;
81378
81379 list_for_each_entry_rcu(mod, &modules, list) {
81380 - struct symsearch arr[] = {
81381 + struct symsearch modarr[] = {
81382 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81383 NOT_GPL_ONLY, false },
81384 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81385 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81386 if (mod->state == MODULE_STATE_UNFORMED)
81387 continue;
81388
81389 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81390 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81391 return true;
81392 }
81393 return false;
81394 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81395 if (!pcpusec->sh_size)
81396 return 0;
81397
81398 - if (align > PAGE_SIZE) {
81399 + if (align-1 >= PAGE_SIZE) {
81400 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81401 mod->name, align, PAGE_SIZE);
81402 align = PAGE_SIZE;
81403 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81404 static ssize_t show_coresize(struct module_attribute *mattr,
81405 struct module_kobject *mk, char *buffer)
81406 {
81407 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81408 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81409 }
81410
81411 static struct module_attribute modinfo_coresize =
81412 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81413 static ssize_t show_initsize(struct module_attribute *mattr,
81414 struct module_kobject *mk, char *buffer)
81415 {
81416 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81417 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81418 }
81419
81420 static struct module_attribute modinfo_initsize =
81421 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81422 */
81423 #ifdef CONFIG_SYSFS
81424
81425 -#ifdef CONFIG_KALLSYMS
81426 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81427 static inline bool sect_empty(const Elf_Shdr *sect)
81428 {
81429 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81430 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81431 {
81432 unsigned int notes, loaded, i;
81433 struct module_notes_attrs *notes_attrs;
81434 - struct bin_attribute *nattr;
81435 + bin_attribute_no_const *nattr;
81436
81437 /* failed to create section attributes, so can't create notes */
81438 if (!mod->sect_attrs)
81439 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81440 static int module_add_modinfo_attrs(struct module *mod)
81441 {
81442 struct module_attribute *attr;
81443 - struct module_attribute *temp_attr;
81444 + module_attribute_no_const *temp_attr;
81445 int error = 0;
81446 int i;
81447
81448 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81449
81450 static void unset_module_core_ro_nx(struct module *mod)
81451 {
81452 - set_page_attributes(mod->module_core + mod->core_text_size,
81453 - mod->module_core + mod->core_size,
81454 + set_page_attributes(mod->module_core_rw,
81455 + mod->module_core_rw + mod->core_size_rw,
81456 set_memory_x);
81457 - set_page_attributes(mod->module_core,
81458 - mod->module_core + mod->core_ro_size,
81459 + set_page_attributes(mod->module_core_rx,
81460 + mod->module_core_rx + mod->core_size_rx,
81461 set_memory_rw);
81462 }
81463
81464 static void unset_module_init_ro_nx(struct module *mod)
81465 {
81466 - set_page_attributes(mod->module_init + mod->init_text_size,
81467 - mod->module_init + mod->init_size,
81468 + set_page_attributes(mod->module_init_rw,
81469 + mod->module_init_rw + mod->init_size_rw,
81470 set_memory_x);
81471 - set_page_attributes(mod->module_init,
81472 - mod->module_init + mod->init_ro_size,
81473 + set_page_attributes(mod->module_init_rx,
81474 + mod->module_init_rx + mod->init_size_rx,
81475 set_memory_rw);
81476 }
81477
81478 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81479 list_for_each_entry_rcu(mod, &modules, list) {
81480 if (mod->state == MODULE_STATE_UNFORMED)
81481 continue;
81482 - if ((mod->module_core) && (mod->core_text_size)) {
81483 - set_page_attributes(mod->module_core,
81484 - mod->module_core + mod->core_text_size,
81485 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81486 + set_page_attributes(mod->module_core_rx,
81487 + mod->module_core_rx + mod->core_size_rx,
81488 set_memory_rw);
81489 }
81490 - if ((mod->module_init) && (mod->init_text_size)) {
81491 - set_page_attributes(mod->module_init,
81492 - mod->module_init + mod->init_text_size,
81493 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81494 + set_page_attributes(mod->module_init_rx,
81495 + mod->module_init_rx + mod->init_size_rx,
81496 set_memory_rw);
81497 }
81498 }
81499 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81500 list_for_each_entry_rcu(mod, &modules, list) {
81501 if (mod->state == MODULE_STATE_UNFORMED)
81502 continue;
81503 - if ((mod->module_core) && (mod->core_text_size)) {
81504 - set_page_attributes(mod->module_core,
81505 - mod->module_core + mod->core_text_size,
81506 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81507 + set_page_attributes(mod->module_core_rx,
81508 + mod->module_core_rx + mod->core_size_rx,
81509 set_memory_ro);
81510 }
81511 - if ((mod->module_init) && (mod->init_text_size)) {
81512 - set_page_attributes(mod->module_init,
81513 - mod->module_init + mod->init_text_size,
81514 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81515 + set_page_attributes(mod->module_init_rx,
81516 + mod->module_init_rx + mod->init_size_rx,
81517 set_memory_ro);
81518 }
81519 }
81520 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81521
81522 /* This may be NULL, but that's OK */
81523 unset_module_init_ro_nx(mod);
81524 - module_free(mod, mod->module_init);
81525 + module_free(mod, mod->module_init_rw);
81526 + module_free_exec(mod, mod->module_init_rx);
81527 kfree(mod->args);
81528 percpu_modfree(mod);
81529
81530 /* Free lock-classes: */
81531 - lockdep_free_key_range(mod->module_core, mod->core_size);
81532 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81533 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81534
81535 /* Finally, free the core (containing the module structure) */
81536 unset_module_core_ro_nx(mod);
81537 - module_free(mod, mod->module_core);
81538 + module_free_exec(mod, mod->module_core_rx);
81539 + module_free(mod, mod->module_core_rw);
81540
81541 #ifdef CONFIG_MPU
81542 update_protections(current->mm);
81543 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81544 int ret = 0;
81545 const struct kernel_symbol *ksym;
81546
81547 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81548 + int is_fs_load = 0;
81549 + int register_filesystem_found = 0;
81550 + char *p;
81551 +
81552 + p = strstr(mod->args, "grsec_modharden_fs");
81553 + if (p) {
81554 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81555 + /* copy \0 as well */
81556 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81557 + is_fs_load = 1;
81558 + }
81559 +#endif
81560 +
81561 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81562 const char *name = info->strtab + sym[i].st_name;
81563
81564 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81565 + /* it's a real shame this will never get ripped and copied
81566 + upstream! ;(
81567 + */
81568 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81569 + register_filesystem_found = 1;
81570 +#endif
81571 +
81572 switch (sym[i].st_shndx) {
81573 case SHN_COMMON:
81574 /* We compiled with -fno-common. These are not
81575 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81576 ksym = resolve_symbol_wait(mod, info, name);
81577 /* Ok if resolved. */
81578 if (ksym && !IS_ERR(ksym)) {
81579 + pax_open_kernel();
81580 sym[i].st_value = ksym->value;
81581 + pax_close_kernel();
81582 break;
81583 }
81584
81585 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81586 secbase = (unsigned long)mod_percpu(mod);
81587 else
81588 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81589 + pax_open_kernel();
81590 sym[i].st_value += secbase;
81591 + pax_close_kernel();
81592 break;
81593 }
81594 }
81595
81596 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81597 + if (is_fs_load && !register_filesystem_found) {
81598 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81599 + ret = -EPERM;
81600 + }
81601 +#endif
81602 +
81603 return ret;
81604 }
81605
81606 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81607 || s->sh_entsize != ~0UL
81608 || strstarts(sname, ".init"))
81609 continue;
81610 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81611 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81612 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81613 + else
81614 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81615 pr_debug("\t%s\n", sname);
81616 }
81617 - switch (m) {
81618 - case 0: /* executable */
81619 - mod->core_size = debug_align(mod->core_size);
81620 - mod->core_text_size = mod->core_size;
81621 - break;
81622 - case 1: /* RO: text and ro-data */
81623 - mod->core_size = debug_align(mod->core_size);
81624 - mod->core_ro_size = mod->core_size;
81625 - break;
81626 - case 3: /* whole core */
81627 - mod->core_size = debug_align(mod->core_size);
81628 - break;
81629 - }
81630 }
81631
81632 pr_debug("Init section allocation order:\n");
81633 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81634 || s->sh_entsize != ~0UL
81635 || !strstarts(sname, ".init"))
81636 continue;
81637 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81638 - | INIT_OFFSET_MASK);
81639 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81640 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81641 + else
81642 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81643 + s->sh_entsize |= INIT_OFFSET_MASK;
81644 pr_debug("\t%s\n", sname);
81645 }
81646 - switch (m) {
81647 - case 0: /* executable */
81648 - mod->init_size = debug_align(mod->init_size);
81649 - mod->init_text_size = mod->init_size;
81650 - break;
81651 - case 1: /* RO: text and ro-data */
81652 - mod->init_size = debug_align(mod->init_size);
81653 - mod->init_ro_size = mod->init_size;
81654 - break;
81655 - case 3: /* whole init */
81656 - mod->init_size = debug_align(mod->init_size);
81657 - break;
81658 - }
81659 }
81660 }
81661
81662 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81663
81664 /* Put symbol section at end of init part of module. */
81665 symsect->sh_flags |= SHF_ALLOC;
81666 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81667 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81668 info->index.sym) | INIT_OFFSET_MASK;
81669 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81670
81671 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81672 }
81673
81674 /* Append room for core symbols at end of core part. */
81675 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81676 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81677 - mod->core_size += strtab_size;
81678 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81679 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81680 + mod->core_size_rx += strtab_size;
81681
81682 /* Put string table section at end of init part of module. */
81683 strsect->sh_flags |= SHF_ALLOC;
81684 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81685 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81686 info->index.str) | INIT_OFFSET_MASK;
81687 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81688 }
81689 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81690 /* Make sure we get permanent strtab: don't use info->strtab. */
81691 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81692
81693 + pax_open_kernel();
81694 +
81695 /* Set types up while we still have access to sections. */
81696 for (i = 0; i < mod->num_symtab; i++)
81697 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81698
81699 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81700 - mod->core_strtab = s = mod->module_core + info->stroffs;
81701 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81702 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81703 src = mod->symtab;
81704 for (ndst = i = 0; i < mod->num_symtab; i++) {
81705 if (i == 0 ||
81706 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81707 }
81708 }
81709 mod->core_num_syms = ndst;
81710 +
81711 + pax_close_kernel();
81712 }
81713 #else
81714 static inline void layout_symtab(struct module *mod, struct load_info *info)
81715 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81716 return vmalloc_exec(size);
81717 }
81718
81719 -static void *module_alloc_update_bounds(unsigned long size)
81720 +static void *module_alloc_update_bounds_rw(unsigned long size)
81721 {
81722 void *ret = module_alloc(size);
81723
81724 if (ret) {
81725 mutex_lock(&module_mutex);
81726 /* Update module bounds. */
81727 - if ((unsigned long)ret < module_addr_min)
81728 - module_addr_min = (unsigned long)ret;
81729 - if ((unsigned long)ret + size > module_addr_max)
81730 - module_addr_max = (unsigned long)ret + size;
81731 + if ((unsigned long)ret < module_addr_min_rw)
81732 + module_addr_min_rw = (unsigned long)ret;
81733 + if ((unsigned long)ret + size > module_addr_max_rw)
81734 + module_addr_max_rw = (unsigned long)ret + size;
81735 + mutex_unlock(&module_mutex);
81736 + }
81737 + return ret;
81738 +}
81739 +
81740 +static void *module_alloc_update_bounds_rx(unsigned long size)
81741 +{
81742 + void *ret = module_alloc_exec(size);
81743 +
81744 + if (ret) {
81745 + mutex_lock(&module_mutex);
81746 + /* Update module bounds. */
81747 + if ((unsigned long)ret < module_addr_min_rx)
81748 + module_addr_min_rx = (unsigned long)ret;
81749 + if ((unsigned long)ret + size > module_addr_max_rx)
81750 + module_addr_max_rx = (unsigned long)ret + size;
81751 mutex_unlock(&module_mutex);
81752 }
81753 return ret;
81754 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81755 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81756 {
81757 const char *modmagic = get_modinfo(info, "vermagic");
81758 + const char *license = get_modinfo(info, "license");
81759 int err;
81760
81761 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81762 + if (!license || !license_is_gpl_compatible(license))
81763 + return -ENOEXEC;
81764 +#endif
81765 +
81766 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81767 modmagic = NULL;
81768
81769 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81770 }
81771
81772 /* Set up license info based on the info section */
81773 - set_license(mod, get_modinfo(info, "license"));
81774 + set_license(mod, license);
81775
81776 return 0;
81777 }
81778 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81779 void *ptr;
81780
81781 /* Do the allocs. */
81782 - ptr = module_alloc_update_bounds(mod->core_size);
81783 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81784 /*
81785 * The pointer to this block is stored in the module structure
81786 * which is inside the block. Just mark it as not being a
81787 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81788 if (!ptr)
81789 return -ENOMEM;
81790
81791 - memset(ptr, 0, mod->core_size);
81792 - mod->module_core = ptr;
81793 + memset(ptr, 0, mod->core_size_rw);
81794 + mod->module_core_rw = ptr;
81795
81796 - if (mod->init_size) {
81797 - ptr = module_alloc_update_bounds(mod->init_size);
81798 + if (mod->init_size_rw) {
81799 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81800 /*
81801 * The pointer to this block is stored in the module structure
81802 * which is inside the block. This block doesn't need to be
81803 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81804 */
81805 kmemleak_ignore(ptr);
81806 if (!ptr) {
81807 - module_free(mod, mod->module_core);
81808 + module_free(mod, mod->module_core_rw);
81809 return -ENOMEM;
81810 }
81811 - memset(ptr, 0, mod->init_size);
81812 - mod->module_init = ptr;
81813 + memset(ptr, 0, mod->init_size_rw);
81814 + mod->module_init_rw = ptr;
81815 } else
81816 - mod->module_init = NULL;
81817 + mod->module_init_rw = NULL;
81818 +
81819 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81820 + kmemleak_not_leak(ptr);
81821 + if (!ptr) {
81822 + if (mod->module_init_rw)
81823 + module_free(mod, mod->module_init_rw);
81824 + module_free(mod, mod->module_core_rw);
81825 + return -ENOMEM;
81826 + }
81827 +
81828 + pax_open_kernel();
81829 + memset(ptr, 0, mod->core_size_rx);
81830 + pax_close_kernel();
81831 + mod->module_core_rx = ptr;
81832 +
81833 + if (mod->init_size_rx) {
81834 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81835 + kmemleak_ignore(ptr);
81836 + if (!ptr && mod->init_size_rx) {
81837 + module_free_exec(mod, mod->module_core_rx);
81838 + if (mod->module_init_rw)
81839 + module_free(mod, mod->module_init_rw);
81840 + module_free(mod, mod->module_core_rw);
81841 + return -ENOMEM;
81842 + }
81843 +
81844 + pax_open_kernel();
81845 + memset(ptr, 0, mod->init_size_rx);
81846 + pax_close_kernel();
81847 + mod->module_init_rx = ptr;
81848 + } else
81849 + mod->module_init_rx = NULL;
81850
81851 /* Transfer each section which specifies SHF_ALLOC */
81852 pr_debug("final section addresses:\n");
81853 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81854 if (!(shdr->sh_flags & SHF_ALLOC))
81855 continue;
81856
81857 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81858 - dest = mod->module_init
81859 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81860 - else
81861 - dest = mod->module_core + shdr->sh_entsize;
81862 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81863 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81864 + dest = mod->module_init_rw
81865 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81866 + else
81867 + dest = mod->module_init_rx
81868 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81869 + } else {
81870 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81871 + dest = mod->module_core_rw + shdr->sh_entsize;
81872 + else
81873 + dest = mod->module_core_rx + shdr->sh_entsize;
81874 + }
81875 +
81876 + if (shdr->sh_type != SHT_NOBITS) {
81877 +
81878 +#ifdef CONFIG_PAX_KERNEXEC
81879 +#ifdef CONFIG_X86_64
81880 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81881 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81882 +#endif
81883 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81884 + pax_open_kernel();
81885 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81886 + pax_close_kernel();
81887 + } else
81888 +#endif
81889
81890 - if (shdr->sh_type != SHT_NOBITS)
81891 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81892 + }
81893 /* Update sh_addr to point to copy in image. */
81894 - shdr->sh_addr = (unsigned long)dest;
81895 +
81896 +#ifdef CONFIG_PAX_KERNEXEC
81897 + if (shdr->sh_flags & SHF_EXECINSTR)
81898 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81899 + else
81900 +#endif
81901 +
81902 + shdr->sh_addr = (unsigned long)dest;
81903 pr_debug("\t0x%lx %s\n",
81904 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81905 }
81906 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81907 * Do it before processing of module parameters, so the module
81908 * can provide parameter accessor functions of its own.
81909 */
81910 - if (mod->module_init)
81911 - flush_icache_range((unsigned long)mod->module_init,
81912 - (unsigned long)mod->module_init
81913 - + mod->init_size);
81914 - flush_icache_range((unsigned long)mod->module_core,
81915 - (unsigned long)mod->module_core + mod->core_size);
81916 + if (mod->module_init_rx)
81917 + flush_icache_range((unsigned long)mod->module_init_rx,
81918 + (unsigned long)mod->module_init_rx
81919 + + mod->init_size_rx);
81920 + flush_icache_range((unsigned long)mod->module_core_rx,
81921 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81922
81923 set_fs(old_fs);
81924 }
81925 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81926 static void module_deallocate(struct module *mod, struct load_info *info)
81927 {
81928 percpu_modfree(mod);
81929 - module_free(mod, mod->module_init);
81930 - module_free(mod, mod->module_core);
81931 + module_free_exec(mod, mod->module_init_rx);
81932 + module_free_exec(mod, mod->module_core_rx);
81933 + module_free(mod, mod->module_init_rw);
81934 + module_free(mod, mod->module_core_rw);
81935 }
81936
81937 int __weak module_finalize(const Elf_Ehdr *hdr,
81938 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81939 static int post_relocation(struct module *mod, const struct load_info *info)
81940 {
81941 /* Sort exception table now relocations are done. */
81942 + pax_open_kernel();
81943 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81944 + pax_close_kernel();
81945
81946 /* Copy relocated percpu area over. */
81947 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81948 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81949 MODULE_STATE_COMING, mod);
81950
81951 /* Set RO and NX regions for core */
81952 - set_section_ro_nx(mod->module_core,
81953 - mod->core_text_size,
81954 - mod->core_ro_size,
81955 - mod->core_size);
81956 + set_section_ro_nx(mod->module_core_rx,
81957 + mod->core_size_rx,
81958 + mod->core_size_rx,
81959 + mod->core_size_rx);
81960
81961 /* Set RO and NX regions for init */
81962 - set_section_ro_nx(mod->module_init,
81963 - mod->init_text_size,
81964 - mod->init_ro_size,
81965 - mod->init_size);
81966 + set_section_ro_nx(mod->module_init_rx,
81967 + mod->init_size_rx,
81968 + mod->init_size_rx,
81969 + mod->init_size_rx);
81970
81971 do_mod_ctors(mod);
81972 /* Start the module */
81973 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81974 mod->strtab = mod->core_strtab;
81975 #endif
81976 unset_module_init_ro_nx(mod);
81977 - module_free(mod, mod->module_init);
81978 - mod->module_init = NULL;
81979 - mod->init_size = 0;
81980 - mod->init_ro_size = 0;
81981 - mod->init_text_size = 0;
81982 + module_free(mod, mod->module_init_rw);
81983 + module_free_exec(mod, mod->module_init_rx);
81984 + mod->module_init_rw = NULL;
81985 + mod->module_init_rx = NULL;
81986 + mod->init_size_rw = 0;
81987 + mod->init_size_rx = 0;
81988 mutex_unlock(&module_mutex);
81989 wake_up_all(&module_wq);
81990
81991 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81992 if (err)
81993 goto free_unload;
81994
81995 + /* Now copy in args */
81996 + mod->args = strndup_user(uargs, ~0UL >> 1);
81997 + if (IS_ERR(mod->args)) {
81998 + err = PTR_ERR(mod->args);
81999 + goto free_unload;
82000 + }
82001 +
82002 /* Set up MODINFO_ATTR fields */
82003 setup_modinfo(mod, info);
82004
82005 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82006 + {
82007 + char *p, *p2;
82008 +
82009 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82010 + 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);
82011 + err = -EPERM;
82012 + goto free_modinfo;
82013 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82014 + p += sizeof("grsec_modharden_normal") - 1;
82015 + p2 = strstr(p, "_");
82016 + if (p2) {
82017 + *p2 = '\0';
82018 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82019 + *p2 = '_';
82020 + }
82021 + err = -EPERM;
82022 + goto free_modinfo;
82023 + }
82024 + }
82025 +#endif
82026 +
82027 /* Fix up syms, so that st_value is a pointer to location. */
82028 err = simplify_symbols(mod, info);
82029 if (err < 0)
82030 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82031
82032 flush_module_icache(mod);
82033
82034 - /* Now copy in args */
82035 - mod->args = strndup_user(uargs, ~0UL >> 1);
82036 - if (IS_ERR(mod->args)) {
82037 - err = PTR_ERR(mod->args);
82038 - goto free_arch_cleanup;
82039 - }
82040 -
82041 dynamic_debug_setup(info->debug, info->num_debug);
82042
82043 /* Finally it's fully formed, ready to start executing. */
82044 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
82045 ddebug_cleanup:
82046 dynamic_debug_remove(info->debug);
82047 synchronize_sched();
82048 - kfree(mod->args);
82049 - free_arch_cleanup:
82050 module_arch_cleanup(mod);
82051 free_modinfo:
82052 free_modinfo(mod);
82053 + kfree(mod->args);
82054 free_unload:
82055 module_unload_free(mod);
82056 unlink_mod:
82057 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
82058 unsigned long nextval;
82059
82060 /* At worse, next value is at end of module */
82061 - if (within_module_init(addr, mod))
82062 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
82063 + if (within_module_init_rx(addr, mod))
82064 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
82065 + else if (within_module_init_rw(addr, mod))
82066 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
82067 + else if (within_module_core_rx(addr, mod))
82068 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
82069 + else if (within_module_core_rw(addr, mod))
82070 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
82071 else
82072 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
82073 + return NULL;
82074
82075 /* Scan for closest preceding symbol, and next symbol. (ELF
82076 starts real symbols at 1). */
82077 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82078 return 0;
82079
82080 seq_printf(m, "%s %u",
82081 - mod->name, mod->init_size + mod->core_size);
82082 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82083 print_unload_info(m, mod);
82084
82085 /* Informative for users. */
82086 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82087 mod->state == MODULE_STATE_COMING ? "Loading":
82088 "Live");
82089 /* Used by oprofile and other similar tools. */
82090 - seq_printf(m, " 0x%pK", mod->module_core);
82091 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82092
82093 /* Taints info */
82094 if (mod->taints)
82095 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82096
82097 static int __init proc_modules_init(void)
82098 {
82099 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82100 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82101 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82102 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82103 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82104 +#else
82105 proc_create("modules", 0, NULL, &proc_modules_operations);
82106 +#endif
82107 +#else
82108 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82109 +#endif
82110 return 0;
82111 }
82112 module_init(proc_modules_init);
82113 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82114 {
82115 struct module *mod;
82116
82117 - if (addr < module_addr_min || addr > module_addr_max)
82118 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82119 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82120 return NULL;
82121
82122 list_for_each_entry_rcu(mod, &modules, list) {
82123 if (mod->state == MODULE_STATE_UNFORMED)
82124 continue;
82125 - if (within_module_core(addr, mod)
82126 - || within_module_init(addr, mod))
82127 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82128 return mod;
82129 }
82130 return NULL;
82131 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82132 */
82133 struct module *__module_text_address(unsigned long addr)
82134 {
82135 - struct module *mod = __module_address(addr);
82136 + struct module *mod;
82137 +
82138 +#ifdef CONFIG_X86_32
82139 + addr = ktla_ktva(addr);
82140 +#endif
82141 +
82142 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82143 + return NULL;
82144 +
82145 + mod = __module_address(addr);
82146 +
82147 if (mod) {
82148 /* Make sure it's within the text section. */
82149 - if (!within(addr, mod->module_init, mod->init_text_size)
82150 - && !within(addr, mod->module_core, mod->core_text_size))
82151 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82152 mod = NULL;
82153 }
82154 return mod;
82155 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82156 index 7e3443f..b2a1e6b 100644
82157 --- a/kernel/mutex-debug.c
82158 +++ b/kernel/mutex-debug.c
82159 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82160 }
82161
82162 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82163 - struct thread_info *ti)
82164 + struct task_struct *task)
82165 {
82166 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82167
82168 /* Mark the current thread as blocked on the lock: */
82169 - ti->task->blocked_on = waiter;
82170 + task->blocked_on = waiter;
82171 }
82172
82173 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82174 - struct thread_info *ti)
82175 + struct task_struct *task)
82176 {
82177 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82178 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82179 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82180 - ti->task->blocked_on = NULL;
82181 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82182 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82183 + task->blocked_on = NULL;
82184
82185 list_del_init(&waiter->list);
82186 waiter->task = NULL;
82187 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82188 index 0799fd3..d06ae3b 100644
82189 --- a/kernel/mutex-debug.h
82190 +++ b/kernel/mutex-debug.h
82191 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82192 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82193 extern void debug_mutex_add_waiter(struct mutex *lock,
82194 struct mutex_waiter *waiter,
82195 - struct thread_info *ti);
82196 + struct task_struct *task);
82197 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82198 - struct thread_info *ti);
82199 + struct task_struct *task);
82200 extern void debug_mutex_unlock(struct mutex *lock);
82201 extern void debug_mutex_init(struct mutex *lock, const char *name,
82202 struct lock_class_key *key);
82203 diff --git a/kernel/mutex.c b/kernel/mutex.c
82204 index a52ee7bb..f361f16 100644
82205 --- a/kernel/mutex.c
82206 +++ b/kernel/mutex.c
82207 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82208 node->locked = 1;
82209 return;
82210 }
82211 - ACCESS_ONCE(prev->next) = node;
82212 + ACCESS_ONCE_RW(prev->next) = node;
82213 smp_wmb();
82214 /* Wait until the lock holder passes the lock down */
82215 while (!ACCESS_ONCE(node->locked))
82216 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82217 while (!(next = ACCESS_ONCE(node->next)))
82218 arch_mutex_cpu_relax();
82219 }
82220 - ACCESS_ONCE(next->locked) = 1;
82221 + ACCESS_ONCE_RW(next->locked) = 1;
82222 smp_wmb();
82223 }
82224
82225 @@ -514,7 +514,7 @@ slowpath:
82226 spin_lock_mutex(&lock->wait_lock, flags);
82227
82228 debug_mutex_lock_common(lock, &waiter);
82229 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82230 + debug_mutex_add_waiter(lock, &waiter, task);
82231
82232 /* add waiting tasks to the end of the waitqueue (FIFO): */
82233 list_add_tail(&waiter.list, &lock->wait_list);
82234 @@ -565,7 +565,7 @@ slowpath:
82235 done:
82236 lock_acquired(&lock->dep_map, ip);
82237 /* got the lock - rejoice! */
82238 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82239 + mutex_remove_waiter(lock, &waiter, task);
82240 mutex_set_owner(lock);
82241
82242 if (!__builtin_constant_p(ww_ctx == NULL)) {
82243 @@ -604,7 +604,7 @@ done:
82244 return 0;
82245
82246 err:
82247 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82248 + mutex_remove_waiter(lock, &waiter, task);
82249 spin_unlock_mutex(&lock->wait_lock, flags);
82250 debug_mutex_free_waiter(&waiter);
82251 mutex_release(&lock->dep_map, 1, ip);
82252 diff --git a/kernel/notifier.c b/kernel/notifier.c
82253 index 2d5cc4c..d9ea600 100644
82254 --- a/kernel/notifier.c
82255 +++ b/kernel/notifier.c
82256 @@ -5,6 +5,7 @@
82257 #include <linux/rcupdate.h>
82258 #include <linux/vmalloc.h>
82259 #include <linux/reboot.h>
82260 +#include <linux/mm.h>
82261
82262 /*
82263 * Notifier list for kernel code which wants to be called
82264 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82265 while ((*nl) != NULL) {
82266 if (n->priority > (*nl)->priority)
82267 break;
82268 - nl = &((*nl)->next);
82269 + nl = (struct notifier_block **)&((*nl)->next);
82270 }
82271 - n->next = *nl;
82272 + pax_open_kernel();
82273 + *(const void **)&n->next = *nl;
82274 rcu_assign_pointer(*nl, n);
82275 + pax_close_kernel();
82276 return 0;
82277 }
82278
82279 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82280 return 0;
82281 if (n->priority > (*nl)->priority)
82282 break;
82283 - nl = &((*nl)->next);
82284 + nl = (struct notifier_block **)&((*nl)->next);
82285 }
82286 - n->next = *nl;
82287 + pax_open_kernel();
82288 + *(const void **)&n->next = *nl;
82289 rcu_assign_pointer(*nl, n);
82290 + pax_close_kernel();
82291 return 0;
82292 }
82293
82294 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82295 {
82296 while ((*nl) != NULL) {
82297 if ((*nl) == n) {
82298 + pax_open_kernel();
82299 rcu_assign_pointer(*nl, n->next);
82300 + pax_close_kernel();
82301 return 0;
82302 }
82303 - nl = &((*nl)->next);
82304 + nl = (struct notifier_block **)&((*nl)->next);
82305 }
82306 return -ENOENT;
82307 }
82308 diff --git a/kernel/panic.c b/kernel/panic.c
82309 index 8018646..b6a5b4f 100644
82310 --- a/kernel/panic.c
82311 +++ b/kernel/panic.c
82312 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82313 disable_trace_on_warning();
82314
82315 pr_warn("------------[ cut here ]------------\n");
82316 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82317 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82318 raw_smp_processor_id(), current->pid, file, line, caller);
82319
82320 if (args)
82321 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82322 */
82323 void __stack_chk_fail(void)
82324 {
82325 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82326 + dump_stack();
82327 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82328 __builtin_return_address(0));
82329 }
82330 EXPORT_SYMBOL(__stack_chk_fail);
82331 diff --git a/kernel/pid.c b/kernel/pid.c
82332 index ebe5e80..5d6d634 100644
82333 --- a/kernel/pid.c
82334 +++ b/kernel/pid.c
82335 @@ -33,6 +33,7 @@
82336 #include <linux/rculist.h>
82337 #include <linux/bootmem.h>
82338 #include <linux/hash.h>
82339 +#include <linux/security.h>
82340 #include <linux/pid_namespace.h>
82341 #include <linux/init_task.h>
82342 #include <linux/syscalls.h>
82343 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82344
82345 int pid_max = PID_MAX_DEFAULT;
82346
82347 -#define RESERVED_PIDS 300
82348 +#define RESERVED_PIDS 500
82349
82350 int pid_max_min = RESERVED_PIDS + 1;
82351 int pid_max_max = PID_MAX_LIMIT;
82352 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82353 */
82354 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82355 {
82356 + struct task_struct *task;
82357 +
82358 rcu_lockdep_assert(rcu_read_lock_held(),
82359 "find_task_by_pid_ns() needs rcu_read_lock()"
82360 " protection");
82361 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82362 +
82363 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82364 +
82365 + if (gr_pid_is_chrooted(task))
82366 + return NULL;
82367 +
82368 + return task;
82369 }
82370
82371 struct task_struct *find_task_by_vpid(pid_t vnr)
82372 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82373 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82374 }
82375
82376 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82377 +{
82378 + rcu_lockdep_assert(rcu_read_lock_held(),
82379 + "find_task_by_pid_ns() needs rcu_read_lock()"
82380 + " protection");
82381 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82382 +}
82383 +
82384 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82385 {
82386 struct pid *pid;
82387 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82388 index 601bb36..f7e6f34 100644
82389 --- a/kernel/pid_namespace.c
82390 +++ b/kernel/pid_namespace.c
82391 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82392 void __user *buffer, size_t *lenp, loff_t *ppos)
82393 {
82394 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82395 - struct ctl_table tmp = *table;
82396 + ctl_table_no_const tmp = *table;
82397
82398 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82399 return -EPERM;
82400 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82401 index c7f31aa..2b44977 100644
82402 --- a/kernel/posix-cpu-timers.c
82403 +++ b/kernel/posix-cpu-timers.c
82404 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82405
82406 static __init int init_posix_cpu_timers(void)
82407 {
82408 - struct k_clock process = {
82409 + static struct k_clock process = {
82410 .clock_getres = process_cpu_clock_getres,
82411 .clock_get = process_cpu_clock_get,
82412 .timer_create = process_cpu_timer_create,
82413 .nsleep = process_cpu_nsleep,
82414 .nsleep_restart = process_cpu_nsleep_restart,
82415 };
82416 - struct k_clock thread = {
82417 + static struct k_clock thread = {
82418 .clock_getres = thread_cpu_clock_getres,
82419 .clock_get = thread_cpu_clock_get,
82420 .timer_create = thread_cpu_timer_create,
82421 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82422 index 424c2d4..679242f 100644
82423 --- a/kernel/posix-timers.c
82424 +++ b/kernel/posix-timers.c
82425 @@ -43,6 +43,7 @@
82426 #include <linux/hash.h>
82427 #include <linux/posix-clock.h>
82428 #include <linux/posix-timers.h>
82429 +#include <linux/grsecurity.h>
82430 #include <linux/syscalls.h>
82431 #include <linux/wait.h>
82432 #include <linux/workqueue.h>
82433 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82434 * which we beg off on and pass to do_sys_settimeofday().
82435 */
82436
82437 -static struct k_clock posix_clocks[MAX_CLOCKS];
82438 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82439
82440 /*
82441 * These ones are defined below.
82442 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82443 */
82444 static __init int init_posix_timers(void)
82445 {
82446 - struct k_clock clock_realtime = {
82447 + static struct k_clock clock_realtime = {
82448 .clock_getres = hrtimer_get_res,
82449 .clock_get = posix_clock_realtime_get,
82450 .clock_set = posix_clock_realtime_set,
82451 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82452 .timer_get = common_timer_get,
82453 .timer_del = common_timer_del,
82454 };
82455 - struct k_clock clock_monotonic = {
82456 + static struct k_clock clock_monotonic = {
82457 .clock_getres = hrtimer_get_res,
82458 .clock_get = posix_ktime_get_ts,
82459 .nsleep = common_nsleep,
82460 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82461 .timer_get = common_timer_get,
82462 .timer_del = common_timer_del,
82463 };
82464 - struct k_clock clock_monotonic_raw = {
82465 + static struct k_clock clock_monotonic_raw = {
82466 .clock_getres = hrtimer_get_res,
82467 .clock_get = posix_get_monotonic_raw,
82468 };
82469 - struct k_clock clock_realtime_coarse = {
82470 + static struct k_clock clock_realtime_coarse = {
82471 .clock_getres = posix_get_coarse_res,
82472 .clock_get = posix_get_realtime_coarse,
82473 };
82474 - struct k_clock clock_monotonic_coarse = {
82475 + static struct k_clock clock_monotonic_coarse = {
82476 .clock_getres = posix_get_coarse_res,
82477 .clock_get = posix_get_monotonic_coarse,
82478 };
82479 - struct k_clock clock_tai = {
82480 + static struct k_clock clock_tai = {
82481 .clock_getres = hrtimer_get_res,
82482 .clock_get = posix_get_tai,
82483 .nsleep = common_nsleep,
82484 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82485 .timer_get = common_timer_get,
82486 .timer_del = common_timer_del,
82487 };
82488 - struct k_clock clock_boottime = {
82489 + static struct k_clock clock_boottime = {
82490 .clock_getres = hrtimer_get_res,
82491 .clock_get = posix_get_boottime,
82492 .nsleep = common_nsleep,
82493 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82494 return;
82495 }
82496
82497 - posix_clocks[clock_id] = *new_clock;
82498 + posix_clocks[clock_id] = new_clock;
82499 }
82500 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82501
82502 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82503 return (id & CLOCKFD_MASK) == CLOCKFD ?
82504 &clock_posix_dynamic : &clock_posix_cpu;
82505
82506 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82507 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82508 return NULL;
82509 - return &posix_clocks[id];
82510 + return posix_clocks[id];
82511 }
82512
82513 static int common_timer_create(struct k_itimer *new_timer)
82514 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82515 struct k_clock *kc = clockid_to_kclock(which_clock);
82516 struct k_itimer *new_timer;
82517 int error, new_timer_id;
82518 - sigevent_t event;
82519 + sigevent_t event = { };
82520 int it_id_set = IT_ID_NOT_SET;
82521
82522 if (!kc)
82523 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82524 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82525 return -EFAULT;
82526
82527 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82528 + have their clock_set fptr set to a nosettime dummy function
82529 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82530 + call common_clock_set, which calls do_sys_settimeofday, which
82531 + we hook
82532 + */
82533 +
82534 return kc->clock_set(which_clock, &new_tp);
82535 }
82536
82537 diff --git a/kernel/power/process.c b/kernel/power/process.c
82538 index 06ec886..9dba35e 100644
82539 --- a/kernel/power/process.c
82540 +++ b/kernel/power/process.c
82541 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82542 unsigned int elapsed_msecs;
82543 bool wakeup = false;
82544 int sleep_usecs = USEC_PER_MSEC;
82545 + bool timedout = false;
82546
82547 do_gettimeofday(&start);
82548
82549 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82550
82551 while (true) {
82552 todo = 0;
82553 + if (time_after(jiffies, end_time))
82554 + timedout = true;
82555 read_lock(&tasklist_lock);
82556 do_each_thread(g, p) {
82557 if (p == current || !freeze_task(p))
82558 continue;
82559
82560 - if (!freezer_should_skip(p))
82561 + if (!freezer_should_skip(p)) {
82562 todo++;
82563 + if (timedout) {
82564 + printk(KERN_ERR "Task refusing to freeze:\n");
82565 + sched_show_task(p);
82566 + }
82567 + }
82568 } while_each_thread(g, p);
82569 read_unlock(&tasklist_lock);
82570
82571 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82572 todo += wq_busy;
82573 }
82574
82575 - if (!todo || time_after(jiffies, end_time))
82576 + if (!todo || timedout)
82577 break;
82578
82579 if (pm_wakeup_pending()) {
82580 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82581 index 5b5a708..ec7637e 100644
82582 --- a/kernel/printk/printk.c
82583 +++ b/kernel/printk/printk.c
82584 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82585 if (from_file && type != SYSLOG_ACTION_OPEN)
82586 return 0;
82587
82588 +#ifdef CONFIG_GRKERNSEC_DMESG
82589 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82590 + return -EPERM;
82591 +#endif
82592 +
82593 if (syslog_action_restricted(type)) {
82594 if (capable(CAP_SYSLOG))
82595 return 0;
82596 diff --git a/kernel/profile.c b/kernel/profile.c
82597 index 6631e1e..310c266 100644
82598 --- a/kernel/profile.c
82599 +++ b/kernel/profile.c
82600 @@ -37,7 +37,7 @@ struct profile_hit {
82601 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82602 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82603
82604 -static atomic_t *prof_buffer;
82605 +static atomic_unchecked_t *prof_buffer;
82606 static unsigned long prof_len, prof_shift;
82607
82608 int prof_on __read_mostly;
82609 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82610 hits[i].pc = 0;
82611 continue;
82612 }
82613 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82614 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82615 hits[i].hits = hits[i].pc = 0;
82616 }
82617 }
82618 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82619 * Add the current hit(s) and flush the write-queue out
82620 * to the global buffer:
82621 */
82622 - atomic_add(nr_hits, &prof_buffer[pc]);
82623 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82624 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82625 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82626 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82627 hits[i].pc = hits[i].hits = 0;
82628 }
82629 out:
82630 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82631 {
82632 unsigned long pc;
82633 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82634 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82635 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82636 }
82637 #endif /* !CONFIG_SMP */
82638
82639 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82640 return -EFAULT;
82641 buf++; p++; count--; read++;
82642 }
82643 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82644 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82645 if (copy_to_user(buf, (void *)pnt, count))
82646 return -EFAULT;
82647 read += count;
82648 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82649 }
82650 #endif
82651 profile_discard_flip_buffers();
82652 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82653 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82654 return count;
82655 }
82656
82657 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82658 index a146ee3..ffed4c3 100644
82659 --- a/kernel/ptrace.c
82660 +++ b/kernel/ptrace.c
82661 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82662 if (seize)
82663 flags |= PT_SEIZED;
82664 rcu_read_lock();
82665 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82666 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82667 flags |= PT_PTRACE_CAP;
82668 rcu_read_unlock();
82669 task->ptrace = flags;
82670 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82671 break;
82672 return -EIO;
82673 }
82674 - if (copy_to_user(dst, buf, retval))
82675 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82676 return -EFAULT;
82677 copied += retval;
82678 src += retval;
82679 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82680 bool seized = child->ptrace & PT_SEIZED;
82681 int ret = -EIO;
82682 siginfo_t siginfo, *si;
82683 - void __user *datavp = (void __user *) data;
82684 + void __user *datavp = (__force void __user *) data;
82685 unsigned long __user *datalp = datavp;
82686 unsigned long flags;
82687
82688 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82689 goto out;
82690 }
82691
82692 + if (gr_handle_ptrace(child, request)) {
82693 + ret = -EPERM;
82694 + goto out_put_task_struct;
82695 + }
82696 +
82697 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82698 ret = ptrace_attach(child, request, addr, data);
82699 /*
82700 * Some architectures need to do book-keeping after
82701 * a ptrace attach.
82702 */
82703 - if (!ret)
82704 + if (!ret) {
82705 arch_ptrace_attach(child);
82706 + gr_audit_ptrace(child);
82707 + }
82708 goto out_put_task_struct;
82709 }
82710
82711 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82712 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82713 if (copied != sizeof(tmp))
82714 return -EIO;
82715 - return put_user(tmp, (unsigned long __user *)data);
82716 + return put_user(tmp, (__force unsigned long __user *)data);
82717 }
82718
82719 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82720 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82721 }
82722
82723 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82724 - compat_long_t addr, compat_long_t data)
82725 + compat_ulong_t addr, compat_ulong_t data)
82726 {
82727 struct task_struct *child;
82728 long ret;
82729 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82730 goto out;
82731 }
82732
82733 + if (gr_handle_ptrace(child, request)) {
82734 + ret = -EPERM;
82735 + goto out_put_task_struct;
82736 + }
82737 +
82738 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82739 ret = ptrace_attach(child, request, addr, data);
82740 /*
82741 * Some architectures need to do book-keeping after
82742 * a ptrace attach.
82743 */
82744 - if (!ret)
82745 + if (!ret) {
82746 arch_ptrace_attach(child);
82747 + gr_audit_ptrace(child);
82748 + }
82749 goto out_put_task_struct;
82750 }
82751
82752 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82753 index cce6ba8..7c758b1f 100644
82754 --- a/kernel/rcupdate.c
82755 +++ b/kernel/rcupdate.c
82756 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82757 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82758 */
82759 if (till_stall_check < 3) {
82760 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82761 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82762 till_stall_check = 3;
82763 } else if (till_stall_check > 300) {
82764 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82765 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82766 till_stall_check = 300;
82767 }
82768 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82769 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82770 index aa34411..4832cd4 100644
82771 --- a/kernel/rcutiny.c
82772 +++ b/kernel/rcutiny.c
82773 @@ -45,7 +45,7 @@
82774 /* Forward declarations for rcutiny_plugin.h. */
82775 struct rcu_ctrlblk;
82776 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82777 -static void rcu_process_callbacks(struct softirq_action *unused);
82778 +static void rcu_process_callbacks(void);
82779 static void __call_rcu(struct rcu_head *head,
82780 void (*func)(struct rcu_head *rcu),
82781 struct rcu_ctrlblk *rcp);
82782 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82783 false));
82784 }
82785
82786 -static void rcu_process_callbacks(struct softirq_action *unused)
82787 +static __latent_entropy void rcu_process_callbacks(void)
82788 {
82789 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82790 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82791 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82792 index f4871e5..8ef5741 100644
82793 --- a/kernel/rcutorture.c
82794 +++ b/kernel/rcutorture.c
82795 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82796 { 0 };
82797 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82798 { 0 };
82799 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82800 -static atomic_t n_rcu_torture_alloc;
82801 -static atomic_t n_rcu_torture_alloc_fail;
82802 -static atomic_t n_rcu_torture_free;
82803 -static atomic_t n_rcu_torture_mberror;
82804 -static atomic_t n_rcu_torture_error;
82805 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82806 +static atomic_unchecked_t n_rcu_torture_alloc;
82807 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82808 +static atomic_unchecked_t n_rcu_torture_free;
82809 +static atomic_unchecked_t n_rcu_torture_mberror;
82810 +static atomic_unchecked_t n_rcu_torture_error;
82811 static long n_rcu_torture_barrier_error;
82812 static long n_rcu_torture_boost_ktrerror;
82813 static long n_rcu_torture_boost_rterror;
82814 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82815
82816 spin_lock_bh(&rcu_torture_lock);
82817 if (list_empty(&rcu_torture_freelist)) {
82818 - atomic_inc(&n_rcu_torture_alloc_fail);
82819 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82820 spin_unlock_bh(&rcu_torture_lock);
82821 return NULL;
82822 }
82823 - atomic_inc(&n_rcu_torture_alloc);
82824 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82825 p = rcu_torture_freelist.next;
82826 list_del_init(p);
82827 spin_unlock_bh(&rcu_torture_lock);
82828 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82829 static void
82830 rcu_torture_free(struct rcu_torture *p)
82831 {
82832 - atomic_inc(&n_rcu_torture_free);
82833 + atomic_inc_unchecked(&n_rcu_torture_free);
82834 spin_lock_bh(&rcu_torture_lock);
82835 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82836 spin_unlock_bh(&rcu_torture_lock);
82837 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82838 i = rp->rtort_pipe_count;
82839 if (i > RCU_TORTURE_PIPE_LEN)
82840 i = RCU_TORTURE_PIPE_LEN;
82841 - atomic_inc(&rcu_torture_wcount[i]);
82842 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82843 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82844 rp->rtort_mbtest = 0;
82845 rcu_torture_free(rp);
82846 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82847 i = rp->rtort_pipe_count;
82848 if (i > RCU_TORTURE_PIPE_LEN)
82849 i = RCU_TORTURE_PIPE_LEN;
82850 - atomic_inc(&rcu_torture_wcount[i]);
82851 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82852 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82853 rp->rtort_mbtest = 0;
82854 list_del(&rp->rtort_free);
82855 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82856 i = old_rp->rtort_pipe_count;
82857 if (i > RCU_TORTURE_PIPE_LEN)
82858 i = RCU_TORTURE_PIPE_LEN;
82859 - atomic_inc(&rcu_torture_wcount[i]);
82860 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82861 old_rp->rtort_pipe_count++;
82862 cur_ops->deferred_free(old_rp);
82863 }
82864 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82865 return;
82866 }
82867 if (p->rtort_mbtest == 0)
82868 - atomic_inc(&n_rcu_torture_mberror);
82869 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82870 spin_lock(&rand_lock);
82871 cur_ops->read_delay(&rand);
82872 n_rcu_torture_timers++;
82873 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82874 continue;
82875 }
82876 if (p->rtort_mbtest == 0)
82877 - atomic_inc(&n_rcu_torture_mberror);
82878 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82879 cur_ops->read_delay(&rand);
82880 preempt_disable();
82881 pipe_count = p->rtort_pipe_count;
82882 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82883 rcu_torture_current,
82884 rcu_torture_current_version,
82885 list_empty(&rcu_torture_freelist),
82886 - atomic_read(&n_rcu_torture_alloc),
82887 - atomic_read(&n_rcu_torture_alloc_fail),
82888 - atomic_read(&n_rcu_torture_free));
82889 + atomic_read_unchecked(&n_rcu_torture_alloc),
82890 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82891 + atomic_read_unchecked(&n_rcu_torture_free));
82892 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82893 - atomic_read(&n_rcu_torture_mberror),
82894 + atomic_read_unchecked(&n_rcu_torture_mberror),
82895 n_rcu_torture_boost_ktrerror,
82896 n_rcu_torture_boost_rterror);
82897 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82898 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82899 n_barrier_attempts,
82900 n_rcu_torture_barrier_error);
82901 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82902 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82903 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82904 n_rcu_torture_barrier_error != 0 ||
82905 n_rcu_torture_boost_ktrerror != 0 ||
82906 n_rcu_torture_boost_rterror != 0 ||
82907 n_rcu_torture_boost_failure != 0 ||
82908 i > 1) {
82909 cnt += sprintf(&page[cnt], "!!! ");
82910 - atomic_inc(&n_rcu_torture_error);
82911 + atomic_inc_unchecked(&n_rcu_torture_error);
82912 WARN_ON_ONCE(1);
82913 }
82914 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82915 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82916 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82917 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82918 cnt += sprintf(&page[cnt], " %d",
82919 - atomic_read(&rcu_torture_wcount[i]));
82920 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82921 }
82922 cnt += sprintf(&page[cnt], "\n");
82923 if (cur_ops->stats)
82924 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82925
82926 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82927
82928 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82929 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82930 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82931 else if (n_online_successes != n_online_attempts ||
82932 n_offline_successes != n_offline_attempts)
82933 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82934
82935 rcu_torture_current = NULL;
82936 rcu_torture_current_version = 0;
82937 - atomic_set(&n_rcu_torture_alloc, 0);
82938 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82939 - atomic_set(&n_rcu_torture_free, 0);
82940 - atomic_set(&n_rcu_torture_mberror, 0);
82941 - atomic_set(&n_rcu_torture_error, 0);
82942 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82943 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82944 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82945 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82946 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82947 n_rcu_torture_barrier_error = 0;
82948 n_rcu_torture_boost_ktrerror = 0;
82949 n_rcu_torture_boost_rterror = 0;
82950 n_rcu_torture_boost_failure = 0;
82951 n_rcu_torture_boosts = 0;
82952 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82953 - atomic_set(&rcu_torture_wcount[i], 0);
82954 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82955 for_each_possible_cpu(cpu) {
82956 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82957 per_cpu(rcu_torture_count, cpu)[i] = 0;
82958 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82959 index 068de3a..5e7db2f 100644
82960 --- a/kernel/rcutree.c
82961 +++ b/kernel/rcutree.c
82962 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82963 rcu_prepare_for_idle(smp_processor_id());
82964 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82965 smp_mb__before_atomic_inc(); /* See above. */
82966 - atomic_inc(&rdtp->dynticks);
82967 + atomic_inc_unchecked(&rdtp->dynticks);
82968 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82969 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82970 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82971
82972 /*
82973 * It is illegal to enter an extended quiescent state while
82974 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82975 int user)
82976 {
82977 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82978 - atomic_inc(&rdtp->dynticks);
82979 + atomic_inc_unchecked(&rdtp->dynticks);
82980 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82981 smp_mb__after_atomic_inc(); /* See above. */
82982 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82983 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82984 rcu_cleanup_after_idle(smp_processor_id());
82985 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82986 if (!user && !is_idle_task(current)) {
82987 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82988 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82989
82990 if (rdtp->dynticks_nmi_nesting == 0 &&
82991 - (atomic_read(&rdtp->dynticks) & 0x1))
82992 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82993 return;
82994 rdtp->dynticks_nmi_nesting++;
82995 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82996 - atomic_inc(&rdtp->dynticks);
82997 + atomic_inc_unchecked(&rdtp->dynticks);
82998 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82999 smp_mb__after_atomic_inc(); /* See above. */
83000 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83001 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83002 }
83003
83004 /**
83005 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
83006 return;
83007 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83008 smp_mb__before_atomic_inc(); /* See above. */
83009 - atomic_inc(&rdtp->dynticks);
83010 + atomic_inc_unchecked(&rdtp->dynticks);
83011 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83012 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83013 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83014 }
83015
83016 /**
83017 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
83018 int ret;
83019
83020 preempt_disable();
83021 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83022 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83023 preempt_enable();
83024 return ret;
83025 }
83026 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83027 */
83028 static int dyntick_save_progress_counter(struct rcu_data *rdp)
83029 {
83030 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83031 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83032 return (rdp->dynticks_snap & 0x1) == 0;
83033 }
83034
83035 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
83036 unsigned int curr;
83037 unsigned int snap;
83038
83039 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83040 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83041 snap = (unsigned int)rdp->dynticks_snap;
83042
83043 /*
83044 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
83045 rdp = this_cpu_ptr(rsp->rda);
83046 rcu_preempt_check_blocked_tasks(rnp);
83047 rnp->qsmask = rnp->qsmaskinit;
83048 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
83049 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
83050 WARN_ON_ONCE(rnp->completed != rsp->completed);
83051 - ACCESS_ONCE(rnp->completed) = rsp->completed;
83052 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
83053 if (rnp == rdp->mynode)
83054 __note_gp_changes(rsp, rnp, rdp);
83055 rcu_preempt_boost_start_gp(rnp);
83056 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
83057 */
83058 rcu_for_each_node_breadth_first(rsp, rnp) {
83059 raw_spin_lock_irq(&rnp->lock);
83060 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
83061 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
83062 rdp = this_cpu_ptr(rsp->rda);
83063 if (rnp == rdp->mynode)
83064 __note_gp_changes(rsp, rnp, rdp);
83065 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
83066 rsp->qlen += rdp->qlen;
83067 rdp->n_cbs_orphaned += rdp->qlen;
83068 rdp->qlen_lazy = 0;
83069 - ACCESS_ONCE(rdp->qlen) = 0;
83070 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83071 }
83072
83073 /*
83074 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83075 }
83076 smp_mb(); /* List handling before counting for rcu_barrier(). */
83077 rdp->qlen_lazy -= count_lazy;
83078 - ACCESS_ONCE(rdp->qlen) -= count;
83079 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83080 rdp->n_cbs_invoked += count;
83081
83082 /* Reinstate batch limit if we have worked down the excess. */
83083 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83084 /*
83085 * Do RCU core processing for the current CPU.
83086 */
83087 -static void rcu_process_callbacks(struct softirq_action *unused)
83088 +static __latent_entropy void rcu_process_callbacks(void)
83089 {
83090 struct rcu_state *rsp;
83091
83092 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83093 local_irq_restore(flags);
83094 return;
83095 }
83096 - ACCESS_ONCE(rdp->qlen)++;
83097 + ACCESS_ONCE_RW(rdp->qlen)++;
83098 if (lazy)
83099 rdp->qlen_lazy++;
83100 else
83101 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83102 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83103 * course be required on a 64-bit system.
83104 */
83105 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83106 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83107 (ulong)atomic_long_read(&rsp->expedited_done) +
83108 ULONG_MAX / 8)) {
83109 synchronize_sched();
83110 - atomic_long_inc(&rsp->expedited_wrap);
83111 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83112 return;
83113 }
83114
83115 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83116 * Take a ticket. Note that atomic_inc_return() implies a
83117 * full memory barrier.
83118 */
83119 - snap = atomic_long_inc_return(&rsp->expedited_start);
83120 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83121 firstsnap = snap;
83122 get_online_cpus();
83123 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83124 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83125 synchronize_sched_expedited_cpu_stop,
83126 NULL) == -EAGAIN) {
83127 put_online_cpus();
83128 - atomic_long_inc(&rsp->expedited_tryfail);
83129 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83130
83131 /* Check to see if someone else did our work for us. */
83132 s = atomic_long_read(&rsp->expedited_done);
83133 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83134 /* ensure test happens before caller kfree */
83135 smp_mb__before_atomic_inc(); /* ^^^ */
83136 - atomic_long_inc(&rsp->expedited_workdone1);
83137 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83138 return;
83139 }
83140
83141 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83142 udelay(trycount * num_online_cpus());
83143 } else {
83144 wait_rcu_gp(call_rcu_sched);
83145 - atomic_long_inc(&rsp->expedited_normal);
83146 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83147 return;
83148 }
83149
83150 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83151 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83152 /* ensure test happens before caller kfree */
83153 smp_mb__before_atomic_inc(); /* ^^^ */
83154 - atomic_long_inc(&rsp->expedited_workdone2);
83155 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83156 return;
83157 }
83158
83159 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83160 * period works for us.
83161 */
83162 get_online_cpus();
83163 - snap = atomic_long_read(&rsp->expedited_start);
83164 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83165 smp_mb(); /* ensure read is before try_stop_cpus(). */
83166 }
83167 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83168 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83169
83170 /*
83171 * Everyone up to our most recent fetch is covered by our grace
83172 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83173 * than we did already did their update.
83174 */
83175 do {
83176 - atomic_long_inc(&rsp->expedited_done_tries);
83177 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83178 s = atomic_long_read(&rsp->expedited_done);
83179 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83180 /* ensure test happens before caller kfree */
83181 smp_mb__before_atomic_inc(); /* ^^^ */
83182 - atomic_long_inc(&rsp->expedited_done_lost);
83183 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83184 break;
83185 }
83186 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83187 - atomic_long_inc(&rsp->expedited_done_exit);
83188 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83189
83190 put_online_cpus();
83191 }
83192 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83193 * ACCESS_ONCE() to prevent the compiler from speculating
83194 * the increment to precede the early-exit check.
83195 */
83196 - ACCESS_ONCE(rsp->n_barrier_done)++;
83197 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83198 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83199 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83200 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83201 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83202
83203 /* Increment ->n_barrier_done to prevent duplicate work. */
83204 smp_mb(); /* Keep increment after above mechanism. */
83205 - ACCESS_ONCE(rsp->n_barrier_done)++;
83206 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83207 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83208 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83209 smp_mb(); /* Keep increment before caller's subsequent code. */
83210 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83211 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83212 init_callback_list(rdp);
83213 rdp->qlen_lazy = 0;
83214 - ACCESS_ONCE(rdp->qlen) = 0;
83215 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83216 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83217 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83218 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83219 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83220 rdp->cpu = cpu;
83221 rdp->rsp = rsp;
83222 rcu_boot_init_nocb_percpu_data(rdp);
83223 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83224 rdp->blimit = blimit;
83225 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83226 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83227 - atomic_set(&rdp->dynticks->dynticks,
83228 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83229 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83230 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83231 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83232
83233 /* Add CPU to rcu_node bitmasks. */
83234 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83235 index b383258..2440c1e 100644
83236 --- a/kernel/rcutree.h
83237 +++ b/kernel/rcutree.h
83238 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83239 long long dynticks_nesting; /* Track irq/process nesting level. */
83240 /* Process level is worth LLONG_MAX/2. */
83241 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83242 - atomic_t dynticks; /* Even value for idle, else odd. */
83243 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83244 #ifdef CONFIG_RCU_FAST_NO_HZ
83245 bool all_lazy; /* Are all CPU's CBs lazy? */
83246 unsigned long nonlazy_posted;
83247 @@ -419,17 +419,17 @@ struct rcu_state {
83248 /* _rcu_barrier(). */
83249 /* End of fields guarded by barrier_mutex. */
83250
83251 - atomic_long_t expedited_start; /* Starting ticket. */
83252 - atomic_long_t expedited_done; /* Done ticket. */
83253 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83254 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83255 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83256 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83257 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83258 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83259 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83260 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83261 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83262 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83263 + atomic_long_t expedited_done; /* Done ticket. */
83264 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83265 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83266 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83267 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83268 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83269 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83270 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83271 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83272 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83273
83274 unsigned long jiffies_force_qs; /* Time at which to invoke */
83275 /* force_quiescent_state(). */
83276 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83277 index 769e12e..7b2139b 100644
83278 --- a/kernel/rcutree_plugin.h
83279 +++ b/kernel/rcutree_plugin.h
83280 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83281
83282 /* Clean up and exit. */
83283 smp_mb(); /* ensure expedited GP seen before counter increment. */
83284 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83285 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83286 unlock_mb_ret:
83287 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83288 mb_ret:
83289 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83290 free_cpumask_var(cm);
83291 }
83292
83293 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83294 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83295 .store = &rcu_cpu_kthread_task,
83296 .thread_should_run = rcu_cpu_kthread_should_run,
83297 .thread_fn = rcu_cpu_kthread,
83298 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83299 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83300 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83301 cpu, ticks_value, ticks_title,
83302 - atomic_read(&rdtp->dynticks) & 0xfff,
83303 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83304 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83305 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83306 fast_no_hz);
83307 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83308
83309 /* Enqueue the callback on the nocb list and update counts. */
83310 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83311 - ACCESS_ONCE(*old_rhpp) = rhp;
83312 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83313 atomic_long_add(rhcount, &rdp->nocb_q_count);
83314 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83315
83316 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83317 * Extract queued callbacks, update counts, and wait
83318 * for a grace period to elapse.
83319 */
83320 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83321 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83322 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83323 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83324 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83325 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83326 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83327 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83328 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83329 rcu_nocb_wait_gp(rdp);
83330
83331 /* Each pass through the following loop invokes a callback. */
83332 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83333 list = next;
83334 }
83335 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83336 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83337 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83338 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83339 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83340 rdp->n_nocbs_invoked += c;
83341 }
83342 return 0;
83343 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83344 t = kthread_run(rcu_nocb_kthread, rdp,
83345 "rcuo%c/%d", rsp->abbr, cpu);
83346 BUG_ON(IS_ERR(t));
83347 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83348 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83349 }
83350 }
83351
83352 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83353 index cf6c174..a8f4b50 100644
83354 --- a/kernel/rcutree_trace.c
83355 +++ b/kernel/rcutree_trace.c
83356 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83357 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83358 rdp->passed_quiesce, rdp->qs_pending);
83359 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83360 - atomic_read(&rdp->dynticks->dynticks),
83361 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83362 rdp->dynticks->dynticks_nesting,
83363 rdp->dynticks->dynticks_nmi_nesting,
83364 rdp->dynticks_fqs);
83365 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83366 struct rcu_state *rsp = (struct rcu_state *)m->private;
83367
83368 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",
83369 - atomic_long_read(&rsp->expedited_start),
83370 + atomic_long_read_unchecked(&rsp->expedited_start),
83371 atomic_long_read(&rsp->expedited_done),
83372 - atomic_long_read(&rsp->expedited_wrap),
83373 - atomic_long_read(&rsp->expedited_tryfail),
83374 - atomic_long_read(&rsp->expedited_workdone1),
83375 - atomic_long_read(&rsp->expedited_workdone2),
83376 - atomic_long_read(&rsp->expedited_normal),
83377 - atomic_long_read(&rsp->expedited_stoppedcpus),
83378 - atomic_long_read(&rsp->expedited_done_tries),
83379 - atomic_long_read(&rsp->expedited_done_lost),
83380 - atomic_long_read(&rsp->expedited_done_exit));
83381 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83382 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83383 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83384 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83385 + atomic_long_read_unchecked(&rsp->expedited_normal),
83386 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83387 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83388 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83389 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83390 return 0;
83391 }
83392
83393 diff --git a/kernel/resource.c b/kernel/resource.c
83394 index 3f285dc..5755f62 100644
83395 --- a/kernel/resource.c
83396 +++ b/kernel/resource.c
83397 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83398
83399 static int __init ioresources_init(void)
83400 {
83401 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83402 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83403 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83404 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83405 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83406 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83407 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83408 +#endif
83409 +#else
83410 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83411 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83412 +#endif
83413 return 0;
83414 }
83415 __initcall(ioresources_init);
83416 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83417 index 1d96dd0..994ff19 100644
83418 --- a/kernel/rtmutex-tester.c
83419 +++ b/kernel/rtmutex-tester.c
83420 @@ -22,7 +22,7 @@
83421 #define MAX_RT_TEST_MUTEXES 8
83422
83423 static spinlock_t rttest_lock;
83424 -static atomic_t rttest_event;
83425 +static atomic_unchecked_t rttest_event;
83426
83427 struct test_thread_data {
83428 int opcode;
83429 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83430
83431 case RTTEST_LOCKCONT:
83432 td->mutexes[td->opdata] = 1;
83433 - td->event = atomic_add_return(1, &rttest_event);
83434 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83435 return 0;
83436
83437 case RTTEST_RESET:
83438 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83439 return 0;
83440
83441 case RTTEST_RESETEVENT:
83442 - atomic_set(&rttest_event, 0);
83443 + atomic_set_unchecked(&rttest_event, 0);
83444 return 0;
83445
83446 default:
83447 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83448 return ret;
83449
83450 td->mutexes[id] = 1;
83451 - td->event = atomic_add_return(1, &rttest_event);
83452 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83453 rt_mutex_lock(&mutexes[id]);
83454 - td->event = atomic_add_return(1, &rttest_event);
83455 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83456 td->mutexes[id] = 4;
83457 return 0;
83458
83459 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83460 return ret;
83461
83462 td->mutexes[id] = 1;
83463 - td->event = atomic_add_return(1, &rttest_event);
83464 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83465 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83466 - td->event = atomic_add_return(1, &rttest_event);
83467 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83468 td->mutexes[id] = ret ? 0 : 4;
83469 return ret ? -EINTR : 0;
83470
83471 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83472 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83473 return ret;
83474
83475 - td->event = atomic_add_return(1, &rttest_event);
83476 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83477 rt_mutex_unlock(&mutexes[id]);
83478 - td->event = atomic_add_return(1, &rttest_event);
83479 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83480 td->mutexes[id] = 0;
83481 return 0;
83482
83483 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83484 break;
83485
83486 td->mutexes[dat] = 2;
83487 - td->event = atomic_add_return(1, &rttest_event);
83488 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83489 break;
83490
83491 default:
83492 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83493 return;
83494
83495 td->mutexes[dat] = 3;
83496 - td->event = atomic_add_return(1, &rttest_event);
83497 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83498 break;
83499
83500 case RTTEST_LOCKNOWAIT:
83501 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83502 return;
83503
83504 td->mutexes[dat] = 1;
83505 - td->event = atomic_add_return(1, &rttest_event);
83506 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83507 return;
83508
83509 default:
83510 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83511 index 4a07353..66b5291 100644
83512 --- a/kernel/sched/auto_group.c
83513 +++ b/kernel/sched/auto_group.c
83514 @@ -11,7 +11,7 @@
83515
83516 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83517 static struct autogroup autogroup_default;
83518 -static atomic_t autogroup_seq_nr;
83519 +static atomic_unchecked_t autogroup_seq_nr;
83520
83521 void __init autogroup_init(struct task_struct *init_task)
83522 {
83523 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83524
83525 kref_init(&ag->kref);
83526 init_rwsem(&ag->lock);
83527 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83528 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83529 ag->tg = tg;
83530 #ifdef CONFIG_RT_GROUP_SCHED
83531 /*
83532 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83533 index 05c39f0..442e6fe 100644
83534 --- a/kernel/sched/core.c
83535 +++ b/kernel/sched/core.c
83536 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83537 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83538 * or number of jiffies left till timeout) if completed.
83539 */
83540 -long __sched
83541 +long __sched __intentional_overflow(-1)
83542 wait_for_completion_interruptible_timeout(struct completion *x,
83543 unsigned long timeout)
83544 {
83545 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83546 *
83547 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83548 */
83549 -int __sched wait_for_completion_killable(struct completion *x)
83550 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83551 {
83552 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83553 if (t == -ERESTARTSYS)
83554 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83555 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83556 * or number of jiffies left till timeout) if completed.
83557 */
83558 -long __sched
83559 +long __sched __intentional_overflow(-1)
83560 wait_for_completion_killable_timeout(struct completion *x,
83561 unsigned long timeout)
83562 {
83563 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83564 /* convert nice value [19,-20] to rlimit style value [1,40] */
83565 int nice_rlim = 20 - nice;
83566
83567 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83568 +
83569 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83570 capable(CAP_SYS_NICE));
83571 }
83572 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83573 if (nice > 19)
83574 nice = 19;
83575
83576 - if (increment < 0 && !can_nice(current, nice))
83577 + if (increment < 0 && (!can_nice(current, nice) ||
83578 + gr_handle_chroot_nice()))
83579 return -EPERM;
83580
83581 retval = security_task_setnice(current, nice);
83582 @@ -3344,6 +3347,7 @@ recheck:
83583 unsigned long rlim_rtprio =
83584 task_rlimit(p, RLIMIT_RTPRIO);
83585
83586 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83587 /* can't set/change the rt policy */
83588 if (policy != p->policy && !rlim_rtprio)
83589 return -EPERM;
83590 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83591
83592 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83593
83594 -static struct ctl_table sd_ctl_dir[] = {
83595 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83596 {
83597 .procname = "sched_domain",
83598 .mode = 0555,
83599 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83600 {}
83601 };
83602
83603 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83604 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83605 {
83606 - struct ctl_table *entry =
83607 + ctl_table_no_const *entry =
83608 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83609
83610 return entry;
83611 }
83612
83613 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83614 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83615 {
83616 - struct ctl_table *entry;
83617 + ctl_table_no_const *entry;
83618
83619 /*
83620 * In the intermediate directories, both the child directory and
83621 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83622 * will always be set. In the lowest directory the names are
83623 * static strings and all have proc handlers.
83624 */
83625 - for (entry = *tablep; entry->mode; entry++) {
83626 - if (entry->child)
83627 - sd_free_ctl_entry(&entry->child);
83628 + for (entry = tablep; entry->mode; entry++) {
83629 + if (entry->child) {
83630 + sd_free_ctl_entry(entry->child);
83631 + pax_open_kernel();
83632 + entry->child = NULL;
83633 + pax_close_kernel();
83634 + }
83635 if (entry->proc_handler == NULL)
83636 kfree(entry->procname);
83637 }
83638
83639 - kfree(*tablep);
83640 - *tablep = NULL;
83641 + kfree(tablep);
83642 }
83643
83644 static int min_load_idx = 0;
83645 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83646
83647 static void
83648 -set_table_entry(struct ctl_table *entry,
83649 +set_table_entry(ctl_table_no_const *entry,
83650 const char *procname, void *data, int maxlen,
83651 umode_t mode, proc_handler *proc_handler,
83652 bool load_idx)
83653 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83654 static struct ctl_table *
83655 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83656 {
83657 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83658 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83659
83660 if (table == NULL)
83661 return NULL;
83662 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83663 return table;
83664 }
83665
83666 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83667 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83668 {
83669 - struct ctl_table *entry, *table;
83670 + ctl_table_no_const *entry, *table;
83671 struct sched_domain *sd;
83672 int domain_num = 0, i;
83673 char buf[32];
83674 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83675 static void register_sched_domain_sysctl(void)
83676 {
83677 int i, cpu_num = num_possible_cpus();
83678 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83679 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83680 char buf[32];
83681
83682 WARN_ON(sd_ctl_dir[0].child);
83683 + pax_open_kernel();
83684 sd_ctl_dir[0].child = entry;
83685 + pax_close_kernel();
83686
83687 if (entry == NULL)
83688 return;
83689 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83690 if (sd_sysctl_header)
83691 unregister_sysctl_table(sd_sysctl_header);
83692 sd_sysctl_header = NULL;
83693 - if (sd_ctl_dir[0].child)
83694 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83695 + if (sd_ctl_dir[0].child) {
83696 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83697 + pax_open_kernel();
83698 + sd_ctl_dir[0].child = NULL;
83699 + pax_close_kernel();
83700 + }
83701 }
83702 #else
83703 static void register_sched_domain_sysctl(void)
83704 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83705 index 31cbc15..ba68c15 100644
83706 --- a/kernel/sched/fair.c
83707 +++ b/kernel/sched/fair.c
83708 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83709
83710 static void reset_ptenuma_scan(struct task_struct *p)
83711 {
83712 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83713 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83714 p->mm->numa_scan_offset = 0;
83715 }
83716
83717 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83718 * run_rebalance_domains is triggered when needed from the scheduler tick.
83719 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83720 */
83721 -static void run_rebalance_domains(struct softirq_action *h)
83722 +static __latent_entropy void run_rebalance_domains(void)
83723 {
83724 int this_cpu = smp_processor_id();
83725 struct rq *this_rq = cpu_rq(this_cpu);
83726 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83727 index ef0a7b2..1b728c1 100644
83728 --- a/kernel/sched/sched.h
83729 +++ b/kernel/sched/sched.h
83730 @@ -1004,7 +1004,7 @@ struct sched_class {
83731 #ifdef CONFIG_FAIR_GROUP_SCHED
83732 void (*task_move_group) (struct task_struct *p, int on_rq);
83733 #endif
83734 -};
83735 +} __do_const;
83736
83737 #define sched_class_highest (&stop_sched_class)
83738 #define for_each_class(class) \
83739 diff --git a/kernel/signal.c b/kernel/signal.c
83740 index 50e4107..9409983 100644
83741 --- a/kernel/signal.c
83742 +++ b/kernel/signal.c
83743 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83744
83745 int print_fatal_signals __read_mostly;
83746
83747 -static void __user *sig_handler(struct task_struct *t, int sig)
83748 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83749 {
83750 return t->sighand->action[sig - 1].sa.sa_handler;
83751 }
83752
83753 -static int sig_handler_ignored(void __user *handler, int sig)
83754 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83755 {
83756 /* Is it explicitly or implicitly ignored? */
83757 return handler == SIG_IGN ||
83758 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83759
83760 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83761 {
83762 - void __user *handler;
83763 + __sighandler_t handler;
83764
83765 handler = sig_handler(t, sig);
83766
83767 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83768 atomic_inc(&user->sigpending);
83769 rcu_read_unlock();
83770
83771 + if (!override_rlimit)
83772 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83773 +
83774 if (override_rlimit ||
83775 atomic_read(&user->sigpending) <=
83776 task_rlimit(t, RLIMIT_SIGPENDING)) {
83777 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83778
83779 int unhandled_signal(struct task_struct *tsk, int sig)
83780 {
83781 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83782 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83783 if (is_global_init(tsk))
83784 return 1;
83785 if (handler != SIG_IGN && handler != SIG_DFL)
83786 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83787 }
83788 }
83789
83790 + /* allow glibc communication via tgkill to other threads in our
83791 + thread group */
83792 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83793 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83794 + && gr_handle_signal(t, sig))
83795 + return -EPERM;
83796 +
83797 return security_task_kill(t, info, sig, 0);
83798 }
83799
83800 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83801 return send_signal(sig, info, p, 1);
83802 }
83803
83804 -static int
83805 +int
83806 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83807 {
83808 return send_signal(sig, info, t, 0);
83809 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83810 unsigned long int flags;
83811 int ret, blocked, ignored;
83812 struct k_sigaction *action;
83813 + int is_unhandled = 0;
83814
83815 spin_lock_irqsave(&t->sighand->siglock, flags);
83816 action = &t->sighand->action[sig-1];
83817 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83818 }
83819 if (action->sa.sa_handler == SIG_DFL)
83820 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83821 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83822 + is_unhandled = 1;
83823 ret = specific_send_sig_info(sig, info, t);
83824 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83825
83826 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83827 + normal operation */
83828 + if (is_unhandled) {
83829 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83830 + gr_handle_crash(t, sig);
83831 + }
83832 +
83833 return ret;
83834 }
83835
83836 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83837 ret = check_kill_permission(sig, info, p);
83838 rcu_read_unlock();
83839
83840 - if (!ret && sig)
83841 + if (!ret && sig) {
83842 ret = do_send_sig_info(sig, info, p, true);
83843 + if (!ret)
83844 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83845 + }
83846
83847 return ret;
83848 }
83849 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83850 int error = -ESRCH;
83851
83852 rcu_read_lock();
83853 - p = find_task_by_vpid(pid);
83854 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83855 + /* allow glibc communication via tgkill to other threads in our
83856 + thread group */
83857 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83858 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83859 + p = find_task_by_vpid_unrestricted(pid);
83860 + else
83861 +#endif
83862 + p = find_task_by_vpid(pid);
83863 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83864 error = check_kill_permission(sig, info, p);
83865 /*
83866 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83867 }
83868 seg = get_fs();
83869 set_fs(KERNEL_DS);
83870 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83871 - (stack_t __force __user *) &uoss,
83872 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83873 + (stack_t __force_user *) &uoss,
83874 compat_user_stack_pointer());
83875 set_fs(seg);
83876 if (ret >= 0 && uoss_ptr) {
83877 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83878 index eb89e18..a4e6792 100644
83879 --- a/kernel/smpboot.c
83880 +++ b/kernel/smpboot.c
83881 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83882 }
83883 smpboot_unpark_thread(plug_thread, cpu);
83884 }
83885 - list_add(&plug_thread->list, &hotplug_threads);
83886 + pax_list_add(&plug_thread->list, &hotplug_threads);
83887 out:
83888 mutex_unlock(&smpboot_threads_lock);
83889 return ret;
83890 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83891 {
83892 get_online_cpus();
83893 mutex_lock(&smpboot_threads_lock);
83894 - list_del(&plug_thread->list);
83895 + pax_list_del(&plug_thread->list);
83896 smpboot_destroy_threads(plug_thread);
83897 mutex_unlock(&smpboot_threads_lock);
83898 put_online_cpus();
83899 diff --git a/kernel/softirq.c b/kernel/softirq.c
83900 index adf6c00..5d89b73 100644
83901 --- a/kernel/softirq.c
83902 +++ b/kernel/softirq.c
83903 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83904 EXPORT_SYMBOL(irq_stat);
83905 #endif
83906
83907 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83908 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83909
83910 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83911
83912 -char *softirq_to_name[NR_SOFTIRQS] = {
83913 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83914 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83915 "TASKLET", "SCHED", "HRTIMER", "RCU"
83916 };
83917 @@ -248,7 +248,7 @@ restart:
83918 kstat_incr_softirqs_this_cpu(vec_nr);
83919
83920 trace_softirq_entry(vec_nr);
83921 - h->action(h);
83922 + h->action();
83923 trace_softirq_exit(vec_nr);
83924 if (unlikely(prev_count != preempt_count())) {
83925 printk(KERN_ERR "huh, entered softirq %u %s %p"
83926 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83927 or_softirq_pending(1UL << nr);
83928 }
83929
83930 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83931 +void __init open_softirq(int nr, void (*action)(void))
83932 {
83933 softirq_vec[nr].action = action;
83934 }
83935 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83936
83937 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83938
83939 -static void tasklet_action(struct softirq_action *a)
83940 +static __latent_entropy void tasklet_action(void)
83941 {
83942 struct tasklet_struct *list;
83943
83944 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
83945 }
83946 }
83947
83948 -static void tasklet_hi_action(struct softirq_action *a)
83949 +static __latent_entropy void tasklet_hi_action(void)
83950 {
83951 struct tasklet_struct *list;
83952
83953 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
83954 .notifier_call = cpu_callback
83955 };
83956
83957 -static struct smp_hotplug_thread softirq_threads = {
83958 +static struct smp_hotplug_thread softirq_threads __read_only = {
83959 .store = &ksoftirqd,
83960 .thread_should_run = ksoftirqd_should_run,
83961 .thread_fn = run_ksoftirqd,
83962 diff --git a/kernel/srcu.c b/kernel/srcu.c
83963 index 01d5ccb..cdcbee6 100644
83964 --- a/kernel/srcu.c
83965 +++ b/kernel/srcu.c
83966 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83967
83968 idx = ACCESS_ONCE(sp->completed) & 0x1;
83969 preempt_disable();
83970 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83971 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83972 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83973 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83974 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83975 preempt_enable();
83976 return idx;
83977 }
83978 diff --git a/kernel/sys.c b/kernel/sys.c
83979 index 771129b..dc0c7e3 100644
83980 --- a/kernel/sys.c
83981 +++ b/kernel/sys.c
83982 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83983 error = -EACCES;
83984 goto out;
83985 }
83986 +
83987 + if (gr_handle_chroot_setpriority(p, niceval)) {
83988 + error = -EACCES;
83989 + goto out;
83990 + }
83991 +
83992 no_nice = security_task_setnice(p, niceval);
83993 if (no_nice) {
83994 error = no_nice;
83995 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83996 goto error;
83997 }
83998
83999 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
84000 + goto error;
84001 +
84002 if (rgid != (gid_t) -1 ||
84003 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
84004 new->sgid = new->egid;
84005 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
84006 old = current_cred();
84007
84008 retval = -EPERM;
84009 +
84010 + if (gr_check_group_change(kgid, kgid, kgid))
84011 + goto error;
84012 +
84013 if (nsown_capable(CAP_SETGID))
84014 new->gid = new->egid = new->sgid = new->fsgid = kgid;
84015 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
84016 @@ -404,7 +417,7 @@ error:
84017 /*
84018 * change the user struct in a credentials set to match the new UID
84019 */
84020 -static int set_user(struct cred *new)
84021 +int set_user(struct cred *new)
84022 {
84023 struct user_struct *new_user;
84024
84025 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
84026 goto error;
84027 }
84028
84029 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
84030 + goto error;
84031 +
84032 if (!uid_eq(new->uid, old->uid)) {
84033 retval = set_user(new);
84034 if (retval < 0)
84035 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
84036 old = current_cred();
84037
84038 retval = -EPERM;
84039 +
84040 + if (gr_check_crash_uid(kuid))
84041 + goto error;
84042 + if (gr_check_user_change(kuid, kuid, kuid))
84043 + goto error;
84044 +
84045 if (nsown_capable(CAP_SETUID)) {
84046 new->suid = new->uid = kuid;
84047 if (!uid_eq(kuid, old->uid)) {
84048 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
84049 goto error;
84050 }
84051
84052 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84053 + goto error;
84054 +
84055 if (ruid != (uid_t) -1) {
84056 new->uid = kruid;
84057 if (!uid_eq(kruid, old->uid)) {
84058 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84059 goto error;
84060 }
84061
84062 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84063 + goto error;
84064 +
84065 if (rgid != (gid_t) -1)
84066 new->gid = krgid;
84067 if (egid != (gid_t) -1)
84068 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84069 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84070 nsown_capable(CAP_SETUID)) {
84071 if (!uid_eq(kuid, old->fsuid)) {
84072 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84073 + goto error;
84074 +
84075 new->fsuid = kuid;
84076 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84077 goto change_okay;
84078 }
84079 }
84080
84081 +error:
84082 abort_creds(new);
84083 return old_fsuid;
84084
84085 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84086 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84087 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84088 nsown_capable(CAP_SETGID)) {
84089 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84090 + goto error;
84091 +
84092 if (!gid_eq(kgid, old->fsgid)) {
84093 new->fsgid = kgid;
84094 goto change_okay;
84095 }
84096 }
84097
84098 +error:
84099 abort_creds(new);
84100 return old_fsgid;
84101
84102 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84103 return -EFAULT;
84104
84105 down_read(&uts_sem);
84106 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84107 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84108 __OLD_UTS_LEN);
84109 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84110 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84111 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84112 __OLD_UTS_LEN);
84113 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84114 - error |= __copy_to_user(&name->release, &utsname()->release,
84115 + error |= __copy_to_user(name->release, &utsname()->release,
84116 __OLD_UTS_LEN);
84117 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84118 - error |= __copy_to_user(&name->version, &utsname()->version,
84119 + error |= __copy_to_user(name->version, &utsname()->version,
84120 __OLD_UTS_LEN);
84121 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84122 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84123 + error |= __copy_to_user(name->machine, &utsname()->machine,
84124 __OLD_UTS_LEN);
84125 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84126 up_read(&uts_sem);
84127 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84128 */
84129 new_rlim->rlim_cur = 1;
84130 }
84131 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84132 + is changed to a lower value. Since tasks can be created by the same
84133 + user in between this limit change and an execve by this task, force
84134 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84135 + */
84136 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84137 + tsk->flags |= PF_NPROC_EXCEEDED;
84138 }
84139 if (!retval) {
84140 if (old_rlim)
84141 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84142 index 07f6fc4..65fb3d4 100644
84143 --- a/kernel/sysctl.c
84144 +++ b/kernel/sysctl.c
84145 @@ -93,7 +93,6 @@
84146
84147
84148 #if defined(CONFIG_SYSCTL)
84149 -
84150 /* External variables not in a header file. */
84151 extern int sysctl_overcommit_memory;
84152 extern int sysctl_overcommit_ratio;
84153 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84154
84155 /* Constants used for minimum and maximum */
84156 #ifdef CONFIG_LOCKUP_DETECTOR
84157 -static int sixty = 60;
84158 +static int sixty __read_only = 60;
84159 #endif
84160
84161 -static int zero;
84162 -static int __maybe_unused one = 1;
84163 -static int __maybe_unused two = 2;
84164 -static int __maybe_unused three = 3;
84165 -static unsigned long one_ul = 1;
84166 -static int one_hundred = 100;
84167 +static int neg_one __read_only = -1;
84168 +static int zero __read_only = 0;
84169 +static int __maybe_unused one __read_only = 1;
84170 +static int __maybe_unused two __read_only = 2;
84171 +static int __maybe_unused three __read_only = 3;
84172 +static unsigned long one_ul __read_only = 1;
84173 +static int one_hundred __read_only = 100;
84174 #ifdef CONFIG_PRINTK
84175 -static int ten_thousand = 10000;
84176 +static int ten_thousand __read_only = 10000;
84177 #endif
84178
84179 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84180 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84181 void __user *buffer, size_t *lenp, loff_t *ppos);
84182 #endif
84183
84184 -#ifdef CONFIG_PRINTK
84185 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84186 void __user *buffer, size_t *lenp, loff_t *ppos);
84187 -#endif
84188
84189 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84190 void __user *buffer, size_t *lenp, loff_t *ppos);
84191 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84192
84193 #endif
84194
84195 +extern struct ctl_table grsecurity_table[];
84196 +
84197 static struct ctl_table kern_table[];
84198 static struct ctl_table vm_table[];
84199 static struct ctl_table fs_table[];
84200 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84201 int sysctl_legacy_va_layout;
84202 #endif
84203
84204 +#ifdef CONFIG_PAX_SOFTMODE
84205 +static ctl_table pax_table[] = {
84206 + {
84207 + .procname = "softmode",
84208 + .data = &pax_softmode,
84209 + .maxlen = sizeof(unsigned int),
84210 + .mode = 0600,
84211 + .proc_handler = &proc_dointvec,
84212 + },
84213 +
84214 + { }
84215 +};
84216 +#endif
84217 +
84218 /* The default sysctl tables: */
84219
84220 static struct ctl_table sysctl_base_table[] = {
84221 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84222 #endif
84223
84224 static struct ctl_table kern_table[] = {
84225 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84226 + {
84227 + .procname = "grsecurity",
84228 + .mode = 0500,
84229 + .child = grsecurity_table,
84230 + },
84231 +#endif
84232 +
84233 +#ifdef CONFIG_PAX_SOFTMODE
84234 + {
84235 + .procname = "pax",
84236 + .mode = 0500,
84237 + .child = pax_table,
84238 + },
84239 +#endif
84240 +
84241 {
84242 .procname = "sched_child_runs_first",
84243 .data = &sysctl_sched_child_runs_first,
84244 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84245 .data = &modprobe_path,
84246 .maxlen = KMOD_PATH_LEN,
84247 .mode = 0644,
84248 - .proc_handler = proc_dostring,
84249 + .proc_handler = proc_dostring_modpriv,
84250 },
84251 {
84252 .procname = "modules_disabled",
84253 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84254 .extra1 = &zero,
84255 .extra2 = &one,
84256 },
84257 +#endif
84258 {
84259 .procname = "kptr_restrict",
84260 .data = &kptr_restrict,
84261 .maxlen = sizeof(int),
84262 .mode = 0644,
84263 .proc_handler = proc_dointvec_minmax_sysadmin,
84264 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84265 + .extra1 = &two,
84266 +#else
84267 .extra1 = &zero,
84268 +#endif
84269 .extra2 = &two,
84270 },
84271 -#endif
84272 {
84273 .procname = "ngroups_max",
84274 .data = &ngroups_max,
84275 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84276 */
84277 {
84278 .procname = "perf_event_paranoid",
84279 - .data = &sysctl_perf_event_paranoid,
84280 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84281 + .data = &sysctl_perf_event_legitimately_concerned,
84282 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84283 .mode = 0644,
84284 - .proc_handler = proc_dointvec,
84285 + /* go ahead, be a hero */
84286 + .proc_handler = proc_dointvec_minmax_sysadmin,
84287 + .extra1 = &neg_one,
84288 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84289 + .extra2 = &three,
84290 +#else
84291 + .extra2 = &two,
84292 +#endif
84293 },
84294 {
84295 .procname = "perf_event_mlock_kb",
84296 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84297 .proc_handler = proc_dointvec_minmax,
84298 .extra1 = &zero,
84299 },
84300 + {
84301 + .procname = "heap_stack_gap",
84302 + .data = &sysctl_heap_stack_gap,
84303 + .maxlen = sizeof(sysctl_heap_stack_gap),
84304 + .mode = 0644,
84305 + .proc_handler = proc_doulongvec_minmax,
84306 + },
84307 #else
84308 {
84309 .procname = "nr_trim_pages",
84310 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84311 buffer, lenp, ppos);
84312 }
84313
84314 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84315 + void __user *buffer, size_t *lenp, loff_t *ppos)
84316 +{
84317 + if (write && !capable(CAP_SYS_MODULE))
84318 + return -EPERM;
84319 +
84320 + return _proc_do_string(table->data, table->maxlen, write,
84321 + buffer, lenp, ppos);
84322 +}
84323 +
84324 static size_t proc_skip_spaces(char **buf)
84325 {
84326 size_t ret;
84327 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84328 len = strlen(tmp);
84329 if (len > *size)
84330 len = *size;
84331 + if (len > sizeof(tmp))
84332 + len = sizeof(tmp);
84333 if (copy_to_user(*buf, tmp, len))
84334 return -EFAULT;
84335 *size -= len;
84336 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84337 static int proc_taint(struct ctl_table *table, int write,
84338 void __user *buffer, size_t *lenp, loff_t *ppos)
84339 {
84340 - struct ctl_table t;
84341 + ctl_table_no_const t;
84342 unsigned long tmptaint = get_taint();
84343 int err;
84344
84345 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84346 return err;
84347 }
84348
84349 -#ifdef CONFIG_PRINTK
84350 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84351 void __user *buffer, size_t *lenp, loff_t *ppos)
84352 {
84353 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84354
84355 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84356 }
84357 -#endif
84358
84359 struct do_proc_dointvec_minmax_conv_param {
84360 int *min;
84361 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84362 *i = val;
84363 } else {
84364 val = convdiv * (*i) / convmul;
84365 - if (!first)
84366 + if (!first) {
84367 err = proc_put_char(&buffer, &left, '\t');
84368 + if (err)
84369 + break;
84370 + }
84371 err = proc_put_long(&buffer, &left, val, false);
84372 if (err)
84373 break;
84374 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84375 return -ENOSYS;
84376 }
84377
84378 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84379 + void __user *buffer, size_t *lenp, loff_t *ppos)
84380 +{
84381 + return -ENOSYS;
84382 +}
84383 +
84384 int proc_dointvec(struct ctl_table *table, int write,
84385 void __user *buffer, size_t *lenp, loff_t *ppos)
84386 {
84387 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84388 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84389 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84390 EXPORT_SYMBOL(proc_dostring);
84391 +EXPORT_SYMBOL(proc_dostring_modpriv);
84392 EXPORT_SYMBOL(proc_doulongvec_minmax);
84393 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84394 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84395 index 145bb4d..b2aa969 100644
84396 --- a/kernel/taskstats.c
84397 +++ b/kernel/taskstats.c
84398 @@ -28,9 +28,12 @@
84399 #include <linux/fs.h>
84400 #include <linux/file.h>
84401 #include <linux/pid_namespace.h>
84402 +#include <linux/grsecurity.h>
84403 #include <net/genetlink.h>
84404 #include <linux/atomic.h>
84405
84406 +extern int gr_is_taskstats_denied(int pid);
84407 +
84408 /*
84409 * Maximum length of a cpumask that can be specified in
84410 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84411 @@ -570,6 +573,9 @@ err:
84412
84413 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84414 {
84415 + if (gr_is_taskstats_denied(current->pid))
84416 + return -EACCES;
84417 +
84418 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84419 return cmd_attr_register_cpumask(info);
84420 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84421 diff --git a/kernel/time.c b/kernel/time.c
84422 index 7c7964c..784a599 100644
84423 --- a/kernel/time.c
84424 +++ b/kernel/time.c
84425 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84426 return error;
84427
84428 if (tz) {
84429 + /* we log in do_settimeofday called below, so don't log twice
84430 + */
84431 + if (!tv)
84432 + gr_log_timechange();
84433 +
84434 sys_tz = *tz;
84435 update_vsyscall_tz();
84436 if (firsttime) {
84437 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84438 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84439 * value to a scaled second value.
84440 */
84441 -unsigned long
84442 +unsigned long __intentional_overflow(-1)
84443 timespec_to_jiffies(const struct timespec *value)
84444 {
84445 unsigned long sec = value->tv_sec;
84446 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84447 index eec50fc..65e5df6 100644
84448 --- a/kernel/time/alarmtimer.c
84449 +++ b/kernel/time/alarmtimer.c
84450 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84451 struct platform_device *pdev;
84452 int error = 0;
84453 int i;
84454 - struct k_clock alarm_clock = {
84455 + static struct k_clock alarm_clock = {
84456 .clock_getres = alarm_clock_getres,
84457 .clock_get = alarm_clock_get,
84458 .timer_create = alarm_timer_create,
84459 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84460 index 947ba25..20cbade 100644
84461 --- a/kernel/time/timekeeping.c
84462 +++ b/kernel/time/timekeeping.c
84463 @@ -15,6 +15,7 @@
84464 #include <linux/init.h>
84465 #include <linux/mm.h>
84466 #include <linux/sched.h>
84467 +#include <linux/grsecurity.h>
84468 #include <linux/syscore_ops.h>
84469 #include <linux/clocksource.h>
84470 #include <linux/jiffies.h>
84471 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84472 if (!timespec_valid_strict(tv))
84473 return -EINVAL;
84474
84475 + gr_log_timechange();
84476 +
84477 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84478 write_seqcount_begin(&timekeeper_seq);
84479
84480 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84481 index 61ed862..3b52c65 100644
84482 --- a/kernel/time/timer_list.c
84483 +++ b/kernel/time/timer_list.c
84484 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84485
84486 static void print_name_offset(struct seq_file *m, void *sym)
84487 {
84488 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84489 + SEQ_printf(m, "<%p>", NULL);
84490 +#else
84491 char symname[KSYM_NAME_LEN];
84492
84493 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84494 SEQ_printf(m, "<%pK>", sym);
84495 else
84496 SEQ_printf(m, "%s", symname);
84497 +#endif
84498 }
84499
84500 static void
84501 @@ -119,7 +123,11 @@ next_one:
84502 static void
84503 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84504 {
84505 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84506 + SEQ_printf(m, " .base: %p\n", NULL);
84507 +#else
84508 SEQ_printf(m, " .base: %pK\n", base);
84509 +#endif
84510 SEQ_printf(m, " .index: %d\n",
84511 base->index);
84512 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84513 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84514 {
84515 struct proc_dir_entry *pe;
84516
84517 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84518 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84519 +#else
84520 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84521 +#endif
84522 if (!pe)
84523 return -ENOMEM;
84524 return 0;
84525 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84526 index 0b537f2..40d6c20 100644
84527 --- a/kernel/time/timer_stats.c
84528 +++ b/kernel/time/timer_stats.c
84529 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84530 static unsigned long nr_entries;
84531 static struct entry entries[MAX_ENTRIES];
84532
84533 -static atomic_t overflow_count;
84534 +static atomic_unchecked_t overflow_count;
84535
84536 /*
84537 * The entries are in a hash-table, for fast lookup:
84538 @@ -140,7 +140,7 @@ static void reset_entries(void)
84539 nr_entries = 0;
84540 memset(entries, 0, sizeof(entries));
84541 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84542 - atomic_set(&overflow_count, 0);
84543 + atomic_set_unchecked(&overflow_count, 0);
84544 }
84545
84546 static struct entry *alloc_entry(void)
84547 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84548 if (likely(entry))
84549 entry->count++;
84550 else
84551 - atomic_inc(&overflow_count);
84552 + atomic_inc_unchecked(&overflow_count);
84553
84554 out_unlock:
84555 raw_spin_unlock_irqrestore(lock, flags);
84556 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84557
84558 static void print_name_offset(struct seq_file *m, unsigned long addr)
84559 {
84560 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84561 + seq_printf(m, "<%p>", NULL);
84562 +#else
84563 char symname[KSYM_NAME_LEN];
84564
84565 if (lookup_symbol_name(addr, symname) < 0)
84566 - seq_printf(m, "<%p>", (void *)addr);
84567 + seq_printf(m, "<%pK>", (void *)addr);
84568 else
84569 seq_printf(m, "%s", symname);
84570 +#endif
84571 }
84572
84573 static int tstats_show(struct seq_file *m, void *v)
84574 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84575
84576 seq_puts(m, "Timer Stats Version: v0.2\n");
84577 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84578 - if (atomic_read(&overflow_count))
84579 + if (atomic_read_unchecked(&overflow_count))
84580 seq_printf(m, "Overflow: %d entries\n",
84581 - atomic_read(&overflow_count));
84582 + atomic_read_unchecked(&overflow_count));
84583
84584 for (i = 0; i < nr_entries; i++) {
84585 entry = entries + i;
84586 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84587 {
84588 struct proc_dir_entry *pe;
84589
84590 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84591 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84592 +#else
84593 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84594 +#endif
84595 if (!pe)
84596 return -ENOMEM;
84597 return 0;
84598 diff --git a/kernel/timer.c b/kernel/timer.c
84599 index 4296d13..0164b04 100644
84600 --- a/kernel/timer.c
84601 +++ b/kernel/timer.c
84602 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84603 /*
84604 * This function runs timers and the timer-tq in bottom half context.
84605 */
84606 -static void run_timer_softirq(struct softirq_action *h)
84607 +static __latent_entropy void run_timer_softirq(void)
84608 {
84609 struct tvec_base *base = __this_cpu_read(tvec_bases);
84610
84611 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84612 *
84613 * In all cases the return value is guaranteed to be non-negative.
84614 */
84615 -signed long __sched schedule_timeout(signed long timeout)
84616 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84617 {
84618 struct timer_list timer;
84619 unsigned long expire;
84620 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84621 index b8b8560..75b1a09 100644
84622 --- a/kernel/trace/blktrace.c
84623 +++ b/kernel/trace/blktrace.c
84624 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84625 struct blk_trace *bt = filp->private_data;
84626 char buf[16];
84627
84628 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84629 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84630
84631 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84632 }
84633 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84634 return 1;
84635
84636 bt = buf->chan->private_data;
84637 - atomic_inc(&bt->dropped);
84638 + atomic_inc_unchecked(&bt->dropped);
84639 return 0;
84640 }
84641
84642 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84643
84644 bt->dir = dir;
84645 bt->dev = dev;
84646 - atomic_set(&bt->dropped, 0);
84647 + atomic_set_unchecked(&bt->dropped, 0);
84648
84649 ret = -EIO;
84650 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84651 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84652 index a6d098c..bb8cf65 100644
84653 --- a/kernel/trace/ftrace.c
84654 +++ b/kernel/trace/ftrace.c
84655 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84656 if (unlikely(ftrace_disabled))
84657 return 0;
84658
84659 + ret = ftrace_arch_code_modify_prepare();
84660 + FTRACE_WARN_ON(ret);
84661 + if (ret)
84662 + return 0;
84663 +
84664 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84665 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84666 if (ret) {
84667 ftrace_bug(ret, ip);
84668 - return 0;
84669 }
84670 - return 1;
84671 + return ret ? 0 : 1;
84672 }
84673
84674 /*
84675 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84676 if (!count)
84677 return 0;
84678
84679 + pax_open_kernel();
84680 sort(start, count, sizeof(*start),
84681 ftrace_cmp_ips, ftrace_swap_ips);
84682 + pax_close_kernel();
84683
84684 start_pg = ftrace_allocate_pages(count);
84685 if (!start_pg)
84686 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84687 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84688
84689 static int ftrace_graph_active;
84690 -static struct notifier_block ftrace_suspend_notifier;
84691 -
84692 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84693 {
84694 return 0;
84695 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84696 return NOTIFY_DONE;
84697 }
84698
84699 +static struct notifier_block ftrace_suspend_notifier = {
84700 + .notifier_call = ftrace_suspend_notifier_call
84701 +};
84702 +
84703 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84704 trace_func_graph_ent_t entryfunc)
84705 {
84706 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84707 goto out;
84708 }
84709
84710 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84711 register_pm_notifier(&ftrace_suspend_notifier);
84712
84713 ftrace_graph_active++;
84714 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84715 index cc2f66f..05edd54 100644
84716 --- a/kernel/trace/ring_buffer.c
84717 +++ b/kernel/trace/ring_buffer.c
84718 @@ -352,9 +352,9 @@ struct buffer_data_page {
84719 */
84720 struct buffer_page {
84721 struct list_head list; /* list of buffer pages */
84722 - local_t write; /* index for next write */
84723 + local_unchecked_t write; /* index for next write */
84724 unsigned read; /* index for next read */
84725 - local_t entries; /* entries on this page */
84726 + local_unchecked_t entries; /* entries on this page */
84727 unsigned long real_end; /* real end of data */
84728 struct buffer_data_page *page; /* Actual data page */
84729 };
84730 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84731 unsigned long last_overrun;
84732 local_t entries_bytes;
84733 local_t entries;
84734 - local_t overrun;
84735 - local_t commit_overrun;
84736 + local_unchecked_t overrun;
84737 + local_unchecked_t commit_overrun;
84738 local_t dropped_events;
84739 local_t committing;
84740 local_t commits;
84741 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84742 *
84743 * We add a counter to the write field to denote this.
84744 */
84745 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84746 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84747 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84748 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84749
84750 /*
84751 * Just make sure we have seen our old_write and synchronize
84752 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84753 * cmpxchg to only update if an interrupt did not already
84754 * do it for us. If the cmpxchg fails, we don't care.
84755 */
84756 - (void)local_cmpxchg(&next_page->write, old_write, val);
84757 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84758 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84759 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84760
84761 /*
84762 * No need to worry about races with clearing out the commit.
84763 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84764
84765 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84766 {
84767 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84768 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84769 }
84770
84771 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84772 {
84773 - return local_read(&bpage->write) & RB_WRITE_MASK;
84774 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84775 }
84776
84777 static int
84778 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84779 * bytes consumed in ring buffer from here.
84780 * Increment overrun to account for the lost events.
84781 */
84782 - local_add(page_entries, &cpu_buffer->overrun);
84783 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84784 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84785 }
84786
84787 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84788 * it is our responsibility to update
84789 * the counters.
84790 */
84791 - local_add(entries, &cpu_buffer->overrun);
84792 + local_add_unchecked(entries, &cpu_buffer->overrun);
84793 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84794
84795 /*
84796 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84797 if (tail == BUF_PAGE_SIZE)
84798 tail_page->real_end = 0;
84799
84800 - local_sub(length, &tail_page->write);
84801 + local_sub_unchecked(length, &tail_page->write);
84802 return;
84803 }
84804
84805 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84806 rb_event_set_padding(event);
84807
84808 /* Set the write back to the previous setting */
84809 - local_sub(length, &tail_page->write);
84810 + local_sub_unchecked(length, &tail_page->write);
84811 return;
84812 }
84813
84814 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84815
84816 /* Set write to end of buffer */
84817 length = (tail + length) - BUF_PAGE_SIZE;
84818 - local_sub(length, &tail_page->write);
84819 + local_sub_unchecked(length, &tail_page->write);
84820 }
84821
84822 /*
84823 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84824 * about it.
84825 */
84826 if (unlikely(next_page == commit_page)) {
84827 - local_inc(&cpu_buffer->commit_overrun);
84828 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84829 goto out_reset;
84830 }
84831
84832 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84833 cpu_buffer->tail_page) &&
84834 (cpu_buffer->commit_page ==
84835 cpu_buffer->reader_page))) {
84836 - local_inc(&cpu_buffer->commit_overrun);
84837 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84838 goto out_reset;
84839 }
84840 }
84841 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84842 length += RB_LEN_TIME_EXTEND;
84843
84844 tail_page = cpu_buffer->tail_page;
84845 - write = local_add_return(length, &tail_page->write);
84846 + write = local_add_return_unchecked(length, &tail_page->write);
84847
84848 /* set write to only the index of the write */
84849 write &= RB_WRITE_MASK;
84850 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84851 kmemcheck_annotate_bitfield(event, bitfield);
84852 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84853
84854 - local_inc(&tail_page->entries);
84855 + local_inc_unchecked(&tail_page->entries);
84856
84857 /*
84858 * If this is the first commit on the page, then update
84859 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84860
84861 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84862 unsigned long write_mask =
84863 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84864 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84865 unsigned long event_length = rb_event_length(event);
84866 /*
84867 * This is on the tail page. It is possible that
84868 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84869 */
84870 old_index += write_mask;
84871 new_index += write_mask;
84872 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84873 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84874 if (index == old_index) {
84875 /* update counters */
84876 local_sub(event_length, &cpu_buffer->entries_bytes);
84877 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84878
84879 /* Do the likely case first */
84880 if (likely(bpage->page == (void *)addr)) {
84881 - local_dec(&bpage->entries);
84882 + local_dec_unchecked(&bpage->entries);
84883 return;
84884 }
84885
84886 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84887 start = bpage;
84888 do {
84889 if (bpage->page == (void *)addr) {
84890 - local_dec(&bpage->entries);
84891 + local_dec_unchecked(&bpage->entries);
84892 return;
84893 }
84894 rb_inc_page(cpu_buffer, &bpage);
84895 @@ -3139,7 +3139,7 @@ static inline unsigned long
84896 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84897 {
84898 return local_read(&cpu_buffer->entries) -
84899 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84900 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84901 }
84902
84903 /**
84904 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84905 return 0;
84906
84907 cpu_buffer = buffer->buffers[cpu];
84908 - ret = local_read(&cpu_buffer->overrun);
84909 + ret = local_read_unchecked(&cpu_buffer->overrun);
84910
84911 return ret;
84912 }
84913 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84914 return 0;
84915
84916 cpu_buffer = buffer->buffers[cpu];
84917 - ret = local_read(&cpu_buffer->commit_overrun);
84918 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84919
84920 return ret;
84921 }
84922 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84923 /* if you care about this being correct, lock the buffer */
84924 for_each_buffer_cpu(buffer, cpu) {
84925 cpu_buffer = buffer->buffers[cpu];
84926 - overruns += local_read(&cpu_buffer->overrun);
84927 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84928 }
84929
84930 return overruns;
84931 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84932 /*
84933 * Reset the reader page to size zero.
84934 */
84935 - local_set(&cpu_buffer->reader_page->write, 0);
84936 - local_set(&cpu_buffer->reader_page->entries, 0);
84937 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84938 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84939 local_set(&cpu_buffer->reader_page->page->commit, 0);
84940 cpu_buffer->reader_page->real_end = 0;
84941
84942 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84943 * want to compare with the last_overrun.
84944 */
84945 smp_mb();
84946 - overwrite = local_read(&(cpu_buffer->overrun));
84947 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84948
84949 /*
84950 * Here's the tricky part.
84951 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84952
84953 cpu_buffer->head_page
84954 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84955 - local_set(&cpu_buffer->head_page->write, 0);
84956 - local_set(&cpu_buffer->head_page->entries, 0);
84957 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84958 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84959 local_set(&cpu_buffer->head_page->page->commit, 0);
84960
84961 cpu_buffer->head_page->read = 0;
84962 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84963
84964 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84965 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84966 - local_set(&cpu_buffer->reader_page->write, 0);
84967 - local_set(&cpu_buffer->reader_page->entries, 0);
84968 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84969 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84970 local_set(&cpu_buffer->reader_page->page->commit, 0);
84971 cpu_buffer->reader_page->read = 0;
84972
84973 local_set(&cpu_buffer->entries_bytes, 0);
84974 - local_set(&cpu_buffer->overrun, 0);
84975 - local_set(&cpu_buffer->commit_overrun, 0);
84976 + local_set_unchecked(&cpu_buffer->overrun, 0);
84977 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84978 local_set(&cpu_buffer->dropped_events, 0);
84979 local_set(&cpu_buffer->entries, 0);
84980 local_set(&cpu_buffer->committing, 0);
84981 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84982 rb_init_page(bpage);
84983 bpage = reader->page;
84984 reader->page = *data_page;
84985 - local_set(&reader->write, 0);
84986 - local_set(&reader->entries, 0);
84987 + local_set_unchecked(&reader->write, 0);
84988 + local_set_unchecked(&reader->entries, 0);
84989 reader->read = 0;
84990 *data_page = bpage;
84991
84992 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84993 index 496f94d..754aeea 100644
84994 --- a/kernel/trace/trace.c
84995 +++ b/kernel/trace/trace.c
84996 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84997 return 0;
84998 }
84999
85000 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
85001 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
85002 {
85003 /* do nothing if flag is already set */
85004 if (!!(trace_flags & mask) == !!enabled)
85005 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
85006 index afaae41..64871f8 100644
85007 --- a/kernel/trace/trace.h
85008 +++ b/kernel/trace/trace.h
85009 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
85010 void trace_printk_init_buffers(void);
85011 void trace_printk_start_comm(void);
85012 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
85013 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
85014 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
85015
85016 /*
85017 * Normal trace_printk() and friends allocates special buffers
85018 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
85019 index 26dc348..8708ca7 100644
85020 --- a/kernel/trace/trace_clock.c
85021 +++ b/kernel/trace/trace_clock.c
85022 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
85023 return now;
85024 }
85025
85026 -static atomic64_t trace_counter;
85027 +static atomic64_unchecked_t trace_counter;
85028
85029 /*
85030 * trace_clock_counter(): simply an atomic counter.
85031 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
85032 */
85033 u64 notrace trace_clock_counter(void)
85034 {
85035 - return atomic64_add_return(1, &trace_counter);
85036 + return atomic64_inc_return_unchecked(&trace_counter);
85037 }
85038 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
85039 index 29a7ebc..eb473cf 100644
85040 --- a/kernel/trace/trace_events.c
85041 +++ b/kernel/trace/trace_events.c
85042 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
85043 struct ftrace_module_file_ops {
85044 struct list_head list;
85045 struct module *mod;
85046 - struct file_operations id;
85047 - struct file_operations enable;
85048 - struct file_operations format;
85049 - struct file_operations filter;
85050 };
85051
85052 static struct ftrace_module_file_ops *
85053 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85054
85055 file_ops->mod = mod;
85056
85057 - file_ops->id = ftrace_event_id_fops;
85058 - file_ops->id.owner = mod;
85059 -
85060 - file_ops->enable = ftrace_enable_fops;
85061 - file_ops->enable.owner = mod;
85062 -
85063 - file_ops->filter = ftrace_event_filter_fops;
85064 - file_ops->filter.owner = mod;
85065 -
85066 - file_ops->format = ftrace_event_format_fops;
85067 - file_ops->format.owner = mod;
85068 + pax_open_kernel();
85069 + mod->trace_id.owner = mod;
85070 + mod->trace_enable.owner = mod;
85071 + mod->trace_filter.owner = mod;
85072 + mod->trace_format.owner = mod;
85073 + pax_close_kernel();
85074
85075 list_add(&file_ops->list, &ftrace_module_file_list);
85076
85077 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85078 struct ftrace_module_file_ops *file_ops)
85079 {
85080 return __trace_add_new_event(call, tr,
85081 - &file_ops->id, &file_ops->enable,
85082 - &file_ops->filter, &file_ops->format);
85083 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85084 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85085 }
85086
85087 #else
85088 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85089 index b3dcfb2..ebee344 100644
85090 --- a/kernel/trace/trace_mmiotrace.c
85091 +++ b/kernel/trace/trace_mmiotrace.c
85092 @@ -24,7 +24,7 @@ struct header_iter {
85093 static struct trace_array *mmio_trace_array;
85094 static bool overrun_detected;
85095 static unsigned long prev_overruns;
85096 -static atomic_t dropped_count;
85097 +static atomic_unchecked_t dropped_count;
85098
85099 static void mmio_reset_data(struct trace_array *tr)
85100 {
85101 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85102
85103 static unsigned long count_overruns(struct trace_iterator *iter)
85104 {
85105 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85106 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85107 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85108
85109 if (over > prev_overruns)
85110 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85111 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85112 sizeof(*entry), 0, pc);
85113 if (!event) {
85114 - atomic_inc(&dropped_count);
85115 + atomic_inc_unchecked(&dropped_count);
85116 return;
85117 }
85118 entry = ring_buffer_event_data(event);
85119 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85120 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85121 sizeof(*entry), 0, pc);
85122 if (!event) {
85123 - atomic_inc(&dropped_count);
85124 + atomic_inc_unchecked(&dropped_count);
85125 return;
85126 }
85127 entry = ring_buffer_event_data(event);
85128 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85129 index 34e7cba..6f9a729 100644
85130 --- a/kernel/trace/trace_output.c
85131 +++ b/kernel/trace/trace_output.c
85132 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85133
85134 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85135 if (!IS_ERR(p)) {
85136 - p = mangle_path(s->buffer + s->len, p, "\n");
85137 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85138 if (p) {
85139 s->len = p - s->buffer;
85140 return 1;
85141 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85142 goto out;
85143 }
85144
85145 + pax_open_kernel();
85146 if (event->funcs->trace == NULL)
85147 - event->funcs->trace = trace_nop_print;
85148 + *(void **)&event->funcs->trace = trace_nop_print;
85149 if (event->funcs->raw == NULL)
85150 - event->funcs->raw = trace_nop_print;
85151 + *(void **)&event->funcs->raw = trace_nop_print;
85152 if (event->funcs->hex == NULL)
85153 - event->funcs->hex = trace_nop_print;
85154 + *(void **)&event->funcs->hex = trace_nop_print;
85155 if (event->funcs->binary == NULL)
85156 - event->funcs->binary = trace_nop_print;
85157 + *(void **)&event->funcs->binary = trace_nop_print;
85158 + pax_close_kernel();
85159
85160 key = event->type & (EVENT_HASHSIZE - 1);
85161
85162 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85163 index b20428c..4845a10 100644
85164 --- a/kernel/trace/trace_stack.c
85165 +++ b/kernel/trace/trace_stack.c
85166 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85167 return;
85168
85169 /* we do not handle interrupt stacks yet */
85170 - if (!object_is_on_stack(stack))
85171 + if (!object_starts_on_stack(stack))
85172 return;
85173
85174 local_irq_save(flags);
85175 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85176 index 9064b91..1f5d2f8 100644
85177 --- a/kernel/user_namespace.c
85178 +++ b/kernel/user_namespace.c
85179 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85180 !kgid_has_mapping(parent_ns, group))
85181 return -EPERM;
85182
85183 +#ifdef CONFIG_GRKERNSEC
85184 + /*
85185 + * This doesn't really inspire confidence:
85186 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85187 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85188 + * Increases kernel attack surface in areas developers
85189 + * previously cared little about ("low importance due
85190 + * to requiring "root" capability")
85191 + * To be removed when this code receives *proper* review
85192 + */
85193 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85194 + !capable(CAP_SETGID))
85195 + return -EPERM;
85196 +#endif
85197 +
85198 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85199 if (!ns)
85200 return -ENOMEM;
85201 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85202 if (atomic_read(&current->mm->mm_users) > 1)
85203 return -EINVAL;
85204
85205 - if (current->fs->users != 1)
85206 + if (atomic_read(&current->fs->users) != 1)
85207 return -EINVAL;
85208
85209 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85210 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85211 index 4f69f9a..7c6f8f8 100644
85212 --- a/kernel/utsname_sysctl.c
85213 +++ b/kernel/utsname_sysctl.c
85214 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85215 static int proc_do_uts_string(ctl_table *table, int write,
85216 void __user *buffer, size_t *lenp, loff_t *ppos)
85217 {
85218 - struct ctl_table uts_table;
85219 + ctl_table_no_const uts_table;
85220 int r;
85221 memcpy(&uts_table, table, sizeof(uts_table));
85222 uts_table.data = get_uts(table, write);
85223 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85224 index 1241d8c..d5cfc28 100644
85225 --- a/kernel/watchdog.c
85226 +++ b/kernel/watchdog.c
85227 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85228 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85229 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85230
85231 -static struct smp_hotplug_thread watchdog_threads = {
85232 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85233 .store = &softlockup_watchdog,
85234 .thread_should_run = watchdog_should_run,
85235 .thread_fn = watchdog,
85236 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85237 index e93f7b9..989fcd7 100644
85238 --- a/kernel/workqueue.c
85239 +++ b/kernel/workqueue.c
85240 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85241 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85242 worker_flags |= WORKER_REBOUND;
85243 worker_flags &= ~WORKER_UNBOUND;
85244 - ACCESS_ONCE(worker->flags) = worker_flags;
85245 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85246 }
85247
85248 spin_unlock_irq(&pool->lock);
85249 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85250 index 1501aa5..e771896 100644
85251 --- a/lib/Kconfig.debug
85252 +++ b/lib/Kconfig.debug
85253 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85254
85255 config DEBUG_WW_MUTEX_SLOWPATH
85256 bool "Wait/wound mutex debugging: Slowpath testing"
85257 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85258 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85259 select DEBUG_LOCK_ALLOC
85260 select DEBUG_SPINLOCK
85261 select DEBUG_MUTEXES
85262 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85263
85264 config DEBUG_LOCK_ALLOC
85265 bool "Lock debugging: detect incorrect freeing of live locks"
85266 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85267 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85268 select DEBUG_SPINLOCK
85269 select DEBUG_MUTEXES
85270 select LOCKDEP
85271 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85272
85273 config PROVE_LOCKING
85274 bool "Lock debugging: prove locking correctness"
85275 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85276 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85277 select LOCKDEP
85278 select DEBUG_SPINLOCK
85279 select DEBUG_MUTEXES
85280 @@ -914,7 +914,7 @@ config LOCKDEP
85281
85282 config LOCK_STAT
85283 bool "Lock usage statistics"
85284 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85285 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85286 select LOCKDEP
85287 select DEBUG_SPINLOCK
85288 select DEBUG_MUTEXES
85289 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85290 depends on DEBUG_KERNEL
85291 depends on STACKTRACE_SUPPORT
85292 depends on PROC_FS
85293 + depends on !GRKERNSEC_HIDESYM
85294 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85295 select KALLSYMS
85296 select KALLSYMS_ALL
85297 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85298 config DEBUG_STRICT_USER_COPY_CHECKS
85299 bool "Strict user copy size checks"
85300 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85301 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85302 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85303 help
85304 Enabling this option turns a certain set of sanity checks for user
85305 copy operations into compile time failures.
85306 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85307
85308 config PROVIDE_OHCI1394_DMA_INIT
85309 bool "Remote debugging over FireWire early on boot"
85310 - depends on PCI && X86
85311 + depends on PCI && X86 && !GRKERNSEC
85312 help
85313 If you want to debug problems which hang or crash the kernel early
85314 on boot and the crashing machine has a FireWire port, you can use
85315 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85316
85317 config FIREWIRE_OHCI_REMOTE_DMA
85318 bool "Remote debugging over FireWire with firewire-ohci"
85319 - depends on FIREWIRE_OHCI
85320 + depends on FIREWIRE_OHCI && !GRKERNSEC
85321 help
85322 This option lets you use the FireWire bus for remote debugging
85323 with help of the firewire-ohci driver. It enables unfiltered
85324 diff --git a/lib/Makefile b/lib/Makefile
85325 index 7baccfd..3ceb95f 100644
85326 --- a/lib/Makefile
85327 +++ b/lib/Makefile
85328 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85329
85330 obj-$(CONFIG_BTREE) += btree.o
85331 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85332 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85333 +obj-y += list_debug.o
85334 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85335
85336 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85337 diff --git a/lib/bitmap.c b/lib/bitmap.c
85338 index 06f7e4f..f3cf2b0 100644
85339 --- a/lib/bitmap.c
85340 +++ b/lib/bitmap.c
85341 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85342 {
85343 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85344 u32 chunk;
85345 - const char __user __force *ubuf = (const char __user __force *)buf;
85346 + const char __user *ubuf = (const char __force_user *)buf;
85347
85348 bitmap_zero(maskp, nmaskbits);
85349
85350 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85351 {
85352 if (!access_ok(VERIFY_READ, ubuf, ulen))
85353 return -EFAULT;
85354 - return __bitmap_parse((const char __force *)ubuf,
85355 + return __bitmap_parse((const char __force_kernel *)ubuf,
85356 ulen, 1, maskp, nmaskbits);
85357
85358 }
85359 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85360 {
85361 unsigned a, b;
85362 int c, old_c, totaldigits;
85363 - const char __user __force *ubuf = (const char __user __force *)buf;
85364 + const char __user *ubuf = (const char __force_user *)buf;
85365 int exp_digit, in_range;
85366
85367 totaldigits = c = 0;
85368 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85369 {
85370 if (!access_ok(VERIFY_READ, ubuf, ulen))
85371 return -EFAULT;
85372 - return __bitmap_parselist((const char __force *)ubuf,
85373 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85374 ulen, 1, maskp, nmaskbits);
85375 }
85376 EXPORT_SYMBOL(bitmap_parselist_user);
85377 diff --git a/lib/bug.c b/lib/bug.c
85378 index 1686034..a9c00c8 100644
85379 --- a/lib/bug.c
85380 +++ b/lib/bug.c
85381 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85382 return BUG_TRAP_TYPE_NONE;
85383
85384 bug = find_bug(bugaddr);
85385 + if (!bug)
85386 + return BUG_TRAP_TYPE_NONE;
85387
85388 file = NULL;
85389 line = 0;
85390 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85391 index 37061ed..da83f48 100644
85392 --- a/lib/debugobjects.c
85393 +++ b/lib/debugobjects.c
85394 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85395 if (limit > 4)
85396 return;
85397
85398 - is_on_stack = object_is_on_stack(addr);
85399 + is_on_stack = object_starts_on_stack(addr);
85400 if (is_on_stack == onstack)
85401 return;
85402
85403 diff --git a/lib/devres.c b/lib/devres.c
85404 index 8235331..5881053 100644
85405 --- a/lib/devres.c
85406 +++ b/lib/devres.c
85407 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85408 void devm_iounmap(struct device *dev, void __iomem *addr)
85409 {
85410 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85411 - (void *)addr));
85412 + (void __force *)addr));
85413 iounmap(addr);
85414 }
85415 EXPORT_SYMBOL(devm_iounmap);
85416 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85417 {
85418 ioport_unmap(addr);
85419 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85420 - devm_ioport_map_match, (void *)addr));
85421 + devm_ioport_map_match, (void __force *)addr));
85422 }
85423 EXPORT_SYMBOL(devm_ioport_unmap);
85424 #endif /* CONFIG_HAS_IOPORT */
85425 diff --git a/lib/div64.c b/lib/div64.c
85426 index a163b6c..9618fa5 100644
85427 --- a/lib/div64.c
85428 +++ b/lib/div64.c
85429 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85430 EXPORT_SYMBOL(__div64_32);
85431
85432 #ifndef div_s64_rem
85433 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85434 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85435 {
85436 u64 quotient;
85437
85438 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85439 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85440 */
85441 #ifndef div64_u64
85442 -u64 div64_u64(u64 dividend, u64 divisor)
85443 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85444 {
85445 u32 high = divisor >> 32;
85446 u64 quot;
85447 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85448 index d87a17a..ac0d79a 100644
85449 --- a/lib/dma-debug.c
85450 +++ b/lib/dma-debug.c
85451 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85452
85453 void dma_debug_add_bus(struct bus_type *bus)
85454 {
85455 - struct notifier_block *nb;
85456 + notifier_block_no_const *nb;
85457
85458 if (global_disable)
85459 return;
85460 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85461
85462 static void check_for_stack(struct device *dev, void *addr)
85463 {
85464 - if (object_is_on_stack(addr))
85465 + if (object_starts_on_stack(addr))
85466 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85467 "stack [addr=%p]\n", addr);
85468 }
85469 diff --git a/lib/inflate.c b/lib/inflate.c
85470 index 013a761..c28f3fc 100644
85471 --- a/lib/inflate.c
85472 +++ b/lib/inflate.c
85473 @@ -269,7 +269,7 @@ static void free(void *where)
85474 malloc_ptr = free_mem_ptr;
85475 }
85476 #else
85477 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85478 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85479 #define free(a) kfree(a)
85480 #endif
85481
85482 diff --git a/lib/ioremap.c b/lib/ioremap.c
85483 index 0c9216c..863bd89 100644
85484 --- a/lib/ioremap.c
85485 +++ b/lib/ioremap.c
85486 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85487 unsigned long next;
85488
85489 phys_addr -= addr;
85490 - pmd = pmd_alloc(&init_mm, pud, addr);
85491 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85492 if (!pmd)
85493 return -ENOMEM;
85494 do {
85495 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85496 unsigned long next;
85497
85498 phys_addr -= addr;
85499 - pud = pud_alloc(&init_mm, pgd, addr);
85500 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85501 if (!pud)
85502 return -ENOMEM;
85503 do {
85504 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85505 index bd2bea9..6b3c95e 100644
85506 --- a/lib/is_single_threaded.c
85507 +++ b/lib/is_single_threaded.c
85508 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85509 struct task_struct *p, *t;
85510 bool ret;
85511
85512 + if (!mm)
85513 + return true;
85514 +
85515 if (atomic_read(&task->signal->live) != 1)
85516 return false;
85517
85518 diff --git a/lib/kobject.c b/lib/kobject.c
85519 index 4a1f33d..2f3ca75 100644
85520 --- a/lib/kobject.c
85521 +++ b/lib/kobject.c
85522 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85523
85524
85525 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85526 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85527 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85528
85529 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85530 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85531 {
85532 enum kobj_ns_type type = ops->type;
85533 int error;
85534 diff --git a/lib/list_debug.c b/lib/list_debug.c
85535 index c24c2f7..06e070b 100644
85536 --- a/lib/list_debug.c
85537 +++ b/lib/list_debug.c
85538 @@ -11,7 +11,9 @@
85539 #include <linux/bug.h>
85540 #include <linux/kernel.h>
85541 #include <linux/rculist.h>
85542 +#include <linux/mm.h>
85543
85544 +#ifdef CONFIG_DEBUG_LIST
85545 /*
85546 * Insert a new entry between two known consecutive entries.
85547 *
85548 @@ -19,21 +21,32 @@
85549 * the prev/next entries already!
85550 */
85551
85552 -void __list_add(struct list_head *new,
85553 - struct list_head *prev,
85554 - struct list_head *next)
85555 +static bool __list_add_debug(struct list_head *new,
85556 + struct list_head *prev,
85557 + struct list_head *next)
85558 {
85559 - WARN(next->prev != prev,
85560 + if (WARN(next->prev != prev,
85561 "list_add corruption. next->prev should be "
85562 "prev (%p), but was %p. (next=%p).\n",
85563 - prev, next->prev, next);
85564 - WARN(prev->next != next,
85565 + prev, next->prev, next) ||
85566 + WARN(prev->next != next,
85567 "list_add corruption. prev->next should be "
85568 "next (%p), but was %p. (prev=%p).\n",
85569 - next, prev->next, prev);
85570 - WARN(new == prev || new == next,
85571 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85572 - new, prev, next);
85573 + next, prev->next, prev) ||
85574 + WARN(new == prev || new == next,
85575 + "list_add double add: new=%p, prev=%p, next=%p.\n",
85576 + new, prev, next))
85577 + return false;
85578 + return true;
85579 +}
85580 +
85581 +void __list_add(struct list_head *new,
85582 + struct list_head *prev,
85583 + struct list_head *next)
85584 +{
85585 + if (!__list_add_debug(new, prev, next))
85586 + return;
85587 +
85588 next->prev = new;
85589 new->next = next;
85590 new->prev = prev;
85591 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
85592 }
85593 EXPORT_SYMBOL(__list_add);
85594
85595 -void __list_del_entry(struct list_head *entry)
85596 +static bool __list_del_entry_debug(struct list_head *entry)
85597 {
85598 struct list_head *prev, *next;
85599
85600 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
85601 WARN(next->prev != entry,
85602 "list_del corruption. next->prev should be %p, "
85603 "but was %p\n", entry, next->prev))
85604 + return false;
85605 + return true;
85606 +}
85607 +
85608 +void __list_del_entry(struct list_head *entry)
85609 +{
85610 + if (!__list_del_entry_debug(entry))
85611 return;
85612
85613 - __list_del(prev, next);
85614 + __list_del(entry->prev, entry->next);
85615 }
85616 EXPORT_SYMBOL(__list_del_entry);
85617
85618 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
85619 void __list_add_rcu(struct list_head *new,
85620 struct list_head *prev, struct list_head *next)
85621 {
85622 - WARN(next->prev != prev,
85623 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85624 - prev, next->prev, next);
85625 - WARN(prev->next != next,
85626 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85627 - next, prev->next, prev);
85628 + if (!__list_add_debug(new, prev, next))
85629 + return;
85630 +
85631 new->next = next;
85632 new->prev = prev;
85633 rcu_assign_pointer(list_next_rcu(prev), new);
85634 next->prev = new;
85635 }
85636 EXPORT_SYMBOL(__list_add_rcu);
85637 +#endif
85638 +
85639 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85640 +{
85641 +#ifdef CONFIG_DEBUG_LIST
85642 + if (!__list_add_debug(new, prev, next))
85643 + return;
85644 +#endif
85645 +
85646 + pax_open_kernel();
85647 + next->prev = new;
85648 + new->next = next;
85649 + new->prev = prev;
85650 + prev->next = new;
85651 + pax_close_kernel();
85652 +}
85653 +EXPORT_SYMBOL(__pax_list_add);
85654 +
85655 +void pax_list_del(struct list_head *entry)
85656 +{
85657 +#ifdef CONFIG_DEBUG_LIST
85658 + if (!__list_del_entry_debug(entry))
85659 + return;
85660 +#endif
85661 +
85662 + pax_open_kernel();
85663 + __list_del(entry->prev, entry->next);
85664 + entry->next = LIST_POISON1;
85665 + entry->prev = LIST_POISON2;
85666 + pax_close_kernel();
85667 +}
85668 +EXPORT_SYMBOL(pax_list_del);
85669 +
85670 +void pax_list_del_init(struct list_head *entry)
85671 +{
85672 + pax_open_kernel();
85673 + __list_del(entry->prev, entry->next);
85674 + INIT_LIST_HEAD(entry);
85675 + pax_close_kernel();
85676 +}
85677 +EXPORT_SYMBOL(pax_list_del_init);
85678 +
85679 +void __pax_list_add_rcu(struct list_head *new,
85680 + struct list_head *prev, struct list_head *next)
85681 +{
85682 +#ifdef CONFIG_DEBUG_LIST
85683 + if (!__list_add_debug(new, prev, next))
85684 + return;
85685 +#endif
85686 +
85687 + pax_open_kernel();
85688 + new->next = next;
85689 + new->prev = prev;
85690 + rcu_assign_pointer(list_next_rcu(prev), new);
85691 + next->prev = new;
85692 + pax_close_kernel();
85693 +}
85694 +EXPORT_SYMBOL(__pax_list_add_rcu);
85695 +
85696 +void pax_list_del_rcu(struct list_head *entry)
85697 +{
85698 +#ifdef CONFIG_DEBUG_LIST
85699 + if (!__list_del_entry_debug(entry))
85700 + return;
85701 +#endif
85702 +
85703 + pax_open_kernel();
85704 + __list_del(entry->prev, entry->next);
85705 + entry->next = LIST_POISON1;
85706 + entry->prev = LIST_POISON2;
85707 + pax_close_kernel();
85708 +}
85709 +EXPORT_SYMBOL(pax_list_del_rcu);
85710 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85711 index 7deeb62..144eb47 100644
85712 --- a/lib/percpu-refcount.c
85713 +++ b/lib/percpu-refcount.c
85714 @@ -29,7 +29,7 @@
85715 * can't hit 0 before we've added up all the percpu refs.
85716 */
85717
85718 -#define PCPU_COUNT_BIAS (1U << 31)
85719 +#define PCPU_COUNT_BIAS (1U << 30)
85720
85721 /**
85722 * percpu_ref_init - initialize a percpu refcount
85723 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85724 index e796429..6e38f9f 100644
85725 --- a/lib/radix-tree.c
85726 +++ b/lib/radix-tree.c
85727 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85728 int nr;
85729 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85730 };
85731 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85732 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85733
85734 static inline void *ptr_to_indirect(void *ptr)
85735 {
85736 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85737 index bb2b201..46abaf9 100644
85738 --- a/lib/strncpy_from_user.c
85739 +++ b/lib/strncpy_from_user.c
85740 @@ -21,7 +21,7 @@
85741 */
85742 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85743 {
85744 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85745 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85746 long res = 0;
85747
85748 /*
85749 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85750 index a28df52..3d55877 100644
85751 --- a/lib/strnlen_user.c
85752 +++ b/lib/strnlen_user.c
85753 @@ -26,7 +26,7 @@
85754 */
85755 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85756 {
85757 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85758 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85759 long align, res = 0;
85760 unsigned long c;
85761
85762 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85763 index d23762e..e21eab2 100644
85764 --- a/lib/swiotlb.c
85765 +++ b/lib/swiotlb.c
85766 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85767
85768 void
85769 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85770 - dma_addr_t dev_addr)
85771 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85772 {
85773 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85774
85775 diff --git a/lib/usercopy.c b/lib/usercopy.c
85776 index 4f5b1dd..7cab418 100644
85777 --- a/lib/usercopy.c
85778 +++ b/lib/usercopy.c
85779 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85780 WARN(1, "Buffer overflow detected!\n");
85781 }
85782 EXPORT_SYMBOL(copy_from_user_overflow);
85783 +
85784 +void copy_to_user_overflow(void)
85785 +{
85786 + WARN(1, "Buffer overflow detected!\n");
85787 +}
85788 +EXPORT_SYMBOL(copy_to_user_overflow);
85789 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85790 index 739a363..aa668d7 100644
85791 --- a/lib/vsprintf.c
85792 +++ b/lib/vsprintf.c
85793 @@ -16,6 +16,9 @@
85794 * - scnprintf and vscnprintf
85795 */
85796
85797 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85798 +#define __INCLUDED_BY_HIDESYM 1
85799 +#endif
85800 #include <stdarg.h>
85801 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85802 #include <linux/types.h>
85803 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85804 return number(buf, end, *(const netdev_features_t *)addr, spec);
85805 }
85806
85807 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85808 +int kptr_restrict __read_mostly = 2;
85809 +#else
85810 int kptr_restrict __read_mostly;
85811 +#endif
85812
85813 /*
85814 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85815 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85816 * - 'f' For simple symbolic function names without offset
85817 * - 'S' For symbolic direct pointers with offset
85818 * - 's' For symbolic direct pointers without offset
85819 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85820 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85821 * - 'B' For backtraced symbolic direct pointers with offset
85822 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85823 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85824
85825 if (!ptr && *fmt != 'K') {
85826 /*
85827 - * Print (null) with the same width as a pointer so it makes
85828 + * Print (nil) with the same width as a pointer so it makes
85829 * tabular output look nice.
85830 */
85831 if (spec.field_width == -1)
85832 spec.field_width = default_width;
85833 - return string(buf, end, "(null)", spec);
85834 + return string(buf, end, "(nil)", spec);
85835 }
85836
85837 switch (*fmt) {
85838 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85839 /* Fallthrough */
85840 case 'S':
85841 case 's':
85842 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85843 + break;
85844 +#else
85845 + return symbol_string(buf, end, ptr, spec, fmt);
85846 +#endif
85847 + case 'A':
85848 case 'B':
85849 return symbol_string(buf, end, ptr, spec, fmt);
85850 case 'R':
85851 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85852 va_end(va);
85853 return buf;
85854 }
85855 + case 'P':
85856 + break;
85857 case 'K':
85858 /*
85859 * %pK cannot be used in IRQ context because its test
85860 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85861 return number(buf, end,
85862 (unsigned long long) *((phys_addr_t *)ptr), spec);
85863 }
85864 +
85865 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85866 + /* 'P' = approved pointers to copy to userland,
85867 + as in the /proc/kallsyms case, as we make it display nothing
85868 + for non-root users, and the real contents for root users
85869 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85870 + above
85871 + */
85872 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85873 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85874 + dump_stack();
85875 + ptr = NULL;
85876 + }
85877 +#endif
85878 +
85879 spec.flags |= SMALL;
85880 if (spec.field_width == -1) {
85881 spec.field_width = default_width;
85882 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85883 typeof(type) value; \
85884 if (sizeof(type) == 8) { \
85885 args = PTR_ALIGN(args, sizeof(u32)); \
85886 - *(u32 *)&value = *(u32 *)args; \
85887 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85888 + *(u32 *)&value = *(const u32 *)args; \
85889 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85890 } else { \
85891 args = PTR_ALIGN(args, sizeof(type)); \
85892 - value = *(typeof(type) *)args; \
85893 + value = *(const typeof(type) *)args; \
85894 } \
85895 args += sizeof(type); \
85896 value; \
85897 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85898 case FORMAT_TYPE_STR: {
85899 const char *str_arg = args;
85900 args += strlen(str_arg) + 1;
85901 - str = string(str, end, (char *)str_arg, spec);
85902 + str = string(str, end, str_arg, spec);
85903 break;
85904 }
85905
85906 diff --git a/localversion-grsec b/localversion-grsec
85907 new file mode 100644
85908 index 0000000..7cd6065
85909 --- /dev/null
85910 +++ b/localversion-grsec
85911 @@ -0,0 +1 @@
85912 +-grsec
85913 diff --git a/mm/Kconfig b/mm/Kconfig
85914 index 6509d27..dbec5b8 100644
85915 --- a/mm/Kconfig
85916 +++ b/mm/Kconfig
85917 @@ -317,10 +317,10 @@ config KSM
85918 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85919
85920 config DEFAULT_MMAP_MIN_ADDR
85921 - int "Low address space to protect from user allocation"
85922 + int "Low address space to protect from user allocation"
85923 depends on MMU
85924 - default 4096
85925 - help
85926 + default 65536
85927 + help
85928 This is the portion of low virtual memory which should be protected
85929 from userspace allocation. Keeping a user from writing to low pages
85930 can help reduce the impact of kernel NULL pointer bugs.
85931 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
85932
85933 config HWPOISON_INJECT
85934 tristate "HWPoison pages injector"
85935 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85936 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85937 select PROC_PAGE_MONITOR
85938
85939 config NOMMU_INITIAL_TRIM_EXCESS
85940 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85941 index e04454c..ca5be3e 100644
85942 --- a/mm/backing-dev.c
85943 +++ b/mm/backing-dev.c
85944 @@ -12,7 +12,7 @@
85945 #include <linux/device.h>
85946 #include <trace/events/writeback.h>
85947
85948 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85949 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85950
85951 struct backing_dev_info default_backing_dev_info = {
85952 .name = "default",
85953 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85954 return err;
85955
85956 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85957 - atomic_long_inc_return(&bdi_seq));
85958 + atomic_long_inc_return_unchecked(&bdi_seq));
85959 if (err) {
85960 bdi_destroy(bdi);
85961 return err;
85962 diff --git a/mm/filemap.c b/mm/filemap.c
85963 index 4b51ac1..5aa90ff 100644
85964 --- a/mm/filemap.c
85965 +++ b/mm/filemap.c
85966 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85967 struct address_space *mapping = file->f_mapping;
85968
85969 if (!mapping->a_ops->readpage)
85970 - return -ENOEXEC;
85971 + return -ENODEV;
85972 file_accessed(file);
85973 vma->vm_ops = &generic_file_vm_ops;
85974 return 0;
85975 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
85976
85977 while (bytes) {
85978 char __user *buf = iov->iov_base + base;
85979 - int copy = min(bytes, iov->iov_len - base);
85980 + size_t copy = min(bytes, iov->iov_len - base);
85981
85982 base = 0;
85983 left = __copy_from_user_inatomic(vaddr, buf, copy);
85984 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
85985 BUG_ON(!in_atomic());
85986 kaddr = kmap_atomic(page);
85987 if (likely(i->nr_segs == 1)) {
85988 - int left;
85989 + size_t left;
85990 char __user *buf = i->iov->iov_base + i->iov_offset;
85991 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
85992 copied = bytes - left;
85993 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
85994
85995 kaddr = kmap(page);
85996 if (likely(i->nr_segs == 1)) {
85997 - int left;
85998 + size_t left;
85999 char __user *buf = i->iov->iov_base + i->iov_offset;
86000 left = __copy_from_user(kaddr + offset, buf, bytes);
86001 copied = bytes - left;
86002 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
86003 * zero-length segments (without overruning the iovec).
86004 */
86005 while (bytes || unlikely(i->count && !iov->iov_len)) {
86006 - int copy;
86007 + size_t copy;
86008
86009 copy = min(bytes, iov->iov_len - base);
86010 BUG_ON(!i->count || i->count < copy);
86011 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
86012 *pos = i_size_read(inode);
86013
86014 if (limit != RLIM_INFINITY) {
86015 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
86016 if (*pos >= limit) {
86017 send_sig(SIGXFSZ, current, 0);
86018 return -EFBIG;
86019 diff --git a/mm/fremap.c b/mm/fremap.c
86020 index 5bff081..d8189a9 100644
86021 --- a/mm/fremap.c
86022 +++ b/mm/fremap.c
86023 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
86024 retry:
86025 vma = find_vma(mm, start);
86026
86027 +#ifdef CONFIG_PAX_SEGMEXEC
86028 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
86029 + goto out;
86030 +#endif
86031 +
86032 /*
86033 * Make sure the vma is shared, that it supports prefaulting,
86034 * and that the remapped range is valid and fully within
86035 diff --git a/mm/highmem.c b/mm/highmem.c
86036 index b32b70c..e512eb0 100644
86037 --- a/mm/highmem.c
86038 +++ b/mm/highmem.c
86039 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
86040 * So no dangers, even with speculative execution.
86041 */
86042 page = pte_page(pkmap_page_table[i]);
86043 + pax_open_kernel();
86044 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
86045 -
86046 + pax_close_kernel();
86047 set_page_address(page, NULL);
86048 need_flush = 1;
86049 }
86050 @@ -198,9 +199,11 @@ start:
86051 }
86052 }
86053 vaddr = PKMAP_ADDR(last_pkmap_nr);
86054 +
86055 + pax_open_kernel();
86056 set_pte_at(&init_mm, vaddr,
86057 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86058 -
86059 + pax_close_kernel();
86060 pkmap_count[last_pkmap_nr] = 1;
86061 set_page_address(page, (void *)vaddr);
86062
86063 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86064 index b60f330..ee7de7e 100644
86065 --- a/mm/hugetlb.c
86066 +++ b/mm/hugetlb.c
86067 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86068 struct hstate *h = &default_hstate;
86069 unsigned long tmp;
86070 int ret;
86071 + ctl_table_no_const hugetlb_table;
86072
86073 tmp = h->max_huge_pages;
86074
86075 if (write && h->order >= MAX_ORDER)
86076 return -EINVAL;
86077
86078 - table->data = &tmp;
86079 - table->maxlen = sizeof(unsigned long);
86080 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86081 + hugetlb_table = *table;
86082 + hugetlb_table.data = &tmp;
86083 + hugetlb_table.maxlen = sizeof(unsigned long);
86084 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86085 if (ret)
86086 goto out;
86087
86088 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86089 struct hstate *h = &default_hstate;
86090 unsigned long tmp;
86091 int ret;
86092 + ctl_table_no_const hugetlb_table;
86093
86094 tmp = h->nr_overcommit_huge_pages;
86095
86096 if (write && h->order >= MAX_ORDER)
86097 return -EINVAL;
86098
86099 - table->data = &tmp;
86100 - table->maxlen = sizeof(unsigned long);
86101 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86102 + hugetlb_table = *table;
86103 + hugetlb_table.data = &tmp;
86104 + hugetlb_table.maxlen = sizeof(unsigned long);
86105 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86106 if (ret)
86107 goto out;
86108
86109 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86110 return 1;
86111 }
86112
86113 +#ifdef CONFIG_PAX_SEGMEXEC
86114 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86115 +{
86116 + struct mm_struct *mm = vma->vm_mm;
86117 + struct vm_area_struct *vma_m;
86118 + unsigned long address_m;
86119 + pte_t *ptep_m;
86120 +
86121 + vma_m = pax_find_mirror_vma(vma);
86122 + if (!vma_m)
86123 + return;
86124 +
86125 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86126 + address_m = address + SEGMEXEC_TASK_SIZE;
86127 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86128 + get_page(page_m);
86129 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86130 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86131 +}
86132 +#endif
86133 +
86134 /*
86135 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86136 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86137 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86138 make_huge_pte(vma, new_page, 1));
86139 page_remove_rmap(old_page);
86140 hugepage_add_new_anon_rmap(new_page, vma, address);
86141 +
86142 +#ifdef CONFIG_PAX_SEGMEXEC
86143 + pax_mirror_huge_pte(vma, address, new_page);
86144 +#endif
86145 +
86146 /* Make the old page be freed below */
86147 new_page = old_page;
86148 }
86149 @@ -2821,6 +2851,10 @@ retry:
86150 && (vma->vm_flags & VM_SHARED)));
86151 set_huge_pte_at(mm, address, ptep, new_pte);
86152
86153 +#ifdef CONFIG_PAX_SEGMEXEC
86154 + pax_mirror_huge_pte(vma, address, page);
86155 +#endif
86156 +
86157 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86158 /* Optimization, do the COW without a second fault */
86159 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86160 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86161 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86162 struct hstate *h = hstate_vma(vma);
86163
86164 +#ifdef CONFIG_PAX_SEGMEXEC
86165 + struct vm_area_struct *vma_m;
86166 +#endif
86167 +
86168 address &= huge_page_mask(h);
86169
86170 ptep = huge_pte_offset(mm, address);
86171 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86172 VM_FAULT_SET_HINDEX(hstate_index(h));
86173 }
86174
86175 +#ifdef CONFIG_PAX_SEGMEXEC
86176 + vma_m = pax_find_mirror_vma(vma);
86177 + if (vma_m) {
86178 + unsigned long address_m;
86179 +
86180 + if (vma->vm_start > vma_m->vm_start) {
86181 + address_m = address;
86182 + address -= SEGMEXEC_TASK_SIZE;
86183 + vma = vma_m;
86184 + h = hstate_vma(vma);
86185 + } else
86186 + address_m = address + SEGMEXEC_TASK_SIZE;
86187 +
86188 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86189 + return VM_FAULT_OOM;
86190 + address_m &= HPAGE_MASK;
86191 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86192 + }
86193 +#endif
86194 +
86195 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86196 if (!ptep)
86197 return VM_FAULT_OOM;
86198 diff --git a/mm/internal.h b/mm/internal.h
86199 index 4390ac6..fc60373c 100644
86200 --- a/mm/internal.h
86201 +++ b/mm/internal.h
86202 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86203 * in mm/page_alloc.c
86204 */
86205 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86206 +extern void free_compound_page(struct page *page);
86207 extern void prep_compound_page(struct page *page, unsigned long order);
86208 #ifdef CONFIG_MEMORY_FAILURE
86209 extern bool is_free_buddy_page(struct page *page);
86210 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86211
86212 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86213 unsigned long, unsigned long,
86214 - unsigned long, unsigned long);
86215 + unsigned long, unsigned long) __intentional_overflow(-1);
86216
86217 extern void set_pageblock_order(void);
86218 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86219 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86220 index c8d7f31..2dbeffd 100644
86221 --- a/mm/kmemleak.c
86222 +++ b/mm/kmemleak.c
86223 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86224
86225 for (i = 0; i < object->trace_len; i++) {
86226 void *ptr = (void *)object->trace[i];
86227 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86228 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86229 }
86230 }
86231
86232 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86233 return -ENOMEM;
86234 }
86235
86236 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86237 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86238 &kmemleak_fops);
86239 if (!dentry)
86240 pr_warning("Failed to create the debugfs kmemleak file\n");
86241 diff --git a/mm/maccess.c b/mm/maccess.c
86242 index d53adf9..03a24bf 100644
86243 --- a/mm/maccess.c
86244 +++ b/mm/maccess.c
86245 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86246 set_fs(KERNEL_DS);
86247 pagefault_disable();
86248 ret = __copy_from_user_inatomic(dst,
86249 - (__force const void __user *)src, size);
86250 + (const void __force_user *)src, size);
86251 pagefault_enable();
86252 set_fs(old_fs);
86253
86254 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86255
86256 set_fs(KERNEL_DS);
86257 pagefault_disable();
86258 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86259 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86260 pagefault_enable();
86261 set_fs(old_fs);
86262
86263 diff --git a/mm/madvise.c b/mm/madvise.c
86264 index 7055883..aafb1ed 100644
86265 --- a/mm/madvise.c
86266 +++ b/mm/madvise.c
86267 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86268 pgoff_t pgoff;
86269 unsigned long new_flags = vma->vm_flags;
86270
86271 +#ifdef CONFIG_PAX_SEGMEXEC
86272 + struct vm_area_struct *vma_m;
86273 +#endif
86274 +
86275 switch (behavior) {
86276 case MADV_NORMAL:
86277 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86278 @@ -126,6 +130,13 @@ success:
86279 /*
86280 * vm_flags is protected by the mmap_sem held in write mode.
86281 */
86282 +
86283 +#ifdef CONFIG_PAX_SEGMEXEC
86284 + vma_m = pax_find_mirror_vma(vma);
86285 + if (vma_m)
86286 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86287 +#endif
86288 +
86289 vma->vm_flags = new_flags;
86290
86291 out:
86292 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86293 struct vm_area_struct ** prev,
86294 unsigned long start, unsigned long end)
86295 {
86296 +
86297 +#ifdef CONFIG_PAX_SEGMEXEC
86298 + struct vm_area_struct *vma_m;
86299 +#endif
86300 +
86301 *prev = vma;
86302 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86303 return -EINVAL;
86304 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86305 zap_page_range(vma, start, end - start, &details);
86306 } else
86307 zap_page_range(vma, start, end - start, NULL);
86308 +
86309 +#ifdef CONFIG_PAX_SEGMEXEC
86310 + vma_m = pax_find_mirror_vma(vma);
86311 + if (vma_m) {
86312 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86313 + struct zap_details details = {
86314 + .nonlinear_vma = vma_m,
86315 + .last_index = ULONG_MAX,
86316 + };
86317 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86318 + } else
86319 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86320 + }
86321 +#endif
86322 +
86323 return 0;
86324 }
86325
86326 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86327 if (end < start)
86328 return error;
86329
86330 +#ifdef CONFIG_PAX_SEGMEXEC
86331 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86332 + if (end > SEGMEXEC_TASK_SIZE)
86333 + return error;
86334 + } else
86335 +#endif
86336 +
86337 + if (end > TASK_SIZE)
86338 + return error;
86339 +
86340 error = 0;
86341 if (end == start)
86342 return error;
86343 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
86344 index aa44621..99011b3 100644
86345 --- a/mm/memcontrol.c
86346 +++ b/mm/memcontrol.c
86347 @@ -2772,6 +2772,8 @@ done:
86348 return 0;
86349 nomem:
86350 *ptr = NULL;
86351 + if (gfp_mask & __GFP_NOFAIL)
86352 + return 0;
86353 return -ENOMEM;
86354 bypass:
86355 *ptr = root_mem_cgroup;
86356 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86357 index 2c13aa7..64cbc3f 100644
86358 --- a/mm/memory-failure.c
86359 +++ b/mm/memory-failure.c
86360 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86361
86362 int sysctl_memory_failure_recovery __read_mostly = 1;
86363
86364 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86365 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86366
86367 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86368
86369 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86370 pfn, t->comm, t->pid);
86371 si.si_signo = SIGBUS;
86372 si.si_errno = 0;
86373 - si.si_addr = (void *)addr;
86374 + si.si_addr = (void __user *)addr;
86375 #ifdef __ARCH_SI_TRAPNO
86376 si.si_trapno = trapno;
86377 #endif
86378 @@ -760,7 +760,7 @@ static struct page_state {
86379 unsigned long res;
86380 char *msg;
86381 int (*action)(struct page *p, unsigned long pfn);
86382 -} error_states[] = {
86383 +} __do_const error_states[] = {
86384 { reserved, reserved, "reserved kernel", me_kernel },
86385 /*
86386 * free pages are specially detected outside this table:
86387 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86388 nr_pages = 1 << compound_order(hpage);
86389 else /* normal page or thp */
86390 nr_pages = 1;
86391 - atomic_long_add(nr_pages, &num_poisoned_pages);
86392 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86393
86394 /*
86395 * We need/can do nothing about count=0 pages.
86396 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86397 if (!PageHWPoison(hpage)
86398 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86399 || (p != hpage && TestSetPageHWPoison(hpage))) {
86400 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86401 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86402 return 0;
86403 }
86404 set_page_hwpoison_huge_page(hpage);
86405 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86406 }
86407 if (hwpoison_filter(p)) {
86408 if (TestClearPageHWPoison(p))
86409 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86410 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86411 unlock_page(hpage);
86412 put_page(hpage);
86413 return 0;
86414 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86415 return 0;
86416 }
86417 if (TestClearPageHWPoison(p))
86418 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86419 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86420 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86421 return 0;
86422 }
86423 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86424 */
86425 if (TestClearPageHWPoison(page)) {
86426 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86427 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86428 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86429 freeit = 1;
86430 if (PageHuge(page))
86431 clear_page_hwpoison_huge_page(page);
86432 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86433 } else {
86434 set_page_hwpoison_huge_page(hpage);
86435 dequeue_hwpoisoned_huge_page(hpage);
86436 - atomic_long_add(1 << compound_trans_order(hpage),
86437 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86438 &num_poisoned_pages);
86439 }
86440 return ret;
86441 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86442 if (PageHuge(page)) {
86443 set_page_hwpoison_huge_page(hpage);
86444 dequeue_hwpoisoned_huge_page(hpage);
86445 - atomic_long_add(1 << compound_trans_order(hpage),
86446 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86447 &num_poisoned_pages);
86448 } else {
86449 SetPageHWPoison(page);
86450 - atomic_long_inc(&num_poisoned_pages);
86451 + atomic_long_inc_unchecked(&num_poisoned_pages);
86452 }
86453 }
86454 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86455 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86456 put_page(page);
86457 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86458 SetPageHWPoison(page);
86459 - atomic_long_inc(&num_poisoned_pages);
86460 + atomic_long_inc_unchecked(&num_poisoned_pages);
86461 return 0;
86462 }
86463
86464 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86465 if (!is_free_buddy_page(page))
86466 pr_info("soft offline: %#lx: page leaked\n",
86467 pfn);
86468 - atomic_long_inc(&num_poisoned_pages);
86469 + atomic_long_inc_unchecked(&num_poisoned_pages);
86470 }
86471 } else {
86472 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86473 diff --git a/mm/memory.c b/mm/memory.c
86474 index af84bc0..2ed0816 100644
86475 --- a/mm/memory.c
86476 +++ b/mm/memory.c
86477 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86478 free_pte_range(tlb, pmd, addr);
86479 } while (pmd++, addr = next, addr != end);
86480
86481 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86482 start &= PUD_MASK;
86483 if (start < floor)
86484 return;
86485 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86486 pmd = pmd_offset(pud, start);
86487 pud_clear(pud);
86488 pmd_free_tlb(tlb, pmd, start);
86489 +#endif
86490 +
86491 }
86492
86493 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86494 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86495 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86496 } while (pud++, addr = next, addr != end);
86497
86498 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86499 start &= PGDIR_MASK;
86500 if (start < floor)
86501 return;
86502 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86503 pud = pud_offset(pgd, start);
86504 pgd_clear(pgd);
86505 pud_free_tlb(tlb, pud, start);
86506 +#endif
86507 +
86508 }
86509
86510 /*
86511 @@ -1645,12 +1651,6 @@ no_page_table:
86512 return page;
86513 }
86514
86515 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86516 -{
86517 - return stack_guard_page_start(vma, addr) ||
86518 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86519 -}
86520 -
86521 /**
86522 * __get_user_pages() - pin user pages in memory
86523 * @tsk: task_struct of target task
86524 @@ -1737,10 +1737,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86525
86526 i = 0;
86527
86528 - do {
86529 + while (nr_pages) {
86530 struct vm_area_struct *vma;
86531
86532 - vma = find_extend_vma(mm, start);
86533 + vma = find_vma(mm, start);
86534 if (!vma && in_gate_area(mm, start)) {
86535 unsigned long pg = start & PAGE_MASK;
86536 pgd_t *pgd;
86537 @@ -1789,7 +1789,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86538 goto next_page;
86539 }
86540
86541 - if (!vma ||
86542 + if (!vma || start < vma->vm_start ||
86543 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86544 !(vm_flags & vma->vm_flags))
86545 return i ? : -EFAULT;
86546 @@ -1818,11 +1818,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86547 int ret;
86548 unsigned int fault_flags = 0;
86549
86550 - /* For mlock, just skip the stack guard page. */
86551 - if (foll_flags & FOLL_MLOCK) {
86552 - if (stack_guard_page(vma, start))
86553 - goto next_page;
86554 - }
86555 if (foll_flags & FOLL_WRITE)
86556 fault_flags |= FAULT_FLAG_WRITE;
86557 if (nonblocking)
86558 @@ -1902,7 +1897,7 @@ next_page:
86559 start += page_increm * PAGE_SIZE;
86560 nr_pages -= page_increm;
86561 } while (nr_pages && start < vma->vm_end);
86562 - } while (nr_pages);
86563 + }
86564 return i;
86565 }
86566 EXPORT_SYMBOL(__get_user_pages);
86567 @@ -2109,6 +2104,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86568 page_add_file_rmap(page);
86569 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86570
86571 +#ifdef CONFIG_PAX_SEGMEXEC
86572 + pax_mirror_file_pte(vma, addr, page, ptl);
86573 +#endif
86574 +
86575 retval = 0;
86576 pte_unmap_unlock(pte, ptl);
86577 return retval;
86578 @@ -2153,9 +2152,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86579 if (!page_count(page))
86580 return -EINVAL;
86581 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86582 +
86583 +#ifdef CONFIG_PAX_SEGMEXEC
86584 + struct vm_area_struct *vma_m;
86585 +#endif
86586 +
86587 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86588 BUG_ON(vma->vm_flags & VM_PFNMAP);
86589 vma->vm_flags |= VM_MIXEDMAP;
86590 +
86591 +#ifdef CONFIG_PAX_SEGMEXEC
86592 + vma_m = pax_find_mirror_vma(vma);
86593 + if (vma_m)
86594 + vma_m->vm_flags |= VM_MIXEDMAP;
86595 +#endif
86596 +
86597 }
86598 return insert_page(vma, addr, page, vma->vm_page_prot);
86599 }
86600 @@ -2238,6 +2249,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86601 unsigned long pfn)
86602 {
86603 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86604 + BUG_ON(vma->vm_mirror);
86605
86606 if (addr < vma->vm_start || addr >= vma->vm_end)
86607 return -EFAULT;
86608 @@ -2485,7 +2497,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86609
86610 BUG_ON(pud_huge(*pud));
86611
86612 - pmd = pmd_alloc(mm, pud, addr);
86613 + pmd = (mm == &init_mm) ?
86614 + pmd_alloc_kernel(mm, pud, addr) :
86615 + pmd_alloc(mm, pud, addr);
86616 if (!pmd)
86617 return -ENOMEM;
86618 do {
86619 @@ -2505,7 +2519,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86620 unsigned long next;
86621 int err;
86622
86623 - pud = pud_alloc(mm, pgd, addr);
86624 + pud = (mm == &init_mm) ?
86625 + pud_alloc_kernel(mm, pgd, addr) :
86626 + pud_alloc(mm, pgd, addr);
86627 if (!pud)
86628 return -ENOMEM;
86629 do {
86630 @@ -2593,6 +2609,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86631 copy_user_highpage(dst, src, va, vma);
86632 }
86633
86634 +#ifdef CONFIG_PAX_SEGMEXEC
86635 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86636 +{
86637 + struct mm_struct *mm = vma->vm_mm;
86638 + spinlock_t *ptl;
86639 + pte_t *pte, entry;
86640 +
86641 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86642 + entry = *pte;
86643 + if (!pte_present(entry)) {
86644 + if (!pte_none(entry)) {
86645 + BUG_ON(pte_file(entry));
86646 + free_swap_and_cache(pte_to_swp_entry(entry));
86647 + pte_clear_not_present_full(mm, address, pte, 0);
86648 + }
86649 + } else {
86650 + struct page *page;
86651 +
86652 + flush_cache_page(vma, address, pte_pfn(entry));
86653 + entry = ptep_clear_flush(vma, address, pte);
86654 + BUG_ON(pte_dirty(entry));
86655 + page = vm_normal_page(vma, address, entry);
86656 + if (page) {
86657 + update_hiwater_rss(mm);
86658 + if (PageAnon(page))
86659 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86660 + else
86661 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86662 + page_remove_rmap(page);
86663 + page_cache_release(page);
86664 + }
86665 + }
86666 + pte_unmap_unlock(pte, ptl);
86667 +}
86668 +
86669 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86670 + *
86671 + * the ptl of the lower mapped page is held on entry and is not released on exit
86672 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86673 + */
86674 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86675 +{
86676 + struct mm_struct *mm = vma->vm_mm;
86677 + unsigned long address_m;
86678 + spinlock_t *ptl_m;
86679 + struct vm_area_struct *vma_m;
86680 + pmd_t *pmd_m;
86681 + pte_t *pte_m, entry_m;
86682 +
86683 + BUG_ON(!page_m || !PageAnon(page_m));
86684 +
86685 + vma_m = pax_find_mirror_vma(vma);
86686 + if (!vma_m)
86687 + return;
86688 +
86689 + BUG_ON(!PageLocked(page_m));
86690 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86691 + address_m = address + SEGMEXEC_TASK_SIZE;
86692 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86693 + pte_m = pte_offset_map(pmd_m, address_m);
86694 + ptl_m = pte_lockptr(mm, pmd_m);
86695 + if (ptl != ptl_m) {
86696 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86697 + if (!pte_none(*pte_m))
86698 + goto out;
86699 + }
86700 +
86701 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86702 + page_cache_get(page_m);
86703 + page_add_anon_rmap(page_m, vma_m, address_m);
86704 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86705 + set_pte_at(mm, address_m, pte_m, entry_m);
86706 + update_mmu_cache(vma_m, address_m, pte_m);
86707 +out:
86708 + if (ptl != ptl_m)
86709 + spin_unlock(ptl_m);
86710 + pte_unmap(pte_m);
86711 + unlock_page(page_m);
86712 +}
86713 +
86714 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86715 +{
86716 + struct mm_struct *mm = vma->vm_mm;
86717 + unsigned long address_m;
86718 + spinlock_t *ptl_m;
86719 + struct vm_area_struct *vma_m;
86720 + pmd_t *pmd_m;
86721 + pte_t *pte_m, entry_m;
86722 +
86723 + BUG_ON(!page_m || PageAnon(page_m));
86724 +
86725 + vma_m = pax_find_mirror_vma(vma);
86726 + if (!vma_m)
86727 + return;
86728 +
86729 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86730 + address_m = address + SEGMEXEC_TASK_SIZE;
86731 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86732 + pte_m = pte_offset_map(pmd_m, address_m);
86733 + ptl_m = pte_lockptr(mm, pmd_m);
86734 + if (ptl != ptl_m) {
86735 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86736 + if (!pte_none(*pte_m))
86737 + goto out;
86738 + }
86739 +
86740 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86741 + page_cache_get(page_m);
86742 + page_add_file_rmap(page_m);
86743 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86744 + set_pte_at(mm, address_m, pte_m, entry_m);
86745 + update_mmu_cache(vma_m, address_m, pte_m);
86746 +out:
86747 + if (ptl != ptl_m)
86748 + spin_unlock(ptl_m);
86749 + pte_unmap(pte_m);
86750 +}
86751 +
86752 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86753 +{
86754 + struct mm_struct *mm = vma->vm_mm;
86755 + unsigned long address_m;
86756 + spinlock_t *ptl_m;
86757 + struct vm_area_struct *vma_m;
86758 + pmd_t *pmd_m;
86759 + pte_t *pte_m, entry_m;
86760 +
86761 + vma_m = pax_find_mirror_vma(vma);
86762 + if (!vma_m)
86763 + return;
86764 +
86765 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86766 + address_m = address + SEGMEXEC_TASK_SIZE;
86767 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86768 + pte_m = pte_offset_map(pmd_m, address_m);
86769 + ptl_m = pte_lockptr(mm, pmd_m);
86770 + if (ptl != ptl_m) {
86771 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86772 + if (!pte_none(*pte_m))
86773 + goto out;
86774 + }
86775 +
86776 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86777 + set_pte_at(mm, address_m, pte_m, entry_m);
86778 +out:
86779 + if (ptl != ptl_m)
86780 + spin_unlock(ptl_m);
86781 + pte_unmap(pte_m);
86782 +}
86783 +
86784 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86785 +{
86786 + struct page *page_m;
86787 + pte_t entry;
86788 +
86789 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86790 + goto out;
86791 +
86792 + entry = *pte;
86793 + page_m = vm_normal_page(vma, address, entry);
86794 + if (!page_m)
86795 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86796 + else if (PageAnon(page_m)) {
86797 + if (pax_find_mirror_vma(vma)) {
86798 + pte_unmap_unlock(pte, ptl);
86799 + lock_page(page_m);
86800 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86801 + if (pte_same(entry, *pte))
86802 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86803 + else
86804 + unlock_page(page_m);
86805 + }
86806 + } else
86807 + pax_mirror_file_pte(vma, address, page_m, ptl);
86808 +
86809 +out:
86810 + pte_unmap_unlock(pte, ptl);
86811 +}
86812 +#endif
86813 +
86814 /*
86815 * This routine handles present pages, when users try to write
86816 * to a shared page. It is done by copying the page to a new address
86817 @@ -2809,6 +3005,12 @@ gotten:
86818 */
86819 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86820 if (likely(pte_same(*page_table, orig_pte))) {
86821 +
86822 +#ifdef CONFIG_PAX_SEGMEXEC
86823 + if (pax_find_mirror_vma(vma))
86824 + BUG_ON(!trylock_page(new_page));
86825 +#endif
86826 +
86827 if (old_page) {
86828 if (!PageAnon(old_page)) {
86829 dec_mm_counter_fast(mm, MM_FILEPAGES);
86830 @@ -2860,6 +3062,10 @@ gotten:
86831 page_remove_rmap(old_page);
86832 }
86833
86834 +#ifdef CONFIG_PAX_SEGMEXEC
86835 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86836 +#endif
86837 +
86838 /* Free the old page.. */
86839 new_page = old_page;
86840 ret |= VM_FAULT_WRITE;
86841 @@ -3137,6 +3343,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86842 swap_free(entry);
86843 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86844 try_to_free_swap(page);
86845 +
86846 +#ifdef CONFIG_PAX_SEGMEXEC
86847 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86848 +#endif
86849 +
86850 unlock_page(page);
86851 if (page != swapcache) {
86852 /*
86853 @@ -3160,6 +3371,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86854
86855 /* No need to invalidate - it was non-present before */
86856 update_mmu_cache(vma, address, page_table);
86857 +
86858 +#ifdef CONFIG_PAX_SEGMEXEC
86859 + pax_mirror_anon_pte(vma, address, page, ptl);
86860 +#endif
86861 +
86862 unlock:
86863 pte_unmap_unlock(page_table, ptl);
86864 out:
86865 @@ -3179,40 +3395,6 @@ out_release:
86866 }
86867
86868 /*
86869 - * This is like a special single-page "expand_{down|up}wards()",
86870 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86871 - * doesn't hit another vma.
86872 - */
86873 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86874 -{
86875 - address &= PAGE_MASK;
86876 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86877 - struct vm_area_struct *prev = vma->vm_prev;
86878 -
86879 - /*
86880 - * Is there a mapping abutting this one below?
86881 - *
86882 - * That's only ok if it's the same stack mapping
86883 - * that has gotten split..
86884 - */
86885 - if (prev && prev->vm_end == address)
86886 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86887 -
86888 - expand_downwards(vma, address - PAGE_SIZE);
86889 - }
86890 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86891 - struct vm_area_struct *next = vma->vm_next;
86892 -
86893 - /* As VM_GROWSDOWN but s/below/above/ */
86894 - if (next && next->vm_start == address + PAGE_SIZE)
86895 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86896 -
86897 - expand_upwards(vma, address + PAGE_SIZE);
86898 - }
86899 - return 0;
86900 -}
86901 -
86902 -/*
86903 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86904 * but allow concurrent faults), and pte mapped but not yet locked.
86905 * We return with mmap_sem still held, but pte unmapped and unlocked.
86906 @@ -3221,27 +3403,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86907 unsigned long address, pte_t *page_table, pmd_t *pmd,
86908 unsigned int flags)
86909 {
86910 - struct page *page;
86911 + struct page *page = NULL;
86912 spinlock_t *ptl;
86913 pte_t entry;
86914
86915 - pte_unmap(page_table);
86916 -
86917 - /* Check if we need to add a guard page to the stack */
86918 - if (check_stack_guard_page(vma, address) < 0)
86919 - return VM_FAULT_SIGBUS;
86920 -
86921 - /* Use the zero-page for reads */
86922 if (!(flags & FAULT_FLAG_WRITE)) {
86923 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86924 vma->vm_page_prot));
86925 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86926 + ptl = pte_lockptr(mm, pmd);
86927 + spin_lock(ptl);
86928 if (!pte_none(*page_table))
86929 goto unlock;
86930 goto setpte;
86931 }
86932
86933 /* Allocate our own private page. */
86934 + pte_unmap(page_table);
86935 +
86936 if (unlikely(anon_vma_prepare(vma)))
86937 goto oom;
86938 page = alloc_zeroed_user_highpage_movable(vma, address);
86939 @@ -3265,6 +3443,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86940 if (!pte_none(*page_table))
86941 goto release;
86942
86943 +#ifdef CONFIG_PAX_SEGMEXEC
86944 + if (pax_find_mirror_vma(vma))
86945 + BUG_ON(!trylock_page(page));
86946 +#endif
86947 +
86948 inc_mm_counter_fast(mm, MM_ANONPAGES);
86949 page_add_new_anon_rmap(page, vma, address);
86950 setpte:
86951 @@ -3272,6 +3455,12 @@ setpte:
86952
86953 /* No need to invalidate - it was non-present before */
86954 update_mmu_cache(vma, address, page_table);
86955 +
86956 +#ifdef CONFIG_PAX_SEGMEXEC
86957 + if (page)
86958 + pax_mirror_anon_pte(vma, address, page, ptl);
86959 +#endif
86960 +
86961 unlock:
86962 pte_unmap_unlock(page_table, ptl);
86963 return 0;
86964 @@ -3415,6 +3604,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86965 */
86966 /* Only go through if we didn't race with anybody else... */
86967 if (likely(pte_same(*page_table, orig_pte))) {
86968 +
86969 +#ifdef CONFIG_PAX_SEGMEXEC
86970 + if (anon && pax_find_mirror_vma(vma))
86971 + BUG_ON(!trylock_page(page));
86972 +#endif
86973 +
86974 flush_icache_page(vma, page);
86975 entry = mk_pte(page, vma->vm_page_prot);
86976 if (flags & FAULT_FLAG_WRITE)
86977 @@ -3436,6 +3631,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86978
86979 /* no need to invalidate: a not-present page won't be cached */
86980 update_mmu_cache(vma, address, page_table);
86981 +
86982 +#ifdef CONFIG_PAX_SEGMEXEC
86983 + if (anon)
86984 + pax_mirror_anon_pte(vma, address, page, ptl);
86985 + else
86986 + pax_mirror_file_pte(vma, address, page, ptl);
86987 +#endif
86988 +
86989 } else {
86990 if (cow_page)
86991 mem_cgroup_uncharge_page(cow_page);
86992 @@ -3757,6 +3960,12 @@ int handle_pte_fault(struct mm_struct *mm,
86993 if (flags & FAULT_FLAG_WRITE)
86994 flush_tlb_fix_spurious_fault(vma, address);
86995 }
86996 +
86997 +#ifdef CONFIG_PAX_SEGMEXEC
86998 + pax_mirror_pte(vma, address, pte, pmd, ptl);
86999 + return 0;
87000 +#endif
87001 +
87002 unlock:
87003 pte_unmap_unlock(pte, ptl);
87004 return 0;
87005 @@ -3773,6 +3982,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87006 pmd_t *pmd;
87007 pte_t *pte;
87008
87009 +#ifdef CONFIG_PAX_SEGMEXEC
87010 + struct vm_area_struct *vma_m;
87011 +#endif
87012 +
87013 __set_current_state(TASK_RUNNING);
87014
87015 count_vm_event(PGFAULT);
87016 @@ -3784,6 +3997,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87017 if (unlikely(is_vm_hugetlb_page(vma)))
87018 return hugetlb_fault(mm, vma, address, flags);
87019
87020 +#ifdef CONFIG_PAX_SEGMEXEC
87021 + vma_m = pax_find_mirror_vma(vma);
87022 + if (vma_m) {
87023 + unsigned long address_m;
87024 + pgd_t *pgd_m;
87025 + pud_t *pud_m;
87026 + pmd_t *pmd_m;
87027 +
87028 + if (vma->vm_start > vma_m->vm_start) {
87029 + address_m = address;
87030 + address -= SEGMEXEC_TASK_SIZE;
87031 + vma = vma_m;
87032 + } else
87033 + address_m = address + SEGMEXEC_TASK_SIZE;
87034 +
87035 + pgd_m = pgd_offset(mm, address_m);
87036 + pud_m = pud_alloc(mm, pgd_m, address_m);
87037 + if (!pud_m)
87038 + return VM_FAULT_OOM;
87039 + pmd_m = pmd_alloc(mm, pud_m, address_m);
87040 + if (!pmd_m)
87041 + return VM_FAULT_OOM;
87042 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
87043 + return VM_FAULT_OOM;
87044 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
87045 + }
87046 +#endif
87047 +
87048 retry:
87049 pgd = pgd_offset(mm, address);
87050 pud = pud_alloc(mm, pgd, address);
87051 @@ -3882,6 +4123,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87052 spin_unlock(&mm->page_table_lock);
87053 return 0;
87054 }
87055 +
87056 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87057 +{
87058 + pud_t *new = pud_alloc_one(mm, address);
87059 + if (!new)
87060 + return -ENOMEM;
87061 +
87062 + smp_wmb(); /* See comment in __pte_alloc */
87063 +
87064 + spin_lock(&mm->page_table_lock);
87065 + if (pgd_present(*pgd)) /* Another has populated it */
87066 + pud_free(mm, new);
87067 + else
87068 + pgd_populate_kernel(mm, pgd, new);
87069 + spin_unlock(&mm->page_table_lock);
87070 + return 0;
87071 +}
87072 #endif /* __PAGETABLE_PUD_FOLDED */
87073
87074 #ifndef __PAGETABLE_PMD_FOLDED
87075 @@ -3912,6 +4170,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87076 spin_unlock(&mm->page_table_lock);
87077 return 0;
87078 }
87079 +
87080 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87081 +{
87082 + pmd_t *new = pmd_alloc_one(mm, address);
87083 + if (!new)
87084 + return -ENOMEM;
87085 +
87086 + smp_wmb(); /* See comment in __pte_alloc */
87087 +
87088 + spin_lock(&mm->page_table_lock);
87089 +#ifndef __ARCH_HAS_4LEVEL_HACK
87090 + if (pud_present(*pud)) /* Another has populated it */
87091 + pmd_free(mm, new);
87092 + else
87093 + pud_populate_kernel(mm, pud, new);
87094 +#else
87095 + if (pgd_present(*pud)) /* Another has populated it */
87096 + pmd_free(mm, new);
87097 + else
87098 + pgd_populate_kernel(mm, pud, new);
87099 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87100 + spin_unlock(&mm->page_table_lock);
87101 + return 0;
87102 +}
87103 #endif /* __PAGETABLE_PMD_FOLDED */
87104
87105 #if !defined(__HAVE_ARCH_GATE_AREA)
87106 @@ -3925,7 +4207,7 @@ static int __init gate_vma_init(void)
87107 gate_vma.vm_start = FIXADDR_USER_START;
87108 gate_vma.vm_end = FIXADDR_USER_END;
87109 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87110 - gate_vma.vm_page_prot = __P101;
87111 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87112
87113 return 0;
87114 }
87115 @@ -4059,8 +4341,8 @@ out:
87116 return ret;
87117 }
87118
87119 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87120 - void *buf, int len, int write)
87121 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87122 + void *buf, size_t len, int write)
87123 {
87124 resource_size_t phys_addr;
87125 unsigned long prot = 0;
87126 @@ -4085,8 +4367,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87127 * Access another process' address space as given in mm. If non-NULL, use the
87128 * given task for page fault accounting.
87129 */
87130 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87131 - unsigned long addr, void *buf, int len, int write)
87132 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87133 + unsigned long addr, void *buf, size_t len, int write)
87134 {
87135 struct vm_area_struct *vma;
87136 void *old_buf = buf;
87137 @@ -4094,7 +4376,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87138 down_read(&mm->mmap_sem);
87139 /* ignore errors, just check how much was successfully transferred */
87140 while (len) {
87141 - int bytes, ret, offset;
87142 + ssize_t bytes, ret, offset;
87143 void *maddr;
87144 struct page *page = NULL;
87145
87146 @@ -4153,8 +4435,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87147 *
87148 * The caller must hold a reference on @mm.
87149 */
87150 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87151 - void *buf, int len, int write)
87152 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87153 + void *buf, size_t len, int write)
87154 {
87155 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87156 }
87157 @@ -4164,11 +4446,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87158 * Source/target buffer must be kernel space,
87159 * Do not walk the page table directly, use get_user_pages
87160 */
87161 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87162 - void *buf, int len, int write)
87163 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87164 + void *buf, size_t len, int write)
87165 {
87166 struct mm_struct *mm;
87167 - int ret;
87168 + ssize_t ret;
87169
87170 mm = get_task_mm(tsk);
87171 if (!mm)
87172 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87173 index 4baf12e..5497066 100644
87174 --- a/mm/mempolicy.c
87175 +++ b/mm/mempolicy.c
87176 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87177 unsigned long vmstart;
87178 unsigned long vmend;
87179
87180 +#ifdef CONFIG_PAX_SEGMEXEC
87181 + struct vm_area_struct *vma_m;
87182 +#endif
87183 +
87184 vma = find_vma(mm, start);
87185 if (!vma || vma->vm_start > start)
87186 return -EFAULT;
87187 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87188 err = vma_replace_policy(vma, new_pol);
87189 if (err)
87190 goto out;
87191 +
87192 +#ifdef CONFIG_PAX_SEGMEXEC
87193 + vma_m = pax_find_mirror_vma(vma);
87194 + if (vma_m) {
87195 + err = vma_replace_policy(vma_m, new_pol);
87196 + if (err)
87197 + goto out;
87198 + }
87199 +#endif
87200 +
87201 }
87202
87203 out:
87204 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87205
87206 if (end < start)
87207 return -EINVAL;
87208 +
87209 +#ifdef CONFIG_PAX_SEGMEXEC
87210 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87211 + if (end > SEGMEXEC_TASK_SIZE)
87212 + return -EINVAL;
87213 + } else
87214 +#endif
87215 +
87216 + if (end > TASK_SIZE)
87217 + return -EINVAL;
87218 +
87219 if (end == start)
87220 return 0;
87221
87222 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87223 */
87224 tcred = __task_cred(task);
87225 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87226 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87227 - !capable(CAP_SYS_NICE)) {
87228 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87229 rcu_read_unlock();
87230 err = -EPERM;
87231 goto out_put;
87232 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87233 goto out;
87234 }
87235
87236 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87237 + if (mm != current->mm &&
87238 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87239 + mmput(mm);
87240 + err = -EPERM;
87241 + goto out;
87242 + }
87243 +#endif
87244 +
87245 err = do_migrate_pages(mm, old, new,
87246 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87247
87248 diff --git a/mm/migrate.c b/mm/migrate.c
87249 index 25ca7ca..abe1836 100644
87250 --- a/mm/migrate.c
87251 +++ b/mm/migrate.c
87252 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87253 */
87254 tcred = __task_cred(task);
87255 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87256 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87257 - !capable(CAP_SYS_NICE)) {
87258 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87259 rcu_read_unlock();
87260 err = -EPERM;
87261 goto out;
87262 diff --git a/mm/mlock.c b/mm/mlock.c
87263 index 79b7cf7..37472bf 100644
87264 --- a/mm/mlock.c
87265 +++ b/mm/mlock.c
87266 @@ -13,6 +13,7 @@
87267 #include <linux/pagemap.h>
87268 #include <linux/mempolicy.h>
87269 #include <linux/syscalls.h>
87270 +#include <linux/security.h>
87271 #include <linux/sched.h>
87272 #include <linux/export.h>
87273 #include <linux/rmap.h>
87274 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87275 {
87276 unsigned long nstart, end, tmp;
87277 struct vm_area_struct * vma, * prev;
87278 - int error;
87279 + int error = 0;
87280
87281 VM_BUG_ON(start & ~PAGE_MASK);
87282 VM_BUG_ON(len != PAGE_ALIGN(len));
87283 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87284 return -EINVAL;
87285 if (end == start)
87286 return 0;
87287 + if (end > TASK_SIZE)
87288 + return -EINVAL;
87289 +
87290 vma = find_vma(current->mm, start);
87291 if (!vma || vma->vm_start > start)
87292 return -ENOMEM;
87293 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87294 for (nstart = start ; ; ) {
87295 vm_flags_t newflags;
87296
87297 +#ifdef CONFIG_PAX_SEGMEXEC
87298 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87299 + break;
87300 +#endif
87301 +
87302 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87303
87304 newflags = vma->vm_flags & ~VM_LOCKED;
87305 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87306 lock_limit >>= PAGE_SHIFT;
87307
87308 /* check against resource limits */
87309 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87310 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87311 error = do_mlock(start, len, 1);
87312 up_write(&current->mm->mmap_sem);
87313 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87314 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87315 vm_flags_t newflags;
87316
87317 +#ifdef CONFIG_PAX_SEGMEXEC
87318 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87319 + break;
87320 +#endif
87321 +
87322 newflags = vma->vm_flags & ~VM_LOCKED;
87323 if (flags & MCL_CURRENT)
87324 newflags |= VM_LOCKED;
87325
87326 /* Ignore errors */
87327 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87328 + cond_resched();
87329 }
87330 out:
87331 return 0;
87332 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87333 lock_limit >>= PAGE_SHIFT;
87334
87335 ret = -ENOMEM;
87336 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87337 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87338 capable(CAP_IPC_LOCK))
87339 ret = do_mlockall(flags);
87340 diff --git a/mm/mmap.c b/mm/mmap.c
87341 index f9c97d1..3468d3b 100644
87342 --- a/mm/mmap.c
87343 +++ b/mm/mmap.c
87344 @@ -36,6 +36,7 @@
87345 #include <linux/sched/sysctl.h>
87346 #include <linux/notifier.h>
87347 #include <linux/memory.h>
87348 +#include <linux/random.h>
87349
87350 #include <asm/uaccess.h>
87351 #include <asm/cacheflush.h>
87352 @@ -52,6 +53,16 @@
87353 #define arch_rebalance_pgtables(addr, len) (addr)
87354 #endif
87355
87356 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87357 +{
87358 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87359 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87360 + up_read(&mm->mmap_sem);
87361 + BUG();
87362 + }
87363 +#endif
87364 +}
87365 +
87366 static void unmap_region(struct mm_struct *mm,
87367 struct vm_area_struct *vma, struct vm_area_struct *prev,
87368 unsigned long start, unsigned long end);
87369 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87370 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87371 *
87372 */
87373 -pgprot_t protection_map[16] = {
87374 +pgprot_t protection_map[16] __read_only = {
87375 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87376 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87377 };
87378
87379 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87380 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87381 {
87382 - return __pgprot(pgprot_val(protection_map[vm_flags &
87383 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87384 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87385 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87386 +
87387 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87388 + if (!(__supported_pte_mask & _PAGE_NX) &&
87389 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87390 + (vm_flags & (VM_READ | VM_WRITE)))
87391 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87392 +#endif
87393 +
87394 + return prot;
87395 }
87396 EXPORT_SYMBOL(vm_get_page_prot);
87397
87398 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87399 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87400 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87401 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87402 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87403 /*
87404 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87405 * other variables. It can be updated by several CPUs frequently.
87406 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87407 struct vm_area_struct *next = vma->vm_next;
87408
87409 might_sleep();
87410 + BUG_ON(vma->vm_mirror);
87411 if (vma->vm_ops && vma->vm_ops->close)
87412 vma->vm_ops->close(vma);
87413 if (vma->vm_file)
87414 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87415 * not page aligned -Ram Gupta
87416 */
87417 rlim = rlimit(RLIMIT_DATA);
87418 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87419 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87420 (mm->end_data - mm->start_data) > rlim)
87421 goto out;
87422 @@ -933,6 +956,12 @@ static int
87423 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87424 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87425 {
87426 +
87427 +#ifdef CONFIG_PAX_SEGMEXEC
87428 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87429 + return 0;
87430 +#endif
87431 +
87432 if (is_mergeable_vma(vma, file, vm_flags) &&
87433 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87434 if (vma->vm_pgoff == vm_pgoff)
87435 @@ -952,6 +981,12 @@ static int
87436 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87437 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87438 {
87439 +
87440 +#ifdef CONFIG_PAX_SEGMEXEC
87441 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87442 + return 0;
87443 +#endif
87444 +
87445 if (is_mergeable_vma(vma, file, vm_flags) &&
87446 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87447 pgoff_t vm_pglen;
87448 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87449 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87450 struct vm_area_struct *prev, unsigned long addr,
87451 unsigned long end, unsigned long vm_flags,
87452 - struct anon_vma *anon_vma, struct file *file,
87453 + struct anon_vma *anon_vma, struct file *file,
87454 pgoff_t pgoff, struct mempolicy *policy)
87455 {
87456 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87457 struct vm_area_struct *area, *next;
87458 int err;
87459
87460 +#ifdef CONFIG_PAX_SEGMEXEC
87461 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87462 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87463 +
87464 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87465 +#endif
87466 +
87467 /*
87468 * We later require that vma->vm_flags == vm_flags,
87469 * so this tests vma->vm_flags & VM_SPECIAL, too.
87470 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87471 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87472 next = next->vm_next;
87473
87474 +#ifdef CONFIG_PAX_SEGMEXEC
87475 + if (prev)
87476 + prev_m = pax_find_mirror_vma(prev);
87477 + if (area)
87478 + area_m = pax_find_mirror_vma(area);
87479 + if (next)
87480 + next_m = pax_find_mirror_vma(next);
87481 +#endif
87482 +
87483 /*
87484 * Can it merge with the predecessor?
87485 */
87486 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87487 /* cases 1, 6 */
87488 err = vma_adjust(prev, prev->vm_start,
87489 next->vm_end, prev->vm_pgoff, NULL);
87490 - } else /* cases 2, 5, 7 */
87491 +
87492 +#ifdef CONFIG_PAX_SEGMEXEC
87493 + if (!err && prev_m)
87494 + err = vma_adjust(prev_m, prev_m->vm_start,
87495 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87496 +#endif
87497 +
87498 + } else { /* cases 2, 5, 7 */
87499 err = vma_adjust(prev, prev->vm_start,
87500 end, prev->vm_pgoff, NULL);
87501 +
87502 +#ifdef CONFIG_PAX_SEGMEXEC
87503 + if (!err && prev_m)
87504 + err = vma_adjust(prev_m, prev_m->vm_start,
87505 + end_m, prev_m->vm_pgoff, NULL);
87506 +#endif
87507 +
87508 + }
87509 if (err)
87510 return NULL;
87511 khugepaged_enter_vma_merge(prev);
87512 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87513 mpol_equal(policy, vma_policy(next)) &&
87514 can_vma_merge_before(next, vm_flags,
87515 anon_vma, file, pgoff+pglen)) {
87516 - if (prev && addr < prev->vm_end) /* case 4 */
87517 + if (prev && addr < prev->vm_end) { /* case 4 */
87518 err = vma_adjust(prev, prev->vm_start,
87519 addr, prev->vm_pgoff, NULL);
87520 - else /* cases 3, 8 */
87521 +
87522 +#ifdef CONFIG_PAX_SEGMEXEC
87523 + if (!err && prev_m)
87524 + err = vma_adjust(prev_m, prev_m->vm_start,
87525 + addr_m, prev_m->vm_pgoff, NULL);
87526 +#endif
87527 +
87528 + } else { /* cases 3, 8 */
87529 err = vma_adjust(area, addr, next->vm_end,
87530 next->vm_pgoff - pglen, NULL);
87531 +
87532 +#ifdef CONFIG_PAX_SEGMEXEC
87533 + if (!err && area_m)
87534 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87535 + next_m->vm_pgoff - pglen, NULL);
87536 +#endif
87537 +
87538 + }
87539 if (err)
87540 return NULL;
87541 khugepaged_enter_vma_merge(area);
87542 @@ -1165,8 +1246,10 @@ none:
87543 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87544 struct file *file, long pages)
87545 {
87546 - const unsigned long stack_flags
87547 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87548 +
87549 +#ifdef CONFIG_PAX_RANDMMAP
87550 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87551 +#endif
87552
87553 mm->total_vm += pages;
87554
87555 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87556 mm->shared_vm += pages;
87557 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87558 mm->exec_vm += pages;
87559 - } else if (flags & stack_flags)
87560 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87561 mm->stack_vm += pages;
87562 }
87563 #endif /* CONFIG_PROC_FS */
87564 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87565 * (the exception is when the underlying filesystem is noexec
87566 * mounted, in which case we dont add PROT_EXEC.)
87567 */
87568 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87569 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87570 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87571 prot |= PROT_EXEC;
87572
87573 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87574 /* Obtain the address to map to. we verify (or select) it and ensure
87575 * that it represents a valid section of the address space.
87576 */
87577 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87578 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87579 if (addr & ~PAGE_MASK)
87580 return addr;
87581
87582 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87583 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87584 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87585
87586 +#ifdef CONFIG_PAX_MPROTECT
87587 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87588 +
87589 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87590 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87591 + mm->binfmt->handle_mmap)
87592 + mm->binfmt->handle_mmap(file);
87593 +#endif
87594 +
87595 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87596 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87597 + gr_log_rwxmmap(file);
87598 +
87599 +#ifdef CONFIG_PAX_EMUPLT
87600 + vm_flags &= ~VM_EXEC;
87601 +#else
87602 + return -EPERM;
87603 +#endif
87604 +
87605 + }
87606 +
87607 + if (!(vm_flags & VM_EXEC))
87608 + vm_flags &= ~VM_MAYEXEC;
87609 +#else
87610 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87611 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87612 +#endif
87613 + else
87614 + vm_flags &= ~VM_MAYWRITE;
87615 + }
87616 +#endif
87617 +
87618 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87619 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87620 + vm_flags &= ~VM_PAGEEXEC;
87621 +#endif
87622 +
87623 if (flags & MAP_LOCKED)
87624 if (!can_do_mlock())
87625 return -EPERM;
87626 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87627 locked += mm->locked_vm;
87628 lock_limit = rlimit(RLIMIT_MEMLOCK);
87629 lock_limit >>= PAGE_SHIFT;
87630 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87631 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87632 return -EAGAIN;
87633 }
87634 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87635 vm_flags |= VM_NORESERVE;
87636 }
87637
87638 + if (!gr_acl_handle_mmap(file, prot))
87639 + return -EACCES;
87640 +
87641 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87642 if (!IS_ERR_VALUE(addr) &&
87643 ((vm_flags & VM_LOCKED) ||
87644 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87645 vm_flags_t vm_flags = vma->vm_flags;
87646
87647 /* If it was private or non-writable, the write bit is already clear */
87648 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87649 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87650 return 0;
87651
87652 /* The backer wishes to know when pages are first written to? */
87653 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87654 unsigned long charged = 0;
87655 struct inode *inode = file ? file_inode(file) : NULL;
87656
87657 +#ifdef CONFIG_PAX_SEGMEXEC
87658 + struct vm_area_struct *vma_m = NULL;
87659 +#endif
87660 +
87661 + /*
87662 + * mm->mmap_sem is required to protect against another thread
87663 + * changing the mappings in case we sleep.
87664 + */
87665 + verify_mm_writelocked(mm);
87666 +
87667 /* Check against address space limit. */
87668 +
87669 +#ifdef CONFIG_PAX_RANDMMAP
87670 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87671 +#endif
87672 +
87673 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87674 unsigned long nr_pages;
87675
87676 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87677
87678 /* Clear old maps */
87679 error = -ENOMEM;
87680 -munmap_back:
87681 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87682 if (do_munmap(mm, addr, len))
87683 return -ENOMEM;
87684 - goto munmap_back;
87685 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87686 }
87687
87688 /*
87689 @@ -1536,6 +1674,16 @@ munmap_back:
87690 goto unacct_error;
87691 }
87692
87693 +#ifdef CONFIG_PAX_SEGMEXEC
87694 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87695 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87696 + if (!vma_m) {
87697 + error = -ENOMEM;
87698 + goto free_vma;
87699 + }
87700 + }
87701 +#endif
87702 +
87703 vma->vm_mm = mm;
87704 vma->vm_start = addr;
87705 vma->vm_end = addr + len;
87706 @@ -1560,6 +1708,13 @@ munmap_back:
87707 if (error)
87708 goto unmap_and_free_vma;
87709
87710 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87711 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87712 + vma->vm_flags |= VM_PAGEEXEC;
87713 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87714 + }
87715 +#endif
87716 +
87717 /* Can addr have changed??
87718 *
87719 * Answer: Yes, several device drivers can do it in their
87720 @@ -1598,6 +1753,11 @@ munmap_back:
87721 vma_link(mm, vma, prev, rb_link, rb_parent);
87722 file = vma->vm_file;
87723
87724 +#ifdef CONFIG_PAX_SEGMEXEC
87725 + if (vma_m)
87726 + BUG_ON(pax_mirror_vma(vma_m, vma));
87727 +#endif
87728 +
87729 /* Once vma denies write, undo our temporary denial count */
87730 if (correct_wcount)
87731 atomic_inc(&inode->i_writecount);
87732 @@ -1605,6 +1765,7 @@ out:
87733 perf_event_mmap(vma);
87734
87735 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87736 + track_exec_limit(mm, addr, addr + len, vm_flags);
87737 if (vm_flags & VM_LOCKED) {
87738 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87739 vma == get_gate_vma(current->mm)))
87740 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87741 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87742 charged = 0;
87743 free_vma:
87744 +
87745 +#ifdef CONFIG_PAX_SEGMEXEC
87746 + if (vma_m)
87747 + kmem_cache_free(vm_area_cachep, vma_m);
87748 +#endif
87749 +
87750 kmem_cache_free(vm_area_cachep, vma);
87751 unacct_error:
87752 if (charged)
87753 @@ -1635,7 +1802,63 @@ unacct_error:
87754 return error;
87755 }
87756
87757 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87758 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87759 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87760 +{
87761 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87762 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87763 +
87764 + return 0;
87765 +}
87766 +#endif
87767 +
87768 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87769 +{
87770 + if (!vma) {
87771 +#ifdef CONFIG_STACK_GROWSUP
87772 + if (addr > sysctl_heap_stack_gap)
87773 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87774 + else
87775 + vma = find_vma(current->mm, 0);
87776 + if (vma && (vma->vm_flags & VM_GROWSUP))
87777 + return false;
87778 +#endif
87779 + return true;
87780 + }
87781 +
87782 + if (addr + len > vma->vm_start)
87783 + return false;
87784 +
87785 + if (vma->vm_flags & VM_GROWSDOWN)
87786 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87787 +#ifdef CONFIG_STACK_GROWSUP
87788 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87789 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87790 +#endif
87791 + else if (offset)
87792 + return offset <= vma->vm_start - addr - len;
87793 +
87794 + return true;
87795 +}
87796 +
87797 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87798 +{
87799 + if (vma->vm_start < len)
87800 + return -ENOMEM;
87801 +
87802 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87803 + if (offset <= vma->vm_start - len)
87804 + return vma->vm_start - len - offset;
87805 + else
87806 + return -ENOMEM;
87807 + }
87808 +
87809 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87810 + return vma->vm_start - len - sysctl_heap_stack_gap;
87811 + return -ENOMEM;
87812 +}
87813 +
87814 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87815 {
87816 /*
87817 * We implement the search by looking for an rbtree node that
87818 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87819 }
87820 }
87821
87822 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87823 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87824 check_current:
87825 /* Check if current node has a suitable gap */
87826 if (gap_start > high_limit)
87827 return -ENOMEM;
87828 +
87829 + if (gap_end - gap_start > info->threadstack_offset)
87830 + gap_start += info->threadstack_offset;
87831 + else
87832 + gap_start = gap_end;
87833 +
87834 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87835 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87836 + gap_start += sysctl_heap_stack_gap;
87837 + else
87838 + gap_start = gap_end;
87839 + }
87840 + if (vma->vm_flags & VM_GROWSDOWN) {
87841 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87842 + gap_end -= sysctl_heap_stack_gap;
87843 + else
87844 + gap_end = gap_start;
87845 + }
87846 if (gap_end >= low_limit && gap_end - gap_start >= length)
87847 goto found;
87848
87849 @@ -1737,7 +1978,7 @@ found:
87850 return gap_start;
87851 }
87852
87853 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87854 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87855 {
87856 struct mm_struct *mm = current->mm;
87857 struct vm_area_struct *vma;
87858 @@ -1791,6 +2032,24 @@ check_current:
87859 gap_end = vma->vm_start;
87860 if (gap_end < low_limit)
87861 return -ENOMEM;
87862 +
87863 + if (gap_end - gap_start > info->threadstack_offset)
87864 + gap_end -= info->threadstack_offset;
87865 + else
87866 + gap_end = gap_start;
87867 +
87868 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87869 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87870 + gap_start += sysctl_heap_stack_gap;
87871 + else
87872 + gap_start = gap_end;
87873 + }
87874 + if (vma->vm_flags & VM_GROWSDOWN) {
87875 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87876 + gap_end -= sysctl_heap_stack_gap;
87877 + else
87878 + gap_end = gap_start;
87879 + }
87880 if (gap_start <= high_limit && gap_end - gap_start >= length)
87881 goto found;
87882
87883 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87884 struct mm_struct *mm = current->mm;
87885 struct vm_area_struct *vma;
87886 struct vm_unmapped_area_info info;
87887 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87888
87889 if (len > TASK_SIZE)
87890 return -ENOMEM;
87891 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87892 if (flags & MAP_FIXED)
87893 return addr;
87894
87895 +#ifdef CONFIG_PAX_RANDMMAP
87896 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87897 +#endif
87898 +
87899 if (addr) {
87900 addr = PAGE_ALIGN(addr);
87901 vma = find_vma(mm, addr);
87902 - if (TASK_SIZE - len >= addr &&
87903 - (!vma || addr + len <= vma->vm_start))
87904 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87905 return addr;
87906 }
87907
87908 info.flags = 0;
87909 info.length = len;
87910 info.low_limit = TASK_UNMAPPED_BASE;
87911 +
87912 +#ifdef CONFIG_PAX_RANDMMAP
87913 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87914 + info.low_limit += mm->delta_mmap;
87915 +#endif
87916 +
87917 info.high_limit = TASK_SIZE;
87918 info.align_mask = 0;
87919 + info.threadstack_offset = offset;
87920 return vm_unmapped_area(&info);
87921 }
87922 #endif
87923 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87924 struct mm_struct *mm = current->mm;
87925 unsigned long addr = addr0;
87926 struct vm_unmapped_area_info info;
87927 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87928
87929 /* requested length too big for entire address space */
87930 if (len > TASK_SIZE)
87931 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87932 if (flags & MAP_FIXED)
87933 return addr;
87934
87935 +#ifdef CONFIG_PAX_RANDMMAP
87936 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87937 +#endif
87938 +
87939 /* requesting a specific address */
87940 if (addr) {
87941 addr = PAGE_ALIGN(addr);
87942 vma = find_vma(mm, addr);
87943 - if (TASK_SIZE - len >= addr &&
87944 - (!vma || addr + len <= vma->vm_start))
87945 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87946 return addr;
87947 }
87948
87949 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87950 info.low_limit = PAGE_SIZE;
87951 info.high_limit = mm->mmap_base;
87952 info.align_mask = 0;
87953 + info.threadstack_offset = offset;
87954 addr = vm_unmapped_area(&info);
87955
87956 /*
87957 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87958 VM_BUG_ON(addr != -ENOMEM);
87959 info.flags = 0;
87960 info.low_limit = TASK_UNMAPPED_BASE;
87961 +
87962 +#ifdef CONFIG_PAX_RANDMMAP
87963 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87964 + info.low_limit += mm->delta_mmap;
87965 +#endif
87966 +
87967 info.high_limit = TASK_SIZE;
87968 addr = vm_unmapped_area(&info);
87969 }
87970 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87971 return vma;
87972 }
87973
87974 +#ifdef CONFIG_PAX_SEGMEXEC
87975 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
87976 +{
87977 + struct vm_area_struct *vma_m;
87978 +
87979 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
87980 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
87981 + BUG_ON(vma->vm_mirror);
87982 + return NULL;
87983 + }
87984 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
87985 + vma_m = vma->vm_mirror;
87986 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
87987 + BUG_ON(vma->vm_file != vma_m->vm_file);
87988 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
87989 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
87990 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
87991 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
87992 + return vma_m;
87993 +}
87994 +#endif
87995 +
87996 /*
87997 * Verify that the stack growth is acceptable and
87998 * update accounting. This is shared with both the
87999 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88000 return -ENOMEM;
88001
88002 /* Stack limit test */
88003 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88004 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88005 return -ENOMEM;
88006
88007 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88008 locked = mm->locked_vm + grow;
88009 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88010 limit >>= PAGE_SHIFT;
88011 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88012 if (locked > limit && !capable(CAP_IPC_LOCK))
88013 return -ENOMEM;
88014 }
88015 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88016 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88017 * vma is the last one with address > vma->vm_end. Have to extend vma.
88018 */
88019 +#ifndef CONFIG_IA64
88020 +static
88021 +#endif
88022 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88023 {
88024 int error;
88025 + bool locknext;
88026
88027 if (!(vma->vm_flags & VM_GROWSUP))
88028 return -EFAULT;
88029
88030 + /* Also guard against wrapping around to address 0. */
88031 + if (address < PAGE_ALIGN(address+1))
88032 + address = PAGE_ALIGN(address+1);
88033 + else
88034 + return -ENOMEM;
88035 +
88036 /*
88037 * We must make sure the anon_vma is allocated
88038 * so that the anon_vma locking is not a noop.
88039 */
88040 if (unlikely(anon_vma_prepare(vma)))
88041 return -ENOMEM;
88042 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
88043 + if (locknext && anon_vma_prepare(vma->vm_next))
88044 + return -ENOMEM;
88045 vma_lock_anon_vma(vma);
88046 + if (locknext)
88047 + vma_lock_anon_vma(vma->vm_next);
88048
88049 /*
88050 * vma->vm_start/vm_end cannot change under us because the caller
88051 * is required to hold the mmap_sem in read mode. We need the
88052 - * anon_vma lock to serialize against concurrent expand_stacks.
88053 - * Also guard against wrapping around to address 0.
88054 + * anon_vma locks to serialize against concurrent expand_stacks
88055 + * and expand_upwards.
88056 */
88057 - if (address < PAGE_ALIGN(address+4))
88058 - address = PAGE_ALIGN(address+4);
88059 - else {
88060 - vma_unlock_anon_vma(vma);
88061 - return -ENOMEM;
88062 - }
88063 error = 0;
88064
88065 /* Somebody else might have raced and expanded it already */
88066 - if (address > vma->vm_end) {
88067 + 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)
88068 + error = -ENOMEM;
88069 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
88070 unsigned long size, grow;
88071
88072 size = address - vma->vm_start;
88073 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88074 }
88075 }
88076 }
88077 + if (locknext)
88078 + vma_unlock_anon_vma(vma->vm_next);
88079 vma_unlock_anon_vma(vma);
88080 khugepaged_enter_vma_merge(vma);
88081 validate_mm(vma->vm_mm);
88082 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88083 unsigned long address)
88084 {
88085 int error;
88086 + bool lockprev = false;
88087 + struct vm_area_struct *prev;
88088
88089 /*
88090 * We must make sure the anon_vma is allocated
88091 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88092 if (error)
88093 return error;
88094
88095 + prev = vma->vm_prev;
88096 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88097 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88098 +#endif
88099 + if (lockprev && anon_vma_prepare(prev))
88100 + return -ENOMEM;
88101 + if (lockprev)
88102 + vma_lock_anon_vma(prev);
88103 +
88104 vma_lock_anon_vma(vma);
88105
88106 /*
88107 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88108 */
88109
88110 /* Somebody else might have raced and expanded it already */
88111 - if (address < vma->vm_start) {
88112 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88113 + error = -ENOMEM;
88114 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88115 unsigned long size, grow;
88116
88117 +#ifdef CONFIG_PAX_SEGMEXEC
88118 + struct vm_area_struct *vma_m;
88119 +
88120 + vma_m = pax_find_mirror_vma(vma);
88121 +#endif
88122 +
88123 size = vma->vm_end - address;
88124 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88125
88126 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88127 vma->vm_pgoff -= grow;
88128 anon_vma_interval_tree_post_update_vma(vma);
88129 vma_gap_update(vma);
88130 +
88131 +#ifdef CONFIG_PAX_SEGMEXEC
88132 + if (vma_m) {
88133 + anon_vma_interval_tree_pre_update_vma(vma_m);
88134 + vma_m->vm_start -= grow << PAGE_SHIFT;
88135 + vma_m->vm_pgoff -= grow;
88136 + anon_vma_interval_tree_post_update_vma(vma_m);
88137 + vma_gap_update(vma_m);
88138 + }
88139 +#endif
88140 +
88141 spin_unlock(&vma->vm_mm->page_table_lock);
88142
88143 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88144 perf_event_mmap(vma);
88145 }
88146 }
88147 }
88148 vma_unlock_anon_vma(vma);
88149 + if (lockprev)
88150 + vma_unlock_anon_vma(prev);
88151 khugepaged_enter_vma_merge(vma);
88152 validate_mm(vma->vm_mm);
88153 return error;
88154 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88155 do {
88156 long nrpages = vma_pages(vma);
88157
88158 +#ifdef CONFIG_PAX_SEGMEXEC
88159 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88160 + vma = remove_vma(vma);
88161 + continue;
88162 + }
88163 +#endif
88164 +
88165 if (vma->vm_flags & VM_ACCOUNT)
88166 nr_accounted += nrpages;
88167 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88168 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88169 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88170 vma->vm_prev = NULL;
88171 do {
88172 +
88173 +#ifdef CONFIG_PAX_SEGMEXEC
88174 + if (vma->vm_mirror) {
88175 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88176 + vma->vm_mirror->vm_mirror = NULL;
88177 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88178 + vma->vm_mirror = NULL;
88179 + }
88180 +#endif
88181 +
88182 vma_rb_erase(vma, &mm->mm_rb);
88183 mm->map_count--;
88184 tail_vma = vma;
88185 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88186 struct vm_area_struct *new;
88187 int err = -ENOMEM;
88188
88189 +#ifdef CONFIG_PAX_SEGMEXEC
88190 + struct vm_area_struct *vma_m, *new_m = NULL;
88191 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88192 +#endif
88193 +
88194 if (is_vm_hugetlb_page(vma) && (addr &
88195 ~(huge_page_mask(hstate_vma(vma)))))
88196 return -EINVAL;
88197
88198 +#ifdef CONFIG_PAX_SEGMEXEC
88199 + vma_m = pax_find_mirror_vma(vma);
88200 +#endif
88201 +
88202 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88203 if (!new)
88204 goto out_err;
88205
88206 +#ifdef CONFIG_PAX_SEGMEXEC
88207 + if (vma_m) {
88208 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88209 + if (!new_m) {
88210 + kmem_cache_free(vm_area_cachep, new);
88211 + goto out_err;
88212 + }
88213 + }
88214 +#endif
88215 +
88216 /* most fields are the same, copy all, and then fixup */
88217 *new = *vma;
88218
88219 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88220 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88221 }
88222
88223 +#ifdef CONFIG_PAX_SEGMEXEC
88224 + if (vma_m) {
88225 + *new_m = *vma_m;
88226 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88227 + new_m->vm_mirror = new;
88228 + new->vm_mirror = new_m;
88229 +
88230 + if (new_below)
88231 + new_m->vm_end = addr_m;
88232 + else {
88233 + new_m->vm_start = addr_m;
88234 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88235 + }
88236 + }
88237 +#endif
88238 +
88239 pol = mpol_dup(vma_policy(vma));
88240 if (IS_ERR(pol)) {
88241 err = PTR_ERR(pol);
88242 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88243 else
88244 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88245
88246 +#ifdef CONFIG_PAX_SEGMEXEC
88247 + if (!err && vma_m) {
88248 + if (anon_vma_clone(new_m, vma_m))
88249 + goto out_free_mpol;
88250 +
88251 + mpol_get(pol);
88252 + vma_set_policy(new_m, pol);
88253 +
88254 + if (new_m->vm_file)
88255 + get_file(new_m->vm_file);
88256 +
88257 + if (new_m->vm_ops && new_m->vm_ops->open)
88258 + new_m->vm_ops->open(new_m);
88259 +
88260 + if (new_below)
88261 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88262 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88263 + else
88264 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88265 +
88266 + if (err) {
88267 + if (new_m->vm_ops && new_m->vm_ops->close)
88268 + new_m->vm_ops->close(new_m);
88269 + if (new_m->vm_file)
88270 + fput(new_m->vm_file);
88271 + mpol_put(pol);
88272 + }
88273 + }
88274 +#endif
88275 +
88276 /* Success. */
88277 if (!err)
88278 return 0;
88279 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88280 new->vm_ops->close(new);
88281 if (new->vm_file)
88282 fput(new->vm_file);
88283 - unlink_anon_vmas(new);
88284 out_free_mpol:
88285 mpol_put(pol);
88286 out_free_vma:
88287 +
88288 +#ifdef CONFIG_PAX_SEGMEXEC
88289 + if (new_m) {
88290 + unlink_anon_vmas(new_m);
88291 + kmem_cache_free(vm_area_cachep, new_m);
88292 + }
88293 +#endif
88294 +
88295 + unlink_anon_vmas(new);
88296 kmem_cache_free(vm_area_cachep, new);
88297 out_err:
88298 return err;
88299 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88300 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88301 unsigned long addr, int new_below)
88302 {
88303 +
88304 +#ifdef CONFIG_PAX_SEGMEXEC
88305 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88306 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88307 + if (mm->map_count >= sysctl_max_map_count-1)
88308 + return -ENOMEM;
88309 + } else
88310 +#endif
88311 +
88312 if (mm->map_count >= sysctl_max_map_count)
88313 return -ENOMEM;
88314
88315 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88316 * work. This now handles partial unmappings.
88317 * Jeremy Fitzhardinge <jeremy@goop.org>
88318 */
88319 +#ifdef CONFIG_PAX_SEGMEXEC
88320 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88321 {
88322 + int ret = __do_munmap(mm, start, len);
88323 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88324 + return ret;
88325 +
88326 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88327 +}
88328 +
88329 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88330 +#else
88331 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88332 +#endif
88333 +{
88334 unsigned long end;
88335 struct vm_area_struct *vma, *prev, *last;
88336
88337 + /*
88338 + * mm->mmap_sem is required to protect against another thread
88339 + * changing the mappings in case we sleep.
88340 + */
88341 + verify_mm_writelocked(mm);
88342 +
88343 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88344 return -EINVAL;
88345
88346 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88347 /* Fix up all other VM information */
88348 remove_vma_list(mm, vma);
88349
88350 + track_exec_limit(mm, start, end, 0UL);
88351 +
88352 return 0;
88353 }
88354
88355 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88356 int ret;
88357 struct mm_struct *mm = current->mm;
88358
88359 +
88360 +#ifdef CONFIG_PAX_SEGMEXEC
88361 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88362 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88363 + return -EINVAL;
88364 +#endif
88365 +
88366 down_write(&mm->mmap_sem);
88367 ret = do_munmap(mm, start, len);
88368 up_write(&mm->mmap_sem);
88369 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88370 return vm_munmap(addr, len);
88371 }
88372
88373 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88374 -{
88375 -#ifdef CONFIG_DEBUG_VM
88376 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88377 - WARN_ON(1);
88378 - up_read(&mm->mmap_sem);
88379 - }
88380 -#endif
88381 -}
88382 -
88383 /*
88384 * this is really a simplified "do_mmap". it only handles
88385 * anonymous maps. eventually we may be able to do some
88386 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88387 struct rb_node ** rb_link, * rb_parent;
88388 pgoff_t pgoff = addr >> PAGE_SHIFT;
88389 int error;
88390 + unsigned long charged;
88391
88392 len = PAGE_ALIGN(len);
88393 if (!len)
88394 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88395
88396 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88397
88398 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88399 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88400 + flags &= ~VM_EXEC;
88401 +
88402 +#ifdef CONFIG_PAX_MPROTECT
88403 + if (mm->pax_flags & MF_PAX_MPROTECT)
88404 + flags &= ~VM_MAYEXEC;
88405 +#endif
88406 +
88407 + }
88408 +#endif
88409 +
88410 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88411 if (error & ~PAGE_MASK)
88412 return error;
88413
88414 + charged = len >> PAGE_SHIFT;
88415 +
88416 /*
88417 * mlock MCL_FUTURE?
88418 */
88419 if (mm->def_flags & VM_LOCKED) {
88420 unsigned long locked, lock_limit;
88421 - locked = len >> PAGE_SHIFT;
88422 + locked = charged;
88423 locked += mm->locked_vm;
88424 lock_limit = rlimit(RLIMIT_MEMLOCK);
88425 lock_limit >>= PAGE_SHIFT;
88426 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88427 /*
88428 * Clear old maps. this also does some error checking for us
88429 */
88430 - munmap_back:
88431 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88432 if (do_munmap(mm, addr, len))
88433 return -ENOMEM;
88434 - goto munmap_back;
88435 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88436 }
88437
88438 /* Check against address space limits *after* clearing old maps... */
88439 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88440 + if (!may_expand_vm(mm, charged))
88441 return -ENOMEM;
88442
88443 if (mm->map_count > sysctl_max_map_count)
88444 return -ENOMEM;
88445
88446 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88447 + if (security_vm_enough_memory_mm(mm, charged))
88448 return -ENOMEM;
88449
88450 /* Can we just expand an old private anonymous mapping? */
88451 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88452 */
88453 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88454 if (!vma) {
88455 - vm_unacct_memory(len >> PAGE_SHIFT);
88456 + vm_unacct_memory(charged);
88457 return -ENOMEM;
88458 }
88459
88460 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88461 vma_link(mm, vma, prev, rb_link, rb_parent);
88462 out:
88463 perf_event_mmap(vma);
88464 - mm->total_vm += len >> PAGE_SHIFT;
88465 + mm->total_vm += charged;
88466 if (flags & VM_LOCKED)
88467 - mm->locked_vm += (len >> PAGE_SHIFT);
88468 + mm->locked_vm += charged;
88469 + track_exec_limit(mm, addr, addr + len, flags);
88470 return addr;
88471 }
88472
88473 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88474 while (vma) {
88475 if (vma->vm_flags & VM_ACCOUNT)
88476 nr_accounted += vma_pages(vma);
88477 + vma->vm_mirror = NULL;
88478 vma = remove_vma(vma);
88479 }
88480 vm_unacct_memory(nr_accounted);
88481 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88482 struct vm_area_struct *prev;
88483 struct rb_node **rb_link, *rb_parent;
88484
88485 +#ifdef CONFIG_PAX_SEGMEXEC
88486 + struct vm_area_struct *vma_m = NULL;
88487 +#endif
88488 +
88489 + if (security_mmap_addr(vma->vm_start))
88490 + return -EPERM;
88491 +
88492 /*
88493 * The vm_pgoff of a purely anonymous vma should be irrelevant
88494 * until its first write fault, when page's anon_vma and index
88495 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88496 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88497 return -ENOMEM;
88498
88499 +#ifdef CONFIG_PAX_SEGMEXEC
88500 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88501 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88502 + if (!vma_m)
88503 + return -ENOMEM;
88504 + }
88505 +#endif
88506 +
88507 vma_link(mm, vma, prev, rb_link, rb_parent);
88508 +
88509 +#ifdef CONFIG_PAX_SEGMEXEC
88510 + if (vma_m)
88511 + BUG_ON(pax_mirror_vma(vma_m, vma));
88512 +#endif
88513 +
88514 return 0;
88515 }
88516
88517 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88518 struct mempolicy *pol;
88519 bool faulted_in_anon_vma = true;
88520
88521 + BUG_ON(vma->vm_mirror);
88522 +
88523 /*
88524 * If anonymous vma has not yet been faulted, update new pgoff
88525 * to match new location, to increase its chance of merging.
88526 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88527 return NULL;
88528 }
88529
88530 +#ifdef CONFIG_PAX_SEGMEXEC
88531 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88532 +{
88533 + struct vm_area_struct *prev_m;
88534 + struct rb_node **rb_link_m, *rb_parent_m;
88535 + struct mempolicy *pol_m;
88536 +
88537 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88538 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88539 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88540 + *vma_m = *vma;
88541 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88542 + if (anon_vma_clone(vma_m, vma))
88543 + return -ENOMEM;
88544 + pol_m = vma_policy(vma_m);
88545 + mpol_get(pol_m);
88546 + vma_set_policy(vma_m, pol_m);
88547 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88548 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88549 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88550 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88551 + if (vma_m->vm_file)
88552 + get_file(vma_m->vm_file);
88553 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88554 + vma_m->vm_ops->open(vma_m);
88555 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88556 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88557 + vma_m->vm_mirror = vma;
88558 + vma->vm_mirror = vma_m;
88559 + return 0;
88560 +}
88561 +#endif
88562 +
88563 /*
88564 * Return true if the calling process may expand its vm space by the passed
88565 * number of pages
88566 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88567
88568 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88569
88570 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88571 if (cur + npages > lim)
88572 return 0;
88573 return 1;
88574 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88575 vma->vm_start = addr;
88576 vma->vm_end = addr + len;
88577
88578 +#ifdef CONFIG_PAX_MPROTECT
88579 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88580 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88581 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88582 + return -EPERM;
88583 + if (!(vm_flags & VM_EXEC))
88584 + vm_flags &= ~VM_MAYEXEC;
88585 +#else
88586 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88587 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88588 +#endif
88589 + else
88590 + vm_flags &= ~VM_MAYWRITE;
88591 + }
88592 +#endif
88593 +
88594 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88595 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88596
88597 diff --git a/mm/mprotect.c b/mm/mprotect.c
88598 index 94722a4..e661e29 100644
88599 --- a/mm/mprotect.c
88600 +++ b/mm/mprotect.c
88601 @@ -23,10 +23,18 @@
88602 #include <linux/mmu_notifier.h>
88603 #include <linux/migrate.h>
88604 #include <linux/perf_event.h>
88605 +#include <linux/sched/sysctl.h>
88606 +
88607 +#ifdef CONFIG_PAX_MPROTECT
88608 +#include <linux/elf.h>
88609 +#include <linux/binfmts.h>
88610 +#endif
88611 +
88612 #include <asm/uaccess.h>
88613 #include <asm/pgtable.h>
88614 #include <asm/cacheflush.h>
88615 #include <asm/tlbflush.h>
88616 +#include <asm/mmu_context.h>
88617
88618 #ifndef pgprot_modify
88619 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88620 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88621 return pages;
88622 }
88623
88624 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88625 +/* called while holding the mmap semaphor for writing except stack expansion */
88626 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88627 +{
88628 + unsigned long oldlimit, newlimit = 0UL;
88629 +
88630 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88631 + return;
88632 +
88633 + spin_lock(&mm->page_table_lock);
88634 + oldlimit = mm->context.user_cs_limit;
88635 + if ((prot & VM_EXEC) && oldlimit < end)
88636 + /* USER_CS limit moved up */
88637 + newlimit = end;
88638 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88639 + /* USER_CS limit moved down */
88640 + newlimit = start;
88641 +
88642 + if (newlimit) {
88643 + mm->context.user_cs_limit = newlimit;
88644 +
88645 +#ifdef CONFIG_SMP
88646 + wmb();
88647 + cpus_clear(mm->context.cpu_user_cs_mask);
88648 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88649 +#endif
88650 +
88651 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88652 + }
88653 + spin_unlock(&mm->page_table_lock);
88654 + if (newlimit == end) {
88655 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88656 +
88657 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88658 + if (is_vm_hugetlb_page(vma))
88659 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88660 + else
88661 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88662 + }
88663 +}
88664 +#endif
88665 +
88666 int
88667 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88668 unsigned long start, unsigned long end, unsigned long newflags)
88669 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88670 int error;
88671 int dirty_accountable = 0;
88672
88673 +#ifdef CONFIG_PAX_SEGMEXEC
88674 + struct vm_area_struct *vma_m = NULL;
88675 + unsigned long start_m, end_m;
88676 +
88677 + start_m = start + SEGMEXEC_TASK_SIZE;
88678 + end_m = end + SEGMEXEC_TASK_SIZE;
88679 +#endif
88680 +
88681 if (newflags == oldflags) {
88682 *pprev = vma;
88683 return 0;
88684 }
88685
88686 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88687 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88688 +
88689 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88690 + return -ENOMEM;
88691 +
88692 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88693 + return -ENOMEM;
88694 + }
88695 +
88696 /*
88697 * If we make a private mapping writable we increase our commit;
88698 * but (without finer accounting) cannot reduce our commit if we
88699 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88700 }
88701 }
88702
88703 +#ifdef CONFIG_PAX_SEGMEXEC
88704 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88705 + if (start != vma->vm_start) {
88706 + error = split_vma(mm, vma, start, 1);
88707 + if (error)
88708 + goto fail;
88709 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88710 + *pprev = (*pprev)->vm_next;
88711 + }
88712 +
88713 + if (end != vma->vm_end) {
88714 + error = split_vma(mm, vma, end, 0);
88715 + if (error)
88716 + goto fail;
88717 + }
88718 +
88719 + if (pax_find_mirror_vma(vma)) {
88720 + error = __do_munmap(mm, start_m, end_m - start_m);
88721 + if (error)
88722 + goto fail;
88723 + } else {
88724 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88725 + if (!vma_m) {
88726 + error = -ENOMEM;
88727 + goto fail;
88728 + }
88729 + vma->vm_flags = newflags;
88730 + error = pax_mirror_vma(vma_m, vma);
88731 + if (error) {
88732 + vma->vm_flags = oldflags;
88733 + goto fail;
88734 + }
88735 + }
88736 + }
88737 +#endif
88738 +
88739 /*
88740 * First try to merge with previous and/or next vma.
88741 */
88742 @@ -296,9 +400,21 @@ success:
88743 * vm_flags and vm_page_prot are protected by the mmap_sem
88744 * held in write mode.
88745 */
88746 +
88747 +#ifdef CONFIG_PAX_SEGMEXEC
88748 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88749 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88750 +#endif
88751 +
88752 vma->vm_flags = newflags;
88753 +
88754 +#ifdef CONFIG_PAX_MPROTECT
88755 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88756 + mm->binfmt->handle_mprotect(vma, newflags);
88757 +#endif
88758 +
88759 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88760 - vm_get_page_prot(newflags));
88761 + vm_get_page_prot(vma->vm_flags));
88762
88763 if (vma_wants_writenotify(vma)) {
88764 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88765 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88766 end = start + len;
88767 if (end <= start)
88768 return -ENOMEM;
88769 +
88770 +#ifdef CONFIG_PAX_SEGMEXEC
88771 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88772 + if (end > SEGMEXEC_TASK_SIZE)
88773 + return -EINVAL;
88774 + } else
88775 +#endif
88776 +
88777 + if (end > TASK_SIZE)
88778 + return -EINVAL;
88779 +
88780 if (!arch_validate_prot(prot))
88781 return -EINVAL;
88782
88783 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88784 /*
88785 * Does the application expect PROT_READ to imply PROT_EXEC:
88786 */
88787 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88788 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88789 prot |= PROT_EXEC;
88790
88791 vm_flags = calc_vm_prot_bits(prot);
88792 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88793 if (start > vma->vm_start)
88794 prev = vma;
88795
88796 +#ifdef CONFIG_PAX_MPROTECT
88797 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88798 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88799 +#endif
88800 +
88801 for (nstart = start ; ; ) {
88802 unsigned long newflags;
88803
88804 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88805
88806 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88807 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88808 + if (prot & (PROT_WRITE | PROT_EXEC))
88809 + gr_log_rwxmprotect(vma);
88810 +
88811 + error = -EACCES;
88812 + goto out;
88813 + }
88814 +
88815 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88816 error = -EACCES;
88817 goto out;
88818 }
88819 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88820 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88821 if (error)
88822 goto out;
88823 +
88824 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88825 +
88826 nstart = tmp;
88827
88828 if (nstart < prev->vm_end)
88829 diff --git a/mm/mremap.c b/mm/mremap.c
88830 index 0843feb..4f5b2e6 100644
88831 --- a/mm/mremap.c
88832 +++ b/mm/mremap.c
88833 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88834 continue;
88835 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88836 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88837 +
88838 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88839 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88840 + pte = pte_exprotect(pte);
88841 +#endif
88842 +
88843 pte = move_soft_dirty_pte(pte);
88844 set_pte_at(mm, new_addr, new_pte, pte);
88845 }
88846 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88847 if (is_vm_hugetlb_page(vma))
88848 goto Einval;
88849
88850 +#ifdef CONFIG_PAX_SEGMEXEC
88851 + if (pax_find_mirror_vma(vma))
88852 + goto Einval;
88853 +#endif
88854 +
88855 /* We can't remap across vm area boundaries */
88856 if (old_len > vma->vm_end - addr)
88857 goto Efault;
88858 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88859 unsigned long ret = -EINVAL;
88860 unsigned long charged = 0;
88861 unsigned long map_flags;
88862 + unsigned long pax_task_size = TASK_SIZE;
88863
88864 if (new_addr & ~PAGE_MASK)
88865 goto out;
88866
88867 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88868 +#ifdef CONFIG_PAX_SEGMEXEC
88869 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88870 + pax_task_size = SEGMEXEC_TASK_SIZE;
88871 +#endif
88872 +
88873 + pax_task_size -= PAGE_SIZE;
88874 +
88875 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88876 goto out;
88877
88878 /* Check if the location we're moving into overlaps the
88879 * old location at all, and fail if it does.
88880 */
88881 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88882 - goto out;
88883 -
88884 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88885 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88886 goto out;
88887
88888 ret = do_munmap(mm, new_addr, new_len);
88889 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88890 unsigned long ret = -EINVAL;
88891 unsigned long charged = 0;
88892 bool locked = false;
88893 + unsigned long pax_task_size = TASK_SIZE;
88894
88895 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88896 return ret;
88897 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88898 if (!new_len)
88899 return ret;
88900
88901 +#ifdef CONFIG_PAX_SEGMEXEC
88902 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88903 + pax_task_size = SEGMEXEC_TASK_SIZE;
88904 +#endif
88905 +
88906 + pax_task_size -= PAGE_SIZE;
88907 +
88908 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88909 + old_len > pax_task_size || addr > pax_task_size-old_len)
88910 + return ret;
88911 +
88912 down_write(&current->mm->mmap_sem);
88913
88914 if (flags & MREMAP_FIXED) {
88915 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88916 new_addr = addr;
88917 }
88918 ret = addr;
88919 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88920 goto out;
88921 }
88922 }
88923 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88924 goto out;
88925 }
88926
88927 + map_flags = vma->vm_flags;
88928 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88929 + if (!(ret & ~PAGE_MASK)) {
88930 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88931 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88932 + }
88933 }
88934 out:
88935 if (ret & ~PAGE_MASK)
88936 diff --git a/mm/nommu.c b/mm/nommu.c
88937 index ecd1f15..77039bd 100644
88938 --- a/mm/nommu.c
88939 +++ b/mm/nommu.c
88940 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88941 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88942 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88943 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88944 -int heap_stack_gap = 0;
88945
88946 atomic_long_t mmap_pages_allocated;
88947
88948 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88949 EXPORT_SYMBOL(find_vma);
88950
88951 /*
88952 - * find a VMA
88953 - * - we don't extend stack VMAs under NOMMU conditions
88954 - */
88955 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88956 -{
88957 - return find_vma(mm, addr);
88958 -}
88959 -
88960 -/*
88961 * expand a stack to a given address
88962 * - not supported under NOMMU conditions
88963 */
88964 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88965
88966 /* most fields are the same, copy all, and then fixup */
88967 *new = *vma;
88968 + INIT_LIST_HEAD(&new->anon_vma_chain);
88969 *region = *vma->vm_region;
88970 new->vm_region = region;
88971
88972 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88973 }
88974 EXPORT_SYMBOL(generic_file_remap_pages);
88975
88976 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88977 - unsigned long addr, void *buf, int len, int write)
88978 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88979 + unsigned long addr, void *buf, size_t len, int write)
88980 {
88981 struct vm_area_struct *vma;
88982
88983 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88984 *
88985 * The caller must hold a reference on @mm.
88986 */
88987 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88988 - void *buf, int len, int write)
88989 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88990 + void *buf, size_t len, int write)
88991 {
88992 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88993 }
88994 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88995 * Access another process' address space.
88996 * - source/target buffer must be kernel space
88997 */
88998 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
88999 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89000 {
89001 struct mm_struct *mm;
89002
89003 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89004 index 3f0c895..60cd104 100644
89005 --- a/mm/page-writeback.c
89006 +++ b/mm/page-writeback.c
89007 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
89008 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89009 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89010 */
89011 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89012 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89013 unsigned long thresh,
89014 unsigned long bg_thresh,
89015 unsigned long dirty,
89016 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89017 index b100255..fba1254 100644
89018 --- a/mm/page_alloc.c
89019 +++ b/mm/page_alloc.c
89020 @@ -60,6 +60,7 @@
89021 #include <linux/page-debug-flags.h>
89022 #include <linux/hugetlb.h>
89023 #include <linux/sched/rt.h>
89024 +#include <linux/random.h>
89025
89026 #include <asm/sections.h>
89027 #include <asm/tlbflush.h>
89028 @@ -353,7 +354,7 @@ out:
89029 * This usage means that zero-order pages may not be compound.
89030 */
89031
89032 -static void free_compound_page(struct page *page)
89033 +void free_compound_page(struct page *page)
89034 {
89035 __free_pages_ok(page, compound_order(page));
89036 }
89037 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89038 int i;
89039 int bad = 0;
89040
89041 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89042 + unsigned long index = 1UL << order;
89043 +#endif
89044 +
89045 trace_mm_page_free(page, order);
89046 kmemcheck_free_shadow(page, order);
89047
89048 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89049 debug_check_no_obj_freed(page_address(page),
89050 PAGE_SIZE << order);
89051 }
89052 +
89053 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89054 + for (; index; --index)
89055 + sanitize_highpage(page + index - 1);
89056 +#endif
89057 +
89058 arch_free_page(page, order);
89059 kernel_map_pages(page, 1 << order, 0);
89060
89061 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89062 local_irq_restore(flags);
89063 }
89064
89065 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89066 +bool __meminitdata extra_latent_entropy;
89067 +
89068 +static int __init setup_pax_extra_latent_entropy(char *str)
89069 +{
89070 + extra_latent_entropy = true;
89071 + return 0;
89072 +}
89073 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89074 +
89075 +volatile u64 latent_entropy;
89076 +EXPORT_SYMBOL(latent_entropy);
89077 +#endif
89078 +
89079 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89080 {
89081 unsigned int nr_pages = 1 << order;
89082 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89083 set_page_count(p, 0);
89084 }
89085
89086 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89087 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89088 + u64 hash = 0;
89089 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89090 + const u64 *data = lowmem_page_address(page);
89091 +
89092 + for (index = 0; index < end; index++)
89093 + hash ^= hash + data[index];
89094 + latent_entropy ^= hash;
89095 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89096 + }
89097 +#endif
89098 +
89099 page_zone(page)->managed_pages += 1 << order;
89100 set_page_refcounted(page);
89101 __free_pages(page, order);
89102 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89103 arch_alloc_page(page, order);
89104 kernel_map_pages(page, 1 << order, 1);
89105
89106 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89107 if (gfp_flags & __GFP_ZERO)
89108 prep_zero_page(page, order, gfp_flags);
89109 +#endif
89110
89111 if (order && (gfp_flags & __GFP_COMP))
89112 prep_compound_page(page, order);
89113 diff --git a/mm/page_io.c b/mm/page_io.c
89114 index ba05b64..ef2f314 100644
89115 --- a/mm/page_io.c
89116 +++ b/mm/page_io.c
89117 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89118 struct file *swap_file = sis->swap_file;
89119 struct address_space *mapping = swap_file->f_mapping;
89120 struct iovec iov = {
89121 - .iov_base = kmap(page),
89122 + .iov_base = (void __force_user *)kmap(page),
89123 .iov_len = PAGE_SIZE,
89124 };
89125
89126 diff --git a/mm/percpu.c b/mm/percpu.c
89127 index 8c8e08f..73a5cda 100644
89128 --- a/mm/percpu.c
89129 +++ b/mm/percpu.c
89130 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89131 static unsigned int pcpu_high_unit_cpu __read_mostly;
89132
89133 /* the address of the first chunk which starts with the kernel static area */
89134 -void *pcpu_base_addr __read_mostly;
89135 +void *pcpu_base_addr __read_only;
89136 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89137
89138 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89139 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89140 index fd26d04..0cea1b0 100644
89141 --- a/mm/process_vm_access.c
89142 +++ b/mm/process_vm_access.c
89143 @@ -13,6 +13,7 @@
89144 #include <linux/uio.h>
89145 #include <linux/sched.h>
89146 #include <linux/highmem.h>
89147 +#include <linux/security.h>
89148 #include <linux/ptrace.h>
89149 #include <linux/slab.h>
89150 #include <linux/syscalls.h>
89151 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89152 size_t iov_l_curr_offset = 0;
89153 ssize_t iov_len;
89154
89155 + return -ENOSYS; // PaX: until properly audited
89156 +
89157 /*
89158 * Work out how many pages of struct pages we're going to need
89159 * when eventually calling get_user_pages
89160 */
89161 for (i = 0; i < riovcnt; i++) {
89162 iov_len = rvec[i].iov_len;
89163 - if (iov_len > 0) {
89164 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89165 - + iov_len)
89166 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89167 - / PAGE_SIZE + 1;
89168 - nr_pages = max(nr_pages, nr_pages_iov);
89169 - }
89170 + if (iov_len <= 0)
89171 + continue;
89172 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89173 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89174 + nr_pages = max(nr_pages, nr_pages_iov);
89175 }
89176
89177 if (nr_pages == 0)
89178 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89179 goto free_proc_pages;
89180 }
89181
89182 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89183 + rc = -EPERM;
89184 + goto put_task_struct;
89185 + }
89186 +
89187 mm = mm_access(task, PTRACE_MODE_ATTACH);
89188 if (!mm || IS_ERR(mm)) {
89189 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89190 diff --git a/mm/rmap.c b/mm/rmap.c
89191 index b2e29ac..4168491 100644
89192 --- a/mm/rmap.c
89193 +++ b/mm/rmap.c
89194 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89195 struct anon_vma *anon_vma = vma->anon_vma;
89196 struct anon_vma_chain *avc;
89197
89198 +#ifdef CONFIG_PAX_SEGMEXEC
89199 + struct anon_vma_chain *avc_m = NULL;
89200 +#endif
89201 +
89202 might_sleep();
89203 if (unlikely(!anon_vma)) {
89204 struct mm_struct *mm = vma->vm_mm;
89205 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89206 if (!avc)
89207 goto out_enomem;
89208
89209 +#ifdef CONFIG_PAX_SEGMEXEC
89210 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89211 + if (!avc_m)
89212 + goto out_enomem_free_avc;
89213 +#endif
89214 +
89215 anon_vma = find_mergeable_anon_vma(vma);
89216 allocated = NULL;
89217 if (!anon_vma) {
89218 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89219 /* page_table_lock to protect against threads */
89220 spin_lock(&mm->page_table_lock);
89221 if (likely(!vma->anon_vma)) {
89222 +
89223 +#ifdef CONFIG_PAX_SEGMEXEC
89224 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89225 +
89226 + if (vma_m) {
89227 + BUG_ON(vma_m->anon_vma);
89228 + vma_m->anon_vma = anon_vma;
89229 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89230 + avc_m = NULL;
89231 + }
89232 +#endif
89233 +
89234 vma->anon_vma = anon_vma;
89235 anon_vma_chain_link(vma, avc, anon_vma);
89236 allocated = NULL;
89237 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89238
89239 if (unlikely(allocated))
89240 put_anon_vma(allocated);
89241 +
89242 +#ifdef CONFIG_PAX_SEGMEXEC
89243 + if (unlikely(avc_m))
89244 + anon_vma_chain_free(avc_m);
89245 +#endif
89246 +
89247 if (unlikely(avc))
89248 anon_vma_chain_free(avc);
89249 }
89250 return 0;
89251
89252 out_enomem_free_avc:
89253 +
89254 +#ifdef CONFIG_PAX_SEGMEXEC
89255 + if (avc_m)
89256 + anon_vma_chain_free(avc_m);
89257 +#endif
89258 +
89259 anon_vma_chain_free(avc);
89260 out_enomem:
89261 return -ENOMEM;
89262 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89263 * Attach the anon_vmas from src to dst.
89264 * Returns 0 on success, -ENOMEM on failure.
89265 */
89266 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89267 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89268 {
89269 struct anon_vma_chain *avc, *pavc;
89270 struct anon_vma *root = NULL;
89271 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89272 * the corresponding VMA in the parent process is attached to.
89273 * Returns 0 on success, non-zero on failure.
89274 */
89275 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89276 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89277 {
89278 struct anon_vma_chain *avc;
89279 struct anon_vma *anon_vma;
89280 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89281 void __init anon_vma_init(void)
89282 {
89283 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89284 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89285 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89286 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89287 + anon_vma_ctor);
89288 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89289 + SLAB_PANIC|SLAB_NO_SANITIZE);
89290 }
89291
89292 /*
89293 diff --git a/mm/shmem.c b/mm/shmem.c
89294 index e43dc55..930e3a2 100644
89295 --- a/mm/shmem.c
89296 +++ b/mm/shmem.c
89297 @@ -33,7 +33,7 @@
89298 #include <linux/swap.h>
89299 #include <linux/aio.h>
89300
89301 -static struct vfsmount *shm_mnt;
89302 +struct vfsmount *shm_mnt;
89303
89304 #ifdef CONFIG_SHMEM
89305 /*
89306 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89307 #define BOGO_DIRENT_SIZE 20
89308
89309 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89310 -#define SHORT_SYMLINK_LEN 128
89311 +#define SHORT_SYMLINK_LEN 64
89312
89313 /*
89314 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89315 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89316 static int shmem_xattr_validate(const char *name)
89317 {
89318 struct { const char *prefix; size_t len; } arr[] = {
89319 +
89320 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89321 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89322 +#endif
89323 +
89324 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89325 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89326 };
89327 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89328 if (err)
89329 return err;
89330
89331 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89332 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89333 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89334 + return -EOPNOTSUPP;
89335 + if (size > 8)
89336 + return -EINVAL;
89337 + }
89338 +#endif
89339 +
89340 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89341 }
89342
89343 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89344 int err = -ENOMEM;
89345
89346 /* Round up to L1_CACHE_BYTES to resist false sharing */
89347 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89348 - L1_CACHE_BYTES), GFP_KERNEL);
89349 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89350 if (!sbinfo)
89351 return -ENOMEM;
89352
89353 diff --git a/mm/slab.c b/mm/slab.c
89354 index 2580db0..0523956 100644
89355 --- a/mm/slab.c
89356 +++ b/mm/slab.c
89357 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89358 if ((x)->max_freeable < i) \
89359 (x)->max_freeable = i; \
89360 } while (0)
89361 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89362 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89363 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89364 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89365 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89366 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89367 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89368 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89369 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89370 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89371 #else
89372 #define STATS_INC_ACTIVE(x) do { } while (0)
89373 #define STATS_DEC_ACTIVE(x) do { } while (0)
89374 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89375 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89376 #define STATS_INC_FREEHIT(x) do { } while (0)
89377 #define STATS_INC_FREEMISS(x) do { } while (0)
89378 +#define STATS_INC_SANITIZED(x) do { } while (0)
89379 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89380 #endif
89381
89382 #if DEBUG
89383 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89384 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89385 */
89386 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89387 - const struct slab *slab, void *obj)
89388 + const struct slab *slab, const void *obj)
89389 {
89390 u32 offset = (obj - slab->s_mem);
89391 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89392 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89393 */
89394
89395 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89396 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89397 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89398
89399 if (INDEX_AC != INDEX_NODE)
89400 kmalloc_caches[INDEX_NODE] =
89401 create_kmalloc_cache("kmalloc-node",
89402 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89403 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89404
89405 slab_early_init = 0;
89406
89407 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89408 struct array_cache *ac = cpu_cache_get(cachep);
89409
89410 check_irq_off();
89411 +
89412 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89413 + if (pax_sanitize_slab) {
89414 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89415 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89416 +
89417 + if (cachep->ctor)
89418 + cachep->ctor(objp);
89419 +
89420 + STATS_INC_SANITIZED(cachep);
89421 + } else
89422 + STATS_INC_NOT_SANITIZED(cachep);
89423 + }
89424 +#endif
89425 +
89426 kmemleak_free_recursive(objp, cachep->flags);
89427 objp = cache_free_debugcheck(cachep, objp, caller);
89428
89429 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89430
89431 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89432 return;
89433 + VM_BUG_ON(!virt_addr_valid(objp));
89434 local_irq_save(flags);
89435 kfree_debugcheck(objp);
89436 c = virt_to_cache(objp);
89437 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89438 }
89439 /* cpu stats */
89440 {
89441 - unsigned long allochit = atomic_read(&cachep->allochit);
89442 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89443 - unsigned long freehit = atomic_read(&cachep->freehit);
89444 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89445 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89446 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89447 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89448 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89449
89450 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89451 allochit, allocmiss, freehit, freemiss);
89452 }
89453 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89454 + {
89455 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89456 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89457 +
89458 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89459 + }
89460 +#endif
89461 #endif
89462 }
89463
89464 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89465 static int __init slab_proc_init(void)
89466 {
89467 #ifdef CONFIG_DEBUG_SLAB_LEAK
89468 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89469 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89470 #endif
89471 return 0;
89472 }
89473 module_init(slab_proc_init);
89474 #endif
89475
89476 +bool is_usercopy_object(const void *ptr)
89477 +{
89478 + struct page *page;
89479 + struct kmem_cache *cachep;
89480 +
89481 + if (ZERO_OR_NULL_PTR(ptr))
89482 + return false;
89483 +
89484 + if (!slab_is_available())
89485 + return false;
89486 +
89487 + if (!virt_addr_valid(ptr))
89488 + return false;
89489 +
89490 + page = virt_to_head_page(ptr);
89491 +
89492 + if (!PageSlab(page))
89493 + return false;
89494 +
89495 + cachep = page->slab_cache;
89496 + return cachep->flags & SLAB_USERCOPY;
89497 +}
89498 +
89499 +#ifdef CONFIG_PAX_USERCOPY
89500 +const char *check_heap_object(const void *ptr, unsigned long n)
89501 +{
89502 + struct page *page;
89503 + struct kmem_cache *cachep;
89504 + struct slab *slabp;
89505 + unsigned int objnr;
89506 + unsigned long offset;
89507 +
89508 + if (ZERO_OR_NULL_PTR(ptr))
89509 + return "<null>";
89510 +
89511 + if (!virt_addr_valid(ptr))
89512 + return NULL;
89513 +
89514 + page = virt_to_head_page(ptr);
89515 +
89516 + if (!PageSlab(page))
89517 + return NULL;
89518 +
89519 + cachep = page->slab_cache;
89520 + if (!(cachep->flags & SLAB_USERCOPY))
89521 + return cachep->name;
89522 +
89523 + slabp = page->slab_page;
89524 + objnr = obj_to_index(cachep, slabp, ptr);
89525 + BUG_ON(objnr >= cachep->num);
89526 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89527 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89528 + return NULL;
89529 +
89530 + return cachep->name;
89531 +}
89532 +#endif
89533 +
89534 /**
89535 * ksize - get the actual amount of memory allocated for a given object
89536 * @objp: Pointer to the object
89537 diff --git a/mm/slab.h b/mm/slab.h
89538 index a535033..2f98fe5 100644
89539 --- a/mm/slab.h
89540 +++ b/mm/slab.h
89541 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89542 /* The slab cache that manages slab cache information */
89543 extern struct kmem_cache *kmem_cache;
89544
89545 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89546 +#ifdef CONFIG_X86_64
89547 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89548 +#else
89549 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89550 +#endif
89551 +extern bool pax_sanitize_slab;
89552 +#endif
89553 +
89554 unsigned long calculate_alignment(unsigned long flags,
89555 unsigned long align, unsigned long size);
89556
89557 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89558
89559 /* Legal flag mask for kmem_cache_create(), for various configurations */
89560 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89561 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89562 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89563 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89564
89565 #if defined(CONFIG_DEBUG_SLAB)
89566 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89567 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89568 return s;
89569
89570 page = virt_to_head_page(x);
89571 +
89572 + BUG_ON(!PageSlab(page));
89573 +
89574 cachep = page->slab_cache;
89575 if (slab_equal_or_root(cachep, s))
89576 return cachep;
89577 diff --git a/mm/slab_common.c b/mm/slab_common.c
89578 index 538bade..36fed99 100644
89579 --- a/mm/slab_common.c
89580 +++ b/mm/slab_common.c
89581 @@ -22,11 +22,22 @@
89582
89583 #include "slab.h"
89584
89585 -enum slab_state slab_state;
89586 +enum slab_state slab_state __read_only;
89587 LIST_HEAD(slab_caches);
89588 DEFINE_MUTEX(slab_mutex);
89589 struct kmem_cache *kmem_cache;
89590
89591 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89592 +bool pax_sanitize_slab __read_only = true;
89593 +static int __init pax_sanitize_slab_setup(char *str)
89594 +{
89595 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89596 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89597 + return 1;
89598 +}
89599 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89600 +#endif
89601 +
89602 #ifdef CONFIG_DEBUG_VM
89603 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89604 size_t size)
89605 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89606
89607 err = __kmem_cache_create(s, flags);
89608 if (!err) {
89609 - s->refcount = 1;
89610 + atomic_set(&s->refcount, 1);
89611 list_add(&s->list, &slab_caches);
89612 memcg_cache_list_add(memcg, s);
89613 } else {
89614 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89615
89616 get_online_cpus();
89617 mutex_lock(&slab_mutex);
89618 - s->refcount--;
89619 - if (!s->refcount) {
89620 + if (atomic_dec_and_test(&s->refcount)) {
89621 list_del(&s->list);
89622
89623 if (!__kmem_cache_shutdown(s)) {
89624 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89625 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89626 name, size, err);
89627
89628 - s->refcount = -1; /* Exempt from merging for now */
89629 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89630 }
89631
89632 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89633 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89634
89635 create_boot_cache(s, name, size, flags);
89636 list_add(&s->list, &slab_caches);
89637 - s->refcount = 1;
89638 + atomic_set(&s->refcount, 1);
89639 return s;
89640 }
89641
89642 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89643 EXPORT_SYMBOL(kmalloc_dma_caches);
89644 #endif
89645
89646 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89647 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89648 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89649 +#endif
89650 +
89651 /*
89652 * Conversion table for small slabs sizes / 8 to the index in the
89653 * kmalloc array. This is necessary for slabs < 192 since we have non power
89654 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89655 return kmalloc_dma_caches[index];
89656
89657 #endif
89658 +
89659 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89660 + if (unlikely((flags & GFP_USERCOPY)))
89661 + return kmalloc_usercopy_caches[index];
89662 +
89663 +#endif
89664 +
89665 return kmalloc_caches[index];
89666 }
89667
89668 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89669 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89670 if (!kmalloc_caches[i]) {
89671 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89672 - 1 << i, flags);
89673 + 1 << i, SLAB_USERCOPY | flags);
89674 }
89675
89676 /*
89677 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89678 * earlier power of two caches
89679 */
89680 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89681 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89682 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89683
89684 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89685 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89686 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89687 }
89688
89689 /* Kmalloc array is now usable */
89690 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89691 }
89692 }
89693 #endif
89694 +
89695 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89696 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89697 + struct kmem_cache *s = kmalloc_caches[i];
89698 +
89699 + if (s) {
89700 + int size = kmalloc_size(i);
89701 + char *n = kasprintf(GFP_NOWAIT,
89702 + "usercopy-kmalloc-%d", size);
89703 +
89704 + BUG_ON(!n);
89705 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89706 + size, SLAB_USERCOPY | flags);
89707 + }
89708 + }
89709 +#endif
89710 +
89711 }
89712 #endif /* !CONFIG_SLOB */
89713
89714 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89715 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89716 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89717 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89718 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89719 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89720 +#endif
89721 #endif
89722 seq_putc(m, '\n');
89723 }
89724 diff --git a/mm/slob.c b/mm/slob.c
89725 index 91bd3f2..e2f549e 100644
89726 --- a/mm/slob.c
89727 +++ b/mm/slob.c
89728 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89729 /*
89730 * Return the size of a slob block.
89731 */
89732 -static slobidx_t slob_units(slob_t *s)
89733 +static slobidx_t slob_units(const slob_t *s)
89734 {
89735 if (s->units > 0)
89736 return s->units;
89737 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89738 /*
89739 * Return the next free slob block pointer after this one.
89740 */
89741 -static slob_t *slob_next(slob_t *s)
89742 +static slob_t *slob_next(const slob_t *s)
89743 {
89744 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89745 slobidx_t next;
89746 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89747 /*
89748 * Returns true if s is the last free block in its page.
89749 */
89750 -static int slob_last(slob_t *s)
89751 +static int slob_last(const slob_t *s)
89752 {
89753 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89754 }
89755
89756 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89757 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89758 {
89759 - void *page;
89760 + struct page *page;
89761
89762 #ifdef CONFIG_NUMA
89763 if (node != NUMA_NO_NODE)
89764 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89765 if (!page)
89766 return NULL;
89767
89768 - return page_address(page);
89769 + __SetPageSlab(page);
89770 + return page;
89771 }
89772
89773 -static void slob_free_pages(void *b, int order)
89774 +static void slob_free_pages(struct page *sp, int order)
89775 {
89776 if (current->reclaim_state)
89777 current->reclaim_state->reclaimed_slab += 1 << order;
89778 - free_pages((unsigned long)b, order);
89779 + __ClearPageSlab(sp);
89780 + page_mapcount_reset(sp);
89781 + sp->private = 0;
89782 + __free_pages(sp, order);
89783 }
89784
89785 /*
89786 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89787
89788 /* Not enough space: must allocate a new page */
89789 if (!b) {
89790 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89791 - if (!b)
89792 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89793 + if (!sp)
89794 return NULL;
89795 - sp = virt_to_page(b);
89796 - __SetPageSlab(sp);
89797 + b = page_address(sp);
89798
89799 spin_lock_irqsave(&slob_lock, flags);
89800 sp->units = SLOB_UNITS(PAGE_SIZE);
89801 sp->freelist = b;
89802 + sp->private = 0;
89803 INIT_LIST_HEAD(&sp->list);
89804 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89805 set_slob_page_free(sp, slob_list);
89806 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89807 if (slob_page_free(sp))
89808 clear_slob_page_free(sp);
89809 spin_unlock_irqrestore(&slob_lock, flags);
89810 - __ClearPageSlab(sp);
89811 - page_mapcount_reset(sp);
89812 - slob_free_pages(b, 0);
89813 + slob_free_pages(sp, 0);
89814 return;
89815 }
89816
89817 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89818 + if (pax_sanitize_slab)
89819 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89820 +#endif
89821 +
89822 if (!slob_page_free(sp)) {
89823 /* This slob page is about to become partially free. Easy! */
89824 sp->units = units;
89825 @@ -424,11 +431,10 @@ out:
89826 */
89827
89828 static __always_inline void *
89829 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89830 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89831 {
89832 - unsigned int *m;
89833 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89834 - void *ret;
89835 + slob_t *m;
89836 + void *ret = NULL;
89837
89838 gfp &= gfp_allowed_mask;
89839
89840 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89841
89842 if (!m)
89843 return NULL;
89844 - *m = size;
89845 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89846 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89847 + m[0].units = size;
89848 + m[1].units = align;
89849 ret = (void *)m + align;
89850
89851 trace_kmalloc_node(caller, ret,
89852 size, size + align, gfp, node);
89853 } else {
89854 unsigned int order = get_order(size);
89855 + struct page *page;
89856
89857 if (likely(order))
89858 gfp |= __GFP_COMP;
89859 - ret = slob_new_pages(gfp, order, node);
89860 + page = slob_new_pages(gfp, order, node);
89861 + if (page) {
89862 + ret = page_address(page);
89863 + page->private = size;
89864 + }
89865
89866 trace_kmalloc_node(caller, ret,
89867 size, PAGE_SIZE << order, gfp, node);
89868 }
89869
89870 - kmemleak_alloc(ret, size, 1, gfp);
89871 + return ret;
89872 +}
89873 +
89874 +static __always_inline void *
89875 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89876 +{
89877 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89878 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89879 +
89880 + if (!ZERO_OR_NULL_PTR(ret))
89881 + kmemleak_alloc(ret, size, 1, gfp);
89882 return ret;
89883 }
89884
89885 @@ -493,34 +517,112 @@ void kfree(const void *block)
89886 return;
89887 kmemleak_free(block);
89888
89889 + VM_BUG_ON(!virt_addr_valid(block));
89890 sp = virt_to_page(block);
89891 - if (PageSlab(sp)) {
89892 + VM_BUG_ON(!PageSlab(sp));
89893 + if (!sp->private) {
89894 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89895 - unsigned int *m = (unsigned int *)(block - align);
89896 - slob_free(m, *m + align);
89897 - } else
89898 + slob_t *m = (slob_t *)(block - align);
89899 + slob_free(m, m[0].units + align);
89900 + } else {
89901 + __ClearPageSlab(sp);
89902 + page_mapcount_reset(sp);
89903 + sp->private = 0;
89904 __free_pages(sp, compound_order(sp));
89905 + }
89906 }
89907 EXPORT_SYMBOL(kfree);
89908
89909 +bool is_usercopy_object(const void *ptr)
89910 +{
89911 + if (!slab_is_available())
89912 + return false;
89913 +
89914 + // PAX: TODO
89915 +
89916 + return false;
89917 +}
89918 +
89919 +#ifdef CONFIG_PAX_USERCOPY
89920 +const char *check_heap_object(const void *ptr, unsigned long n)
89921 +{
89922 + struct page *page;
89923 + const slob_t *free;
89924 + const void *base;
89925 + unsigned long flags;
89926 +
89927 + if (ZERO_OR_NULL_PTR(ptr))
89928 + return "<null>";
89929 +
89930 + if (!virt_addr_valid(ptr))
89931 + return NULL;
89932 +
89933 + page = virt_to_head_page(ptr);
89934 + if (!PageSlab(page))
89935 + return NULL;
89936 +
89937 + if (page->private) {
89938 + base = page;
89939 + if (base <= ptr && n <= page->private - (ptr - base))
89940 + return NULL;
89941 + return "<slob>";
89942 + }
89943 +
89944 + /* some tricky double walking to find the chunk */
89945 + spin_lock_irqsave(&slob_lock, flags);
89946 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89947 + free = page->freelist;
89948 +
89949 + while (!slob_last(free) && (void *)free <= ptr) {
89950 + base = free + slob_units(free);
89951 + free = slob_next(free);
89952 + }
89953 +
89954 + while (base < (void *)free) {
89955 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89956 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89957 + int offset;
89958 +
89959 + if (ptr < base + align)
89960 + break;
89961 +
89962 + offset = ptr - base - align;
89963 + if (offset >= m) {
89964 + base += size;
89965 + continue;
89966 + }
89967 +
89968 + if (n > m - offset)
89969 + break;
89970 +
89971 + spin_unlock_irqrestore(&slob_lock, flags);
89972 + return NULL;
89973 + }
89974 +
89975 + spin_unlock_irqrestore(&slob_lock, flags);
89976 + return "<slob>";
89977 +}
89978 +#endif
89979 +
89980 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
89981 size_t ksize(const void *block)
89982 {
89983 struct page *sp;
89984 int align;
89985 - unsigned int *m;
89986 + slob_t *m;
89987
89988 BUG_ON(!block);
89989 if (unlikely(block == ZERO_SIZE_PTR))
89990 return 0;
89991
89992 sp = virt_to_page(block);
89993 - if (unlikely(!PageSlab(sp)))
89994 - return PAGE_SIZE << compound_order(sp);
89995 + VM_BUG_ON(!PageSlab(sp));
89996 + if (sp->private)
89997 + return sp->private;
89998
89999 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90000 - m = (unsigned int *)(block - align);
90001 - return SLOB_UNITS(*m) * SLOB_UNIT;
90002 + m = (slob_t *)(block - align);
90003 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90004 }
90005 EXPORT_SYMBOL(ksize);
90006
90007 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90008
90009 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90010 {
90011 - void *b;
90012 + void *b = NULL;
90013
90014 flags &= gfp_allowed_mask;
90015
90016 lockdep_trace_alloc(flags);
90017
90018 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90019 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90020 +#else
90021 if (c->size < PAGE_SIZE) {
90022 b = slob_alloc(c->size, flags, c->align, node);
90023 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90024 SLOB_UNITS(c->size) * SLOB_UNIT,
90025 flags, node);
90026 } else {
90027 - b = slob_new_pages(flags, get_order(c->size), node);
90028 + struct page *sp;
90029 +
90030 + sp = slob_new_pages(flags, get_order(c->size), node);
90031 + if (sp) {
90032 + b = page_address(sp);
90033 + sp->private = c->size;
90034 + }
90035 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90036 PAGE_SIZE << get_order(c->size),
90037 flags, node);
90038 }
90039 +#endif
90040
90041 if (b && c->ctor)
90042 c->ctor(b);
90043 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
90044
90045 static void __kmem_cache_free(void *b, int size)
90046 {
90047 - if (size < PAGE_SIZE)
90048 + struct page *sp;
90049 +
90050 + sp = virt_to_page(b);
90051 + BUG_ON(!PageSlab(sp));
90052 + if (!sp->private)
90053 slob_free(b, size);
90054 else
90055 - slob_free_pages(b, get_order(size));
90056 + slob_free_pages(sp, get_order(size));
90057 }
90058
90059 static void kmem_rcu_free(struct rcu_head *head)
90060 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90061
90062 void kmem_cache_free(struct kmem_cache *c, void *b)
90063 {
90064 + int size = c->size;
90065 +
90066 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90067 + if (size + c->align < PAGE_SIZE) {
90068 + size += c->align;
90069 + b -= c->align;
90070 + }
90071 +#endif
90072 +
90073 kmemleak_free_recursive(b, c->flags);
90074 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90075 struct slob_rcu *slob_rcu;
90076 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90077 - slob_rcu->size = c->size;
90078 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90079 + slob_rcu->size = size;
90080 call_rcu(&slob_rcu->head, kmem_rcu_free);
90081 } else {
90082 - __kmem_cache_free(b, c->size);
90083 + __kmem_cache_free(b, size);
90084 }
90085
90086 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90087 + trace_kfree(_RET_IP_, b);
90088 +#else
90089 trace_kmem_cache_free(_RET_IP_, b);
90090 +#endif
90091 +
90092 }
90093 EXPORT_SYMBOL(kmem_cache_free);
90094
90095 diff --git a/mm/slub.c b/mm/slub.c
90096 index e3ba1f2..bd45dac 100644
90097 --- a/mm/slub.c
90098 +++ b/mm/slub.c
90099 @@ -207,7 +207,7 @@ struct track {
90100
90101 enum track_item { TRACK_ALLOC, TRACK_FREE };
90102
90103 -#ifdef CONFIG_SYSFS
90104 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90105 static int sysfs_slab_add(struct kmem_cache *);
90106 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90107 static void sysfs_slab_remove(struct kmem_cache *);
90108 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90109 if (!t->addr)
90110 return;
90111
90112 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90113 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90114 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90115 #ifdef CONFIG_STACKTRACE
90116 {
90117 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90118
90119 slab_free_hook(s, x);
90120
90121 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90122 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90123 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90124 + if (s->ctor)
90125 + s->ctor(x);
90126 + }
90127 +#endif
90128 +
90129 redo:
90130 /*
90131 * Determine the currently cpus per cpu slab.
90132 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90133 * Merge control. If this is set then no merging of slab caches will occur.
90134 * (Could be removed. This was introduced to pacify the merge skeptics.)
90135 */
90136 -static int slub_nomerge;
90137 +static int slub_nomerge = 1;
90138
90139 /*
90140 * Calculate the order of allocation given an slab object size.
90141 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90142 s->inuse = size;
90143
90144 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90145 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90146 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90147 +#endif
90148 s->ctor)) {
90149 /*
90150 * Relocate free pointer after the object if it is not
90151 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90152 EXPORT_SYMBOL(__kmalloc_node);
90153 #endif
90154
90155 +bool is_usercopy_object(const void *ptr)
90156 +{
90157 + struct page *page;
90158 + struct kmem_cache *s;
90159 +
90160 + if (ZERO_OR_NULL_PTR(ptr))
90161 + return false;
90162 +
90163 + if (!slab_is_available())
90164 + return false;
90165 +
90166 + if (!virt_addr_valid(ptr))
90167 + return false;
90168 +
90169 + page = virt_to_head_page(ptr);
90170 +
90171 + if (!PageSlab(page))
90172 + return false;
90173 +
90174 + s = page->slab_cache;
90175 + return s->flags & SLAB_USERCOPY;
90176 +}
90177 +
90178 +#ifdef CONFIG_PAX_USERCOPY
90179 +const char *check_heap_object(const void *ptr, unsigned long n)
90180 +{
90181 + struct page *page;
90182 + struct kmem_cache *s;
90183 + unsigned long offset;
90184 +
90185 + if (ZERO_OR_NULL_PTR(ptr))
90186 + return "<null>";
90187 +
90188 + if (!virt_addr_valid(ptr))
90189 + return NULL;
90190 +
90191 + page = virt_to_head_page(ptr);
90192 +
90193 + if (!PageSlab(page))
90194 + return NULL;
90195 +
90196 + s = page->slab_cache;
90197 + if (!(s->flags & SLAB_USERCOPY))
90198 + return s->name;
90199 +
90200 + offset = (ptr - page_address(page)) % s->size;
90201 + if (offset <= s->object_size && n <= s->object_size - offset)
90202 + return NULL;
90203 +
90204 + return s->name;
90205 +}
90206 +#endif
90207 +
90208 size_t ksize(const void *object)
90209 {
90210 struct page *page;
90211 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90212 if (unlikely(ZERO_OR_NULL_PTR(x)))
90213 return;
90214
90215 + VM_BUG_ON(!virt_addr_valid(x));
90216 page = virt_to_head_page(x);
90217 if (unlikely(!PageSlab(page))) {
90218 BUG_ON(!PageCompound(page));
90219 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90220 /*
90221 * We may have set a slab to be unmergeable during bootstrap.
90222 */
90223 - if (s->refcount < 0)
90224 + if (atomic_read(&s->refcount) < 0)
90225 return 1;
90226
90227 return 0;
90228 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90229
90230 s = find_mergeable(memcg, size, align, flags, name, ctor);
90231 if (s) {
90232 - s->refcount++;
90233 + atomic_inc(&s->refcount);
90234 /*
90235 * Adjust the object sizes so that we clear
90236 * the complete object on kzalloc.
90237 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90238 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90239
90240 if (sysfs_slab_alias(s, name)) {
90241 - s->refcount--;
90242 + atomic_dec(&s->refcount);
90243 s = NULL;
90244 }
90245 }
90246 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90247 }
90248 #endif
90249
90250 -#ifdef CONFIG_SYSFS
90251 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90252 static int count_inuse(struct page *page)
90253 {
90254 return page->inuse;
90255 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90256 validate_slab_cache(kmalloc_caches[9]);
90257 }
90258 #else
90259 -#ifdef CONFIG_SYSFS
90260 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90261 static void resiliency_test(void) {};
90262 #endif
90263 #endif
90264
90265 -#ifdef CONFIG_SYSFS
90266 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90267 enum slab_stat_type {
90268 SL_ALL, /* All slabs */
90269 SL_PARTIAL, /* Only partially allocated slabs */
90270 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90271
90272 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90273 {
90274 - return sprintf(buf, "%d\n", s->refcount - 1);
90275 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90276 }
90277 SLAB_ATTR_RO(aliases);
90278
90279 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90280 SLAB_ATTR_RO(cache_dma);
90281 #endif
90282
90283 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90284 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90285 +{
90286 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90287 +}
90288 +SLAB_ATTR_RO(usercopy);
90289 +#endif
90290 +
90291 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90292 {
90293 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90294 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90295 #ifdef CONFIG_ZONE_DMA
90296 &cache_dma_attr.attr,
90297 #endif
90298 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90299 + &usercopy_attr.attr,
90300 +#endif
90301 #ifdef CONFIG_NUMA
90302 &remote_node_defrag_ratio_attr.attr,
90303 #endif
90304 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90305 return name;
90306 }
90307
90308 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90309 static int sysfs_slab_add(struct kmem_cache *s)
90310 {
90311 int err;
90312 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90313 }
90314
90315 s->kobj.kset = slab_kset;
90316 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90317 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90318 if (err) {
90319 kobject_put(&s->kobj);
90320 return err;
90321 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90322 kobject_del(&s->kobj);
90323 kobject_put(&s->kobj);
90324 }
90325 +#endif
90326
90327 /*
90328 * Need to buffer aliases during bootup until sysfs becomes
90329 @@ -5213,6 +5291,7 @@ struct saved_alias {
90330
90331 static struct saved_alias *alias_list;
90332
90333 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90334 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90335 {
90336 struct saved_alias *al;
90337 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90338 alias_list = al;
90339 return 0;
90340 }
90341 +#endif
90342
90343 static int __init slab_sysfs_init(void)
90344 {
90345 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90346 index 27eeab3..7c3f7f2 100644
90347 --- a/mm/sparse-vmemmap.c
90348 +++ b/mm/sparse-vmemmap.c
90349 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90350 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90351 if (!p)
90352 return NULL;
90353 - pud_populate(&init_mm, pud, p);
90354 + pud_populate_kernel(&init_mm, pud, p);
90355 }
90356 return pud;
90357 }
90358 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90359 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90360 if (!p)
90361 return NULL;
90362 - pgd_populate(&init_mm, pgd, p);
90363 + pgd_populate_kernel(&init_mm, pgd, p);
90364 }
90365 return pgd;
90366 }
90367 diff --git a/mm/sparse.c b/mm/sparse.c
90368 index 308d503..3dbbd04 100644
90369 --- a/mm/sparse.c
90370 +++ b/mm/sparse.c
90371 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90372
90373 for (i = 0; i < PAGES_PER_SECTION; i++) {
90374 if (PageHWPoison(&memmap[i])) {
90375 - atomic_long_sub(1, &num_poisoned_pages);
90376 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90377 ClearPageHWPoison(&memmap[i]);
90378 }
90379 }
90380 diff --git a/mm/swap.c b/mm/swap.c
90381 index c899502..d4dc2cd 100644
90382 --- a/mm/swap.c
90383 +++ b/mm/swap.c
90384 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90385
90386 __page_cache_release(page);
90387 dtor = get_compound_page_dtor(page);
90388 + if (!PageHuge(page))
90389 + BUG_ON(dtor != free_compound_page);
90390 (*dtor)(page);
90391 }
90392
90393 diff --git a/mm/swapfile.c b/mm/swapfile.c
90394 index 6cf2e60..d204b3e 100644
90395 --- a/mm/swapfile.c
90396 +++ b/mm/swapfile.c
90397 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90398
90399 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90400 /* Activity counter to indicate that a swapon or swapoff has occurred */
90401 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90402 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90403
90404 static inline unsigned char swap_count(unsigned char ent)
90405 {
90406 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90407 }
90408 filp_close(swap_file, NULL);
90409 err = 0;
90410 - atomic_inc(&proc_poll_event);
90411 + atomic_inc_unchecked(&proc_poll_event);
90412 wake_up_interruptible(&proc_poll_wait);
90413
90414 out_dput:
90415 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90416
90417 poll_wait(file, &proc_poll_wait, wait);
90418
90419 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90420 - seq->poll_event = atomic_read(&proc_poll_event);
90421 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90422 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90423 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90424 }
90425
90426 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90427 return ret;
90428
90429 seq = file->private_data;
90430 - seq->poll_event = atomic_read(&proc_poll_event);
90431 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90432 return 0;
90433 }
90434
90435 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90436 (frontswap_map) ? "FS" : "");
90437
90438 mutex_unlock(&swapon_mutex);
90439 - atomic_inc(&proc_poll_event);
90440 + atomic_inc_unchecked(&proc_poll_event);
90441 wake_up_interruptible(&proc_poll_wait);
90442
90443 if (S_ISREG(inode->i_mode))
90444 diff --git a/mm/util.c b/mm/util.c
90445 index 7441c41..c3de793 100644
90446 --- a/mm/util.c
90447 +++ b/mm/util.c
90448 @@ -294,6 +294,12 @@ done:
90449 void arch_pick_mmap_layout(struct mm_struct *mm)
90450 {
90451 mm->mmap_base = TASK_UNMAPPED_BASE;
90452 +
90453 +#ifdef CONFIG_PAX_RANDMMAP
90454 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90455 + mm->mmap_base += mm->delta_mmap;
90456 +#endif
90457 +
90458 mm->get_unmapped_area = arch_get_unmapped_area;
90459 }
90460 #endif
90461 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90462 index 13a5495..6707d97 100644
90463 --- a/mm/vmalloc.c
90464 +++ b/mm/vmalloc.c
90465 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90466
90467 pte = pte_offset_kernel(pmd, addr);
90468 do {
90469 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90470 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90471 +
90472 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90473 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90474 + BUG_ON(!pte_exec(*pte));
90475 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90476 + continue;
90477 + }
90478 +#endif
90479 +
90480 + {
90481 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90482 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90483 + }
90484 } while (pte++, addr += PAGE_SIZE, addr != end);
90485 }
90486
90487 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90488 pte = pte_alloc_kernel(pmd, addr);
90489 if (!pte)
90490 return -ENOMEM;
90491 +
90492 + pax_open_kernel();
90493 do {
90494 struct page *page = pages[*nr];
90495
90496 - if (WARN_ON(!pte_none(*pte)))
90497 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90498 + if (pgprot_val(prot) & _PAGE_NX)
90499 +#endif
90500 +
90501 + if (!pte_none(*pte)) {
90502 + pax_close_kernel();
90503 + WARN_ON(1);
90504 return -EBUSY;
90505 - if (WARN_ON(!page))
90506 + }
90507 + if (!page) {
90508 + pax_close_kernel();
90509 + WARN_ON(1);
90510 return -ENOMEM;
90511 + }
90512 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90513 (*nr)++;
90514 } while (pte++, addr += PAGE_SIZE, addr != end);
90515 + pax_close_kernel();
90516 return 0;
90517 }
90518
90519 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90520 pmd_t *pmd;
90521 unsigned long next;
90522
90523 - pmd = pmd_alloc(&init_mm, pud, addr);
90524 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90525 if (!pmd)
90526 return -ENOMEM;
90527 do {
90528 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90529 pud_t *pud;
90530 unsigned long next;
90531
90532 - pud = pud_alloc(&init_mm, pgd, addr);
90533 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90534 if (!pud)
90535 return -ENOMEM;
90536 do {
90537 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90538 if (addr >= MODULES_VADDR && addr < MODULES_END)
90539 return 1;
90540 #endif
90541 +
90542 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90543 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90544 + return 1;
90545 +#endif
90546 +
90547 return is_vmalloc_addr(x);
90548 }
90549
90550 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90551
90552 if (!pgd_none(*pgd)) {
90553 pud_t *pud = pud_offset(pgd, addr);
90554 +#ifdef CONFIG_X86
90555 + if (!pud_large(*pud))
90556 +#endif
90557 if (!pud_none(*pud)) {
90558 pmd_t *pmd = pmd_offset(pud, addr);
90559 +#ifdef CONFIG_X86
90560 + if (!pmd_large(*pmd))
90561 +#endif
90562 if (!pmd_none(*pmd)) {
90563 pte_t *ptep, pte;
90564
90565 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90566 * Allocate a region of KVA of the specified size and alignment, within the
90567 * vstart and vend.
90568 */
90569 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90570 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90571 unsigned long align,
90572 unsigned long vstart, unsigned long vend,
90573 int node, gfp_t gfp_mask)
90574 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90575 struct vm_struct *area;
90576
90577 BUG_ON(in_interrupt());
90578 +
90579 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90580 + if (flags & VM_KERNEXEC) {
90581 + if (start != VMALLOC_START || end != VMALLOC_END)
90582 + return NULL;
90583 + start = (unsigned long)MODULES_EXEC_VADDR;
90584 + end = (unsigned long)MODULES_EXEC_END;
90585 + }
90586 +#endif
90587 +
90588 if (flags & VM_IOREMAP)
90589 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90590
90591 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90592 if (count > totalram_pages)
90593 return NULL;
90594
90595 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90596 + if (!(pgprot_val(prot) & _PAGE_NX))
90597 + flags |= VM_KERNEXEC;
90598 +#endif
90599 +
90600 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90601 __builtin_return_address(0));
90602 if (!area)
90603 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90604 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90605 goto fail;
90606
90607 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90608 + if (!(pgprot_val(prot) & _PAGE_NX))
90609 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90610 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90611 + else
90612 +#endif
90613 +
90614 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90615 start, end, node, gfp_mask, caller);
90616 if (!area)
90617 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90618 * For tight control over page level allocator and protection flags
90619 * use __vmalloc() instead.
90620 */
90621 -
90622 void *vmalloc_exec(unsigned long size)
90623 {
90624 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90625 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90626 NUMA_NO_NODE, __builtin_return_address(0));
90627 }
90628
90629 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90630 {
90631 struct vm_struct *area;
90632
90633 + BUG_ON(vma->vm_mirror);
90634 +
90635 size = PAGE_ALIGN(size);
90636
90637 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90638 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90639 v->addr, v->addr + v->size, v->size);
90640
90641 if (v->caller)
90642 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90643 + seq_printf(m, " %pK", v->caller);
90644 +#else
90645 seq_printf(m, " %pS", v->caller);
90646 +#endif
90647
90648 if (v->nr_pages)
90649 seq_printf(m, " pages=%d", v->nr_pages);
90650 diff --git a/mm/vmstat.c b/mm/vmstat.c
90651 index 20c2ef4..15e7ab7 100644
90652 --- a/mm/vmstat.c
90653 +++ b/mm/vmstat.c
90654 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90655 *
90656 * vm_stat contains the global counters
90657 */
90658 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90659 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90660 EXPORT_SYMBOL(vm_stat);
90661
90662 #ifdef CONFIG_SMP
90663 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90664 v = p->vm_stat_diff[i];
90665 p->vm_stat_diff[i] = 0;
90666 local_irq_restore(flags);
90667 - atomic_long_add(v, &zone->vm_stat[i]);
90668 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90669 global_diff[i] += v;
90670 #ifdef CONFIG_NUMA
90671 /* 3 seconds idle till flush */
90672 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90673
90674 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90675 if (global_diff[i])
90676 - atomic_long_add(global_diff[i], &vm_stat[i]);
90677 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90678 }
90679
90680 /*
90681 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90682 if (pset->vm_stat_diff[i]) {
90683 int v = pset->vm_stat_diff[i];
90684 pset->vm_stat_diff[i] = 0;
90685 - atomic_long_add(v, &zone->vm_stat[i]);
90686 - atomic_long_add(v, &vm_stat[i]);
90687 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90688 + atomic_long_add_unchecked(v, &vm_stat[i]);
90689 }
90690 }
90691 #endif
90692 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90693 start_cpu_timer(cpu);
90694 #endif
90695 #ifdef CONFIG_PROC_FS
90696 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90697 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90698 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90699 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90700 + {
90701 + mode_t gr_mode = S_IRUGO;
90702 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90703 + gr_mode = S_IRUSR;
90704 +#endif
90705 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90706 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90707 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90708 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90709 +#else
90710 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90711 +#endif
90712 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90713 + }
90714 #endif
90715 return 0;
90716 }
90717 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90718 index 2fb2d88..8c06e40 100644
90719 --- a/net/8021q/vlan.c
90720 +++ b/net/8021q/vlan.c
90721 @@ -469,7 +469,7 @@ out:
90722 return NOTIFY_DONE;
90723 }
90724
90725 -static struct notifier_block vlan_notifier_block __read_mostly = {
90726 +static struct notifier_block vlan_notifier_block = {
90727 .notifier_call = vlan_device_event,
90728 };
90729
90730 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90731 err = -EPERM;
90732 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90733 break;
90734 - if ((args.u.name_type >= 0) &&
90735 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90736 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90737 struct vlan_net *vn;
90738
90739 vn = net_generic(net, vlan_net_id);
90740 diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
90741 index 3091297..c7e634a 100644
90742 --- a/net/8021q/vlan_netlink.c
90743 +++ b/net/8021q/vlan_netlink.c
90744 @@ -171,7 +171,7 @@ static size_t vlan_get_size(const struct net_device *dev)
90745
90746 return nla_total_size(2) + /* IFLA_VLAN_PROTOCOL */
90747 nla_total_size(2) + /* IFLA_VLAN_ID */
90748 - sizeof(struct ifla_vlan_flags) + /* IFLA_VLAN_FLAGS */
90749 + nla_total_size(sizeof(struct ifla_vlan_flags)) + /* IFLA_VLAN_FLAGS */
90750 vlan_qos_map_size(vlan->nr_ingress_mappings) +
90751 vlan_qos_map_size(vlan->nr_egress_mappings);
90752 }
90753 diff --git a/net/9p/mod.c b/net/9p/mod.c
90754 index 6ab36ae..6f1841b 100644
90755 --- a/net/9p/mod.c
90756 +++ b/net/9p/mod.c
90757 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90758 void v9fs_register_trans(struct p9_trans_module *m)
90759 {
90760 spin_lock(&v9fs_trans_lock);
90761 - list_add_tail(&m->list, &v9fs_trans_list);
90762 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90763 spin_unlock(&v9fs_trans_lock);
90764 }
90765 EXPORT_SYMBOL(v9fs_register_trans);
90766 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90767 void v9fs_unregister_trans(struct p9_trans_module *m)
90768 {
90769 spin_lock(&v9fs_trans_lock);
90770 - list_del_init(&m->list);
90771 + pax_list_del_init((struct list_head *)&m->list);
90772 spin_unlock(&v9fs_trans_lock);
90773 }
90774 EXPORT_SYMBOL(v9fs_unregister_trans);
90775 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90776 index 3ffda1b..fceac96 100644
90777 --- a/net/9p/trans_fd.c
90778 +++ b/net/9p/trans_fd.c
90779 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90780 oldfs = get_fs();
90781 set_fs(get_ds());
90782 /* The cast to a user pointer is valid due to the set_fs() */
90783 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90784 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90785 set_fs(oldfs);
90786
90787 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90788 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90789 index 876fbe8..8bbea9f 100644
90790 --- a/net/atm/atm_misc.c
90791 +++ b/net/atm/atm_misc.c
90792 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90793 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90794 return 1;
90795 atm_return(vcc, truesize);
90796 - atomic_inc(&vcc->stats->rx_drop);
90797 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90798 return 0;
90799 }
90800 EXPORT_SYMBOL(atm_charge);
90801 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90802 }
90803 }
90804 atm_return(vcc, guess);
90805 - atomic_inc(&vcc->stats->rx_drop);
90806 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90807 return NULL;
90808 }
90809 EXPORT_SYMBOL(atm_alloc_charge);
90810 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90811
90812 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90813 {
90814 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90815 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90816 __SONET_ITEMS
90817 #undef __HANDLE_ITEM
90818 }
90819 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90820
90821 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90822 {
90823 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90824 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90825 __SONET_ITEMS
90826 #undef __HANDLE_ITEM
90827 }
90828 diff --git a/net/atm/lec.h b/net/atm/lec.h
90829 index 4149db1..f2ab682 100644
90830 --- a/net/atm/lec.h
90831 +++ b/net/atm/lec.h
90832 @@ -48,7 +48,7 @@ struct lane2_ops {
90833 const u8 *tlvs, u32 sizeoftlvs);
90834 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90835 const u8 *tlvs, u32 sizeoftlvs);
90836 -};
90837 +} __no_const;
90838
90839 /*
90840 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90841 diff --git a/net/atm/proc.c b/net/atm/proc.c
90842 index bbb6461..cf04016 100644
90843 --- a/net/atm/proc.c
90844 +++ b/net/atm/proc.c
90845 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90846 const struct k_atm_aal_stats *stats)
90847 {
90848 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90849 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90850 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90851 - atomic_read(&stats->rx_drop));
90852 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90853 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90854 + atomic_read_unchecked(&stats->rx_drop));
90855 }
90856
90857 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90858 diff --git a/net/atm/resources.c b/net/atm/resources.c
90859 index 0447d5d..3cf4728 100644
90860 --- a/net/atm/resources.c
90861 +++ b/net/atm/resources.c
90862 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90863 static void copy_aal_stats(struct k_atm_aal_stats *from,
90864 struct atm_aal_stats *to)
90865 {
90866 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90867 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90868 __AAL_STAT_ITEMS
90869 #undef __HANDLE_ITEM
90870 }
90871 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90872 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90873 struct atm_aal_stats *to)
90874 {
90875 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90876 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90877 __AAL_STAT_ITEMS
90878 #undef __HANDLE_ITEM
90879 }
90880 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90881 index 919a5ce..cc6b444 100644
90882 --- a/net/ax25/sysctl_net_ax25.c
90883 +++ b/net/ax25/sysctl_net_ax25.c
90884 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90885 {
90886 char path[sizeof("net/ax25/") + IFNAMSIZ];
90887 int k;
90888 - struct ctl_table *table;
90889 + ctl_table_no_const *table;
90890
90891 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90892 if (!table)
90893 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90894 index 62da527..aa27535 100644
90895 --- a/net/batman-adv/bat_iv_ogm.c
90896 +++ b/net/batman-adv/bat_iv_ogm.c
90897 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90898
90899 /* randomize initial seqno to avoid collision */
90900 get_random_bytes(&random_seqno, sizeof(random_seqno));
90901 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90902 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90903
90904 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90905 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90906 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90907 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90908
90909 /* change sequence number to network order */
90910 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90911 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90912 batadv_ogm_packet->seqno = htonl(seqno);
90913 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90914 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90915
90916 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90917 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90918 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90919 return;
90920
90921 /* could be changed by schedule_own_packet() */
90922 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90923 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90924
90925 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90926 has_directlink_flag = 1;
90927 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90928 index c478e6b..469fd2f 100644
90929 --- a/net/batman-adv/hard-interface.c
90930 +++ b/net/batman-adv/hard-interface.c
90931 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90932 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90933 dev_add_pack(&hard_iface->batman_adv_ptype);
90934
90935 - atomic_set(&hard_iface->frag_seqno, 1);
90936 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90937 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90938 hard_iface->net_dev->name);
90939
90940 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90941 index 33b6144..3212ac5 100644
90942 --- a/net/batman-adv/soft-interface.c
90943 +++ b/net/batman-adv/soft-interface.c
90944 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90945 primary_if->net_dev->dev_addr, ETH_ALEN);
90946
90947 /* set broadcast sequence number */
90948 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90949 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90950 bcast_packet->seqno = htonl(seqno);
90951
90952 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90953 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90954 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90955
90956 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90957 - atomic_set(&bat_priv->bcast_seqno, 1);
90958 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90959 atomic_set(&bat_priv->tt.vn, 0);
90960 atomic_set(&bat_priv->tt.local_changes, 0);
90961 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90962 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90963 index b2c94e1..3d47e07 100644
90964 --- a/net/batman-adv/types.h
90965 +++ b/net/batman-adv/types.h
90966 @@ -51,7 +51,7 @@
90967 struct batadv_hard_iface_bat_iv {
90968 unsigned char *ogm_buff;
90969 int ogm_buff_len;
90970 - atomic_t ogm_seqno;
90971 + atomic_unchecked_t ogm_seqno;
90972 };
90973
90974 /**
90975 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90976 int16_t if_num;
90977 char if_status;
90978 struct net_device *net_dev;
90979 - atomic_t frag_seqno;
90980 + atomic_unchecked_t frag_seqno;
90981 uint8_t num_bcasts;
90982 struct kobject *hardif_obj;
90983 atomic_t refcount;
90984 @@ -560,7 +560,7 @@ struct batadv_priv {
90985 #ifdef CONFIG_BATMAN_ADV_DEBUG
90986 atomic_t log_level;
90987 #endif
90988 - atomic_t bcast_seqno;
90989 + atomic_unchecked_t bcast_seqno;
90990 atomic_t bcast_queue_left;
90991 atomic_t batman_queue_left;
90992 char num_ifaces;
90993 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
90994 index 857e1b8..5ad07b2 100644
90995 --- a/net/batman-adv/unicast.c
90996 +++ b/net/batman-adv/unicast.c
90997 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
90998 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
90999 frag2->flags = large_tail;
91000
91001 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91002 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91003 frag1->seqno = htons(seqno - 1);
91004 frag2->seqno = htons(seqno);
91005
91006 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91007 index 9bd7d95..6c4884f 100644
91008 --- a/net/bluetooth/hci_sock.c
91009 +++ b/net/bluetooth/hci_sock.c
91010 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91011 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91012 }
91013
91014 - len = min_t(unsigned int, len, sizeof(uf));
91015 + len = min((size_t)len, sizeof(uf));
91016 if (copy_from_user(&uf, optval, len)) {
91017 err = -EFAULT;
91018 break;
91019 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91020 index 8c3499b..2661c6a 100644
91021 --- a/net/bluetooth/l2cap_core.c
91022 +++ b/net/bluetooth/l2cap_core.c
91023 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91024 break;
91025
91026 case L2CAP_CONF_RFC:
91027 - if (olen == sizeof(rfc))
91028 - memcpy(&rfc, (void *)val, olen);
91029 + if (olen != sizeof(rfc))
91030 + break;
91031 +
91032 + memcpy(&rfc, (void *)val, olen);
91033
91034 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
91035 rfc.mode != chan->mode)
91036 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
91037 index 0098af8..fb5a31f 100644
91038 --- a/net/bluetooth/l2cap_sock.c
91039 +++ b/net/bluetooth/l2cap_sock.c
91040 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91041 struct sock *sk = sock->sk;
91042 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
91043 struct l2cap_options opts;
91044 - int len, err = 0;
91045 + int err = 0;
91046 + size_t len = optlen;
91047 u32 opt;
91048
91049 BT_DBG("sk %p", sk);
91050 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91051 opts.max_tx = chan->max_tx;
91052 opts.txwin_size = chan->tx_win;
91053
91054 - len = min_t(unsigned int, sizeof(opts), optlen);
91055 + len = min(sizeof(opts), len);
91056 if (copy_from_user((char *) &opts, optval, len)) {
91057 err = -EFAULT;
91058 break;
91059 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91060 struct bt_security sec;
91061 struct bt_power pwr;
91062 struct l2cap_conn *conn;
91063 - int len, err = 0;
91064 + int err = 0;
91065 + size_t len = optlen;
91066 u32 opt;
91067
91068 BT_DBG("sk %p", sk);
91069 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91070
91071 sec.level = BT_SECURITY_LOW;
91072
91073 - len = min_t(unsigned int, sizeof(sec), optlen);
91074 + len = min(sizeof(sec), len);
91075 if (copy_from_user((char *) &sec, optval, len)) {
91076 err = -EFAULT;
91077 break;
91078 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91079
91080 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91081
91082 - len = min_t(unsigned int, sizeof(pwr), optlen);
91083 + len = min(sizeof(pwr), len);
91084 if (copy_from_user((char *) &pwr, optval, len)) {
91085 err = -EFAULT;
91086 break;
91087 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91088 index 30b3721..c1bd0a0 100644
91089 --- a/net/bluetooth/rfcomm/sock.c
91090 +++ b/net/bluetooth/rfcomm/sock.c
91091 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91092 struct sock *sk = sock->sk;
91093 struct bt_security sec;
91094 int err = 0;
91095 - size_t len;
91096 + size_t len = optlen;
91097 u32 opt;
91098
91099 BT_DBG("sk %p", sk);
91100 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91101
91102 sec.level = BT_SECURITY_LOW;
91103
91104 - len = min_t(unsigned int, sizeof(sec), optlen);
91105 + len = min(sizeof(sec), len);
91106 if (copy_from_user((char *) &sec, optval, len)) {
91107 err = -EFAULT;
91108 break;
91109 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91110 index b6e44ad..5b0d514 100644
91111 --- a/net/bluetooth/rfcomm/tty.c
91112 +++ b/net/bluetooth/rfcomm/tty.c
91113 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91114 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91115
91116 spin_lock_irqsave(&dev->port.lock, flags);
91117 - if (dev->port.count > 0) {
91118 + if (atomic_read(&dev->port.count) > 0) {
91119 spin_unlock_irqrestore(&dev->port.lock, flags);
91120 return;
91121 }
91122 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91123 return -ENODEV;
91124
91125 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91126 - dev->channel, dev->port.count);
91127 + dev->channel, atomic_read(&dev->port.count));
91128
91129 spin_lock_irqsave(&dev->port.lock, flags);
91130 - if (++dev->port.count > 1) {
91131 + if (atomic_inc_return(&dev->port.count) > 1) {
91132 spin_unlock_irqrestore(&dev->port.lock, flags);
91133 return 0;
91134 }
91135 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91136 return;
91137
91138 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91139 - dev->port.count);
91140 + atomic_read(&dev->port.count));
91141
91142 spin_lock_irqsave(&dev->port.lock, flags);
91143 - if (!--dev->port.count) {
91144 + if (!atomic_dec_return(&dev->port.count)) {
91145 spin_unlock_irqrestore(&dev->port.lock, flags);
91146 if (dev->tty_dev->parent)
91147 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91148 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
91149 index 5180938..7c470c3 100644
91150 --- a/net/bridge/netfilter/ebt_ulog.c
91151 +++ b/net/bridge/netfilter/ebt_ulog.c
91152 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91153 ub->qlen++;
91154
91155 pm = nlmsg_data(nlh);
91156 + memset(pm, 0, sizeof(*pm));
91157
91158 /* Fill in the ulog data */
91159 pm->version = EBT_ULOG_VERSION;
91160 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91161 pm->hook = hooknr;
91162 if (uloginfo->prefix != NULL)
91163 strcpy(pm->prefix, uloginfo->prefix);
91164 - else
91165 - *(pm->prefix) = '\0';
91166
91167 if (in) {
91168 strcpy(pm->physindev, in->name);
91169 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91170 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
91171 else
91172 strcpy(pm->indev, in->name);
91173 - } else
91174 - pm->indev[0] = pm->physindev[0] = '\0';
91175 + }
91176
91177 if (out) {
91178 /* If out exists, then out is a bridge port */
91179 strcpy(pm->physoutdev, out->name);
91180 /* rcu_read_lock()ed by nf_hook_slow */
91181 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
91182 - } else
91183 - pm->outdev[0] = pm->physoutdev[0] = '\0';
91184 + }
91185
91186 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
91187 BUG();
91188 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91189 index ac78024..161a80c 100644
91190 --- a/net/bridge/netfilter/ebtables.c
91191 +++ b/net/bridge/netfilter/ebtables.c
91192 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91193 tmp.valid_hooks = t->table->valid_hooks;
91194 }
91195 mutex_unlock(&ebt_mutex);
91196 - if (copy_to_user(user, &tmp, *len) != 0){
91197 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91198 BUGPRINT("c2u Didn't work\n");
91199 ret = -EFAULT;
91200 break;
91201 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91202 goto out;
91203 tmp.valid_hooks = t->valid_hooks;
91204
91205 - if (copy_to_user(user, &tmp, *len) != 0) {
91206 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91207 ret = -EFAULT;
91208 break;
91209 }
91210 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91211 tmp.entries_size = t->table->entries_size;
91212 tmp.valid_hooks = t->table->valid_hooks;
91213
91214 - if (copy_to_user(user, &tmp, *len) != 0) {
91215 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91216 ret = -EFAULT;
91217 break;
91218 }
91219 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91220 index 0f45522..dab651f 100644
91221 --- a/net/caif/cfctrl.c
91222 +++ b/net/caif/cfctrl.c
91223 @@ -10,6 +10,7 @@
91224 #include <linux/spinlock.h>
91225 #include <linux/slab.h>
91226 #include <linux/pkt_sched.h>
91227 +#include <linux/sched.h>
91228 #include <net/caif/caif_layer.h>
91229 #include <net/caif/cfpkt.h>
91230 #include <net/caif/cfctrl.h>
91231 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91232 memset(&dev_info, 0, sizeof(dev_info));
91233 dev_info.id = 0xff;
91234 cfsrvl_init(&this->serv, 0, &dev_info, false);
91235 - atomic_set(&this->req_seq_no, 1);
91236 - atomic_set(&this->rsp_seq_no, 1);
91237 + atomic_set_unchecked(&this->req_seq_no, 1);
91238 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91239 this->serv.layer.receive = cfctrl_recv;
91240 sprintf(this->serv.layer.name, "ctrl");
91241 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91242 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91243 struct cfctrl_request_info *req)
91244 {
91245 spin_lock_bh(&ctrl->info_list_lock);
91246 - atomic_inc(&ctrl->req_seq_no);
91247 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91248 + atomic_inc_unchecked(&ctrl->req_seq_no);
91249 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91250 list_add_tail(&req->list, &ctrl->list);
91251 spin_unlock_bh(&ctrl->info_list_lock);
91252 }
91253 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91254 if (p != first)
91255 pr_warn("Requests are not received in order\n");
91256
91257 - atomic_set(&ctrl->rsp_seq_no,
91258 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91259 p->sequence_no);
91260 list_del(&p->list);
91261 goto out;
91262 diff --git a/net/can/af_can.c b/net/can/af_can.c
91263 index 3ab8dd2..b9aef13 100644
91264 --- a/net/can/af_can.c
91265 +++ b/net/can/af_can.c
91266 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91267 };
91268
91269 /* notifier block for netdevice event */
91270 -static struct notifier_block can_netdev_notifier __read_mostly = {
91271 +static struct notifier_block can_netdev_notifier = {
91272 .notifier_call = can_notifier,
91273 };
91274
91275 diff --git a/net/can/gw.c b/net/can/gw.c
91276 index 2f291f9..98c986a 100644
91277 --- a/net/can/gw.c
91278 +++ b/net/can/gw.c
91279 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91280 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91281
91282 static HLIST_HEAD(cgw_list);
91283 -static struct notifier_block notifier;
91284
91285 static struct kmem_cache *cgw_cache __read_mostly;
91286
91287 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91288 return err;
91289 }
91290
91291 +static struct notifier_block notifier = {
91292 + .notifier_call = cgw_notifier
91293 +};
91294 +
91295 static __init int cgw_module_init(void)
91296 {
91297 /* sanitize given module parameter */
91298 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91299 return -ENOMEM;
91300
91301 /* set notifier */
91302 - notifier.notifier_call = cgw_notifier;
91303 register_netdevice_notifier(&notifier);
91304
91305 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91306 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91307 index eb0a46a..5f3bae8 100644
91308 --- a/net/ceph/messenger.c
91309 +++ b/net/ceph/messenger.c
91310 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91311 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91312
91313 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91314 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91315 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91316
91317 static struct page *zero_page; /* used in certain error cases */
91318
91319 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91320 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91321 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91322
91323 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91324 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91325 s = addr_str[i];
91326
91327 switch (ss->ss_family) {
91328 diff --git a/net/compat.c b/net/compat.c
91329 index f0a1ba6..24e30e5 100644
91330 --- a/net/compat.c
91331 +++ b/net/compat.c
91332 @@ -71,9 +71,11 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91333 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
91334 __get_user(kmsg->msg_flags, &umsg->msg_flags))
91335 return -EFAULT;
91336 - kmsg->msg_name = compat_ptr(tmp1);
91337 - kmsg->msg_iov = compat_ptr(tmp2);
91338 - kmsg->msg_control = compat_ptr(tmp3);
91339 + if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
91340 + return -EINVAL;
91341 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91342 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91343 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91344 return 0;
91345 }
91346
91347 @@ -85,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91348
91349 if (kern_msg->msg_namelen) {
91350 if (mode == VERIFY_READ) {
91351 - int err = move_addr_to_kernel(kern_msg->msg_name,
91352 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91353 kern_msg->msg_namelen,
91354 kern_address);
91355 if (err < 0)
91356 @@ -96,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91357 kern_msg->msg_name = NULL;
91358
91359 tot_len = iov_from_user_compat_to_kern(kern_iov,
91360 - (struct compat_iovec __user *)kern_msg->msg_iov,
91361 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91362 kern_msg->msg_iovlen);
91363 if (tot_len >= 0)
91364 kern_msg->msg_iov = kern_iov;
91365 @@ -116,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91366
91367 #define CMSG_COMPAT_FIRSTHDR(msg) \
91368 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91369 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91370 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91371 (struct compat_cmsghdr __user *)NULL)
91372
91373 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91374 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91375 (ucmlen) <= (unsigned long) \
91376 ((mhdr)->msg_controllen - \
91377 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91378 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91379
91380 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91381 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91382 {
91383 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91384 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91385 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91386 msg->msg_controllen)
91387 return NULL;
91388 return (struct compat_cmsghdr __user *)ptr;
91389 @@ -219,7 +221,7 @@ Efault:
91390
91391 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91392 {
91393 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91394 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91395 struct compat_cmsghdr cmhdr;
91396 struct compat_timeval ctv;
91397 struct compat_timespec cts[3];
91398 @@ -275,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91399
91400 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91401 {
91402 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91403 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91404 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91405 int fdnum = scm->fp->count;
91406 struct file **fp = scm->fp->fp;
91407 @@ -363,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91408 return -EFAULT;
91409 old_fs = get_fs();
91410 set_fs(KERNEL_DS);
91411 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91412 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91413 set_fs(old_fs);
91414
91415 return err;
91416 @@ -424,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91417 len = sizeof(ktime);
91418 old_fs = get_fs();
91419 set_fs(KERNEL_DS);
91420 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91421 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91422 set_fs(old_fs);
91423
91424 if (!err) {
91425 @@ -567,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91426 case MCAST_JOIN_GROUP:
91427 case MCAST_LEAVE_GROUP:
91428 {
91429 - struct compat_group_req __user *gr32 = (void *)optval;
91430 + struct compat_group_req __user *gr32 = (void __user *)optval;
91431 struct group_req __user *kgr =
91432 compat_alloc_user_space(sizeof(struct group_req));
91433 u32 interface;
91434 @@ -588,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91435 case MCAST_BLOCK_SOURCE:
91436 case MCAST_UNBLOCK_SOURCE:
91437 {
91438 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91439 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91440 struct group_source_req __user *kgsr = compat_alloc_user_space(
91441 sizeof(struct group_source_req));
91442 u32 interface;
91443 @@ -609,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91444 }
91445 case MCAST_MSFILTER:
91446 {
91447 - struct compat_group_filter __user *gf32 = (void *)optval;
91448 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91449 struct group_filter __user *kgf;
91450 u32 interface, fmode, numsrc;
91451
91452 @@ -647,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91453 char __user *optval, int __user *optlen,
91454 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91455 {
91456 - struct compat_group_filter __user *gf32 = (void *)optval;
91457 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91458 struct group_filter __user *kgf;
91459 int __user *koptlen;
91460 u32 interface, fmode, numsrc;
91461 @@ -805,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91462
91463 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91464 return -EINVAL;
91465 - if (copy_from_user(a, args, nas[call]))
91466 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91467 return -EFAULT;
91468 a0 = a[0];
91469 a1 = a[1];
91470 diff --git a/net/core/datagram.c b/net/core/datagram.c
91471 index 8ab48cd..57b1a80 100644
91472 --- a/net/core/datagram.c
91473 +++ b/net/core/datagram.c
91474 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91475 }
91476
91477 kfree_skb(skb);
91478 - atomic_inc(&sk->sk_drops);
91479 + atomic_inc_unchecked(&sk->sk_drops);
91480 sk_mem_reclaim_partial(sk);
91481
91482 return err;
91483 diff --git a/net/core/dev.c b/net/core/dev.c
91484 index 26755dd..2a232de 100644
91485 --- a/net/core/dev.c
91486 +++ b/net/core/dev.c
91487 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91488 {
91489 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91490 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91491 - atomic_long_inc(&dev->rx_dropped);
91492 + atomic_long_inc_unchecked(&dev->rx_dropped);
91493 kfree_skb(skb);
91494 return NET_RX_DROP;
91495 }
91496 }
91497
91498 if (unlikely(!is_skb_forwardable(dev, skb))) {
91499 - atomic_long_inc(&dev->rx_dropped);
91500 + atomic_long_inc_unchecked(&dev->rx_dropped);
91501 kfree_skb(skb);
91502 return NET_RX_DROP;
91503 }
91504 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91505
91506 struct dev_gso_cb {
91507 void (*destructor)(struct sk_buff *skb);
91508 -};
91509 +} __no_const;
91510
91511 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91512
91513 @@ -3206,7 +3206,7 @@ enqueue:
91514
91515 local_irq_restore(flags);
91516
91517 - atomic_long_inc(&skb->dev->rx_dropped);
91518 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91519 kfree_skb(skb);
91520 return NET_RX_DROP;
91521 }
91522 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91523 }
91524 EXPORT_SYMBOL(netif_rx_ni);
91525
91526 -static void net_tx_action(struct softirq_action *h)
91527 +static __latent_entropy void net_tx_action(void)
91528 {
91529 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91530
91531 @@ -3612,7 +3612,7 @@ ncls:
91532 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91533 } else {
91534 drop:
91535 - atomic_long_inc(&skb->dev->rx_dropped);
91536 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91537 kfree_skb(skb);
91538 /* Jamal, now you will not able to escape explaining
91539 * me how you were going to use this. :-)
91540 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91541 }
91542 EXPORT_SYMBOL(netif_napi_del);
91543
91544 -static void net_rx_action(struct softirq_action *h)
91545 +static __latent_entropy void net_rx_action(void)
91546 {
91547 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91548 unsigned long time_limit = jiffies + 2;
91549 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91550 } else {
91551 netdev_stats_to_stats64(storage, &dev->stats);
91552 }
91553 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91554 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91555 return storage;
91556 }
91557 EXPORT_SYMBOL(dev_get_stats);
91558 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91559 index 5b7d0e1..cb960fc 100644
91560 --- a/net/core/dev_ioctl.c
91561 +++ b/net/core/dev_ioctl.c
91562 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91563 if (no_module && capable(CAP_NET_ADMIN))
91564 no_module = request_module("netdev-%s", name);
91565 if (no_module && capable(CAP_SYS_MODULE)) {
91566 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91567 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91568 +#else
91569 if (!request_module("%s", name))
91570 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91571 name);
91572 +#endif
91573 }
91574 }
91575 EXPORT_SYMBOL(dev_load);
91576 diff --git a/net/core/flow.c b/net/core/flow.c
91577 index dfa602c..3103d88 100644
91578 --- a/net/core/flow.c
91579 +++ b/net/core/flow.c
91580 @@ -61,7 +61,7 @@ struct flow_cache {
91581 struct timer_list rnd_timer;
91582 };
91583
91584 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91585 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91586 EXPORT_SYMBOL(flow_cache_genid);
91587 static struct flow_cache flow_cache_global;
91588 static struct kmem_cache *flow_cachep __read_mostly;
91589 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91590
91591 static int flow_entry_valid(struct flow_cache_entry *fle)
91592 {
91593 - if (atomic_read(&flow_cache_genid) != fle->genid)
91594 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91595 return 0;
91596 if (fle->object && !fle->object->ops->check(fle->object))
91597 return 0;
91598 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91599 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91600 fcp->hash_count++;
91601 }
91602 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91603 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91604 flo = fle->object;
91605 if (!flo)
91606 goto ret_object;
91607 @@ -279,7 +279,7 @@ nocache:
91608 }
91609 flo = resolver(net, key, family, dir, flo, ctx);
91610 if (fle) {
91611 - fle->genid = atomic_read(&flow_cache_genid);
91612 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91613 if (!IS_ERR(flo))
91614 fle->object = flo;
91615 else
91616 diff --git a/net/core/iovec.c b/net/core/iovec.c
91617 index de178e4..1dabd8b 100644
91618 --- a/net/core/iovec.c
91619 +++ b/net/core/iovec.c
91620 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91621 if (m->msg_namelen) {
91622 if (mode == VERIFY_READ) {
91623 void __user *namep;
91624 - namep = (void __user __force *) m->msg_name;
91625 + namep = (void __force_user *) m->msg_name;
91626 err = move_addr_to_kernel(namep, m->msg_namelen,
91627 address);
91628 if (err < 0)
91629 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91630 }
91631
91632 size = m->msg_iovlen * sizeof(struct iovec);
91633 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91634 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91635 return -EFAULT;
91636
91637 m->msg_iov = iov;
91638 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91639 index 60533db..14842cc 100644
91640 --- a/net/core/neighbour.c
91641 +++ b/net/core/neighbour.c
91642 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91643 void __user *buffer, size_t *lenp, loff_t *ppos)
91644 {
91645 int size, ret;
91646 - struct ctl_table tmp = *ctl;
91647 + ctl_table_no_const tmp = *ctl;
91648
91649 tmp.extra1 = &zero;
91650 tmp.extra2 = &unres_qlen_max;
91651 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91652 index 2bf8329..7960607 100644
91653 --- a/net/core/net-procfs.c
91654 +++ b/net/core/net-procfs.c
91655 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91656 else
91657 seq_printf(seq, "%04x", ntohs(pt->type));
91658
91659 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91660 + seq_printf(seq, " %-8s %pf\n",
91661 + pt->dev ? pt->dev->name : "", NULL);
91662 +#else
91663 seq_printf(seq, " %-8s %pf\n",
91664 pt->dev ? pt->dev->name : "", pt->func);
91665 +#endif
91666 }
91667
91668 return 0;
91669 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91670 index 981fed3..536af34 100644
91671 --- a/net/core/net-sysfs.c
91672 +++ b/net/core/net-sysfs.c
91673 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91674 }
91675 EXPORT_SYMBOL(netdev_class_remove_file);
91676
91677 -int netdev_kobject_init(void)
91678 +int __init netdev_kobject_init(void)
91679 {
91680 kobj_ns_type_register(&net_ns_type_operations);
91681 return class_register(&net_class);
91682 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91683 index f9765203..9feaef8 100644
91684 --- a/net/core/net_namespace.c
91685 +++ b/net/core/net_namespace.c
91686 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91687 int error;
91688 LIST_HEAD(net_exit_list);
91689
91690 - list_add_tail(&ops->list, list);
91691 + pax_list_add_tail((struct list_head *)&ops->list, list);
91692 if (ops->init || (ops->id && ops->size)) {
91693 for_each_net(net) {
91694 error = ops_init(ops, net);
91695 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91696
91697 out_undo:
91698 /* If I have an error cleanup all namespaces I initialized */
91699 - list_del(&ops->list);
91700 + pax_list_del((struct list_head *)&ops->list);
91701 ops_exit_list(ops, &net_exit_list);
91702 ops_free_list(ops, &net_exit_list);
91703 return error;
91704 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91705 struct net *net;
91706 LIST_HEAD(net_exit_list);
91707
91708 - list_del(&ops->list);
91709 + pax_list_del((struct list_head *)&ops->list);
91710 for_each_net(net)
91711 list_add_tail(&net->exit_list, &net_exit_list);
91712 ops_exit_list(ops, &net_exit_list);
91713 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91714 mutex_lock(&net_mutex);
91715 error = register_pernet_operations(&pernet_list, ops);
91716 if (!error && (first_device == &pernet_list))
91717 - first_device = &ops->list;
91718 + first_device = (struct list_head *)&ops->list;
91719 mutex_unlock(&net_mutex);
91720 return error;
91721 }
91722 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91723 index fc75c9e..8c8e9be 100644
91724 --- a/net/core/netpoll.c
91725 +++ b/net/core/netpoll.c
91726 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91727 struct udphdr *udph;
91728 struct iphdr *iph;
91729 struct ethhdr *eth;
91730 - static atomic_t ip_ident;
91731 + static atomic_unchecked_t ip_ident;
91732 struct ipv6hdr *ip6h;
91733
91734 udp_len = len + sizeof(*udph);
91735 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91736 put_unaligned(0x45, (unsigned char *)iph);
91737 iph->tos = 0;
91738 put_unaligned(htons(ip_len), &(iph->tot_len));
91739 - iph->id = htons(atomic_inc_return(&ip_ident));
91740 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91741 iph->frag_off = 0;
91742 iph->ttl = 64;
91743 iph->protocol = IPPROTO_UDP;
91744 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91745 index ca198c1d1..125372f 100644
91746 --- a/net/core/rtnetlink.c
91747 +++ b/net/core/rtnetlink.c
91748 @@ -58,7 +58,7 @@ struct rtnl_link {
91749 rtnl_doit_func doit;
91750 rtnl_dumpit_func dumpit;
91751 rtnl_calcit_func calcit;
91752 -};
91753 +} __no_const;
91754
91755 static DEFINE_MUTEX(rtnl_mutex);
91756
91757 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91758 if (rtnl_link_ops_get(ops->kind))
91759 return -EEXIST;
91760
91761 - if (!ops->dellink)
91762 - ops->dellink = unregister_netdevice_queue;
91763 + if (!ops->dellink) {
91764 + pax_open_kernel();
91765 + *(void **)&ops->dellink = unregister_netdevice_queue;
91766 + pax_close_kernel();
91767 + }
91768
91769 - list_add_tail(&ops->list, &link_ops);
91770 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91771 return 0;
91772 }
91773 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91774 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91775 for_each_net(net) {
91776 __rtnl_kill_links(net, ops);
91777 }
91778 - list_del(&ops->list);
91779 + pax_list_del((struct list_head *)&ops->list);
91780 }
91781 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91782
91783 diff --git a/net/core/scm.c b/net/core/scm.c
91784 index b4da80b..98d6bdb 100644
91785 --- a/net/core/scm.c
91786 +++ b/net/core/scm.c
91787 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91788 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91789 {
91790 struct cmsghdr __user *cm
91791 - = (__force struct cmsghdr __user *)msg->msg_control;
91792 + = (struct cmsghdr __force_user *)msg->msg_control;
91793 struct cmsghdr cmhdr;
91794 int cmlen = CMSG_LEN(len);
91795 int err;
91796 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91797 err = -EFAULT;
91798 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91799 goto out;
91800 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91801 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91802 goto out;
91803 cmlen = CMSG_SPACE(len);
91804 if (msg->msg_controllen < cmlen)
91805 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91806 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91807 {
91808 struct cmsghdr __user *cm
91809 - = (__force struct cmsghdr __user*)msg->msg_control;
91810 + = (struct cmsghdr __force_user *)msg->msg_control;
91811
91812 int fdmax = 0;
91813 int fdnum = scm->fp->count;
91814 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91815 if (fdnum < fdmax)
91816 fdmax = fdnum;
91817
91818 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91819 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91820 i++, cmfptr++)
91821 {
91822 struct socket *sock;
91823 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91824 index 2c3d0f5..f5a326f 100644
91825 --- a/net/core/skbuff.c
91826 +++ b/net/core/skbuff.c
91827 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91828 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91829 sizeof(struct sk_buff),
91830 0,
91831 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91832 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91833 + SLAB_NO_SANITIZE,
91834 NULL);
91835 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91836 (2*sizeof(struct sk_buff)) +
91837 sizeof(atomic_t),
91838 0,
91839 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91840 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91841 + SLAB_NO_SANITIZE,
91842 NULL);
91843 }
91844
91845 diff --git a/net/core/sock.c b/net/core/sock.c
91846 index 2c097c5..bf72858 100644
91847 --- a/net/core/sock.c
91848 +++ b/net/core/sock.c
91849 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91850 struct sk_buff_head *list = &sk->sk_receive_queue;
91851
91852 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91853 - atomic_inc(&sk->sk_drops);
91854 + atomic_inc_unchecked(&sk->sk_drops);
91855 trace_sock_rcvqueue_full(sk, skb);
91856 return -ENOMEM;
91857 }
91858 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91859 return err;
91860
91861 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91862 - atomic_inc(&sk->sk_drops);
91863 + atomic_inc_unchecked(&sk->sk_drops);
91864 return -ENOBUFS;
91865 }
91866
91867 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91868 skb_dst_force(skb);
91869
91870 spin_lock_irqsave(&list->lock, flags);
91871 - skb->dropcount = atomic_read(&sk->sk_drops);
91872 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91873 __skb_queue_tail(list, skb);
91874 spin_unlock_irqrestore(&list->lock, flags);
91875
91876 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91877 skb->dev = NULL;
91878
91879 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91880 - atomic_inc(&sk->sk_drops);
91881 + atomic_inc_unchecked(&sk->sk_drops);
91882 goto discard_and_relse;
91883 }
91884 if (nested)
91885 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91886 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91887 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91888 bh_unlock_sock(sk);
91889 - atomic_inc(&sk->sk_drops);
91890 + atomic_inc_unchecked(&sk->sk_drops);
91891 goto discard_and_relse;
91892 }
91893
91894 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91895 struct timeval tm;
91896 } v;
91897
91898 - int lv = sizeof(int);
91899 - int len;
91900 + unsigned int lv = sizeof(int);
91901 + unsigned int len;
91902
91903 if (get_user(len, optlen))
91904 return -EFAULT;
91905 - if (len < 0)
91906 + if (len > INT_MAX)
91907 return -EINVAL;
91908
91909 memset(&v, 0, sizeof(v));
91910 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91911
91912 case SO_PEERNAME:
91913 {
91914 - char address[128];
91915 + char address[_K_SS_MAXSIZE];
91916
91917 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91918 return -ENOTCONN;
91919 - if (lv < len)
91920 + if (lv < len || sizeof address < len)
91921 return -EINVAL;
91922 if (copy_to_user(optval, address, len))
91923 return -EFAULT;
91924 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91925
91926 if (len > lv)
91927 len = lv;
91928 - if (copy_to_user(optval, &v, len))
91929 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91930 return -EFAULT;
91931 lenout:
91932 if (put_user(len, optlen))
91933 @@ -2303,7 +2303,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91934 */
91935 smp_wmb();
91936 atomic_set(&sk->sk_refcnt, 1);
91937 - atomic_set(&sk->sk_drops, 0);
91938 + atomic_set_unchecked(&sk->sk_drops, 0);
91939 }
91940 EXPORT_SYMBOL(sock_init_data);
91941
91942 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91943 index a0e9cf6..ef7f9ed 100644
91944 --- a/net/core/sock_diag.c
91945 +++ b/net/core/sock_diag.c
91946 @@ -9,26 +9,33 @@
91947 #include <linux/inet_diag.h>
91948 #include <linux/sock_diag.h>
91949
91950 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91951 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91952 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91953 static DEFINE_MUTEX(sock_diag_table_mutex);
91954
91955 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91956 {
91957 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91958 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91959 cookie[1] != INET_DIAG_NOCOOKIE) &&
91960 ((u32)(unsigned long)sk != cookie[0] ||
91961 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91962 return -ESTALE;
91963 else
91964 +#endif
91965 return 0;
91966 }
91967 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91968
91969 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91970 {
91971 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91972 + cookie[0] = 0;
91973 + cookie[1] = 0;
91974 +#else
91975 cookie[0] = (u32)(unsigned long)sk;
91976 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91977 +#endif
91978 }
91979 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91980
91981 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91982 mutex_lock(&sock_diag_table_mutex);
91983 if (sock_diag_handlers[hndl->family])
91984 err = -EBUSY;
91985 - else
91986 + else {
91987 + pax_open_kernel();
91988 sock_diag_handlers[hndl->family] = hndl;
91989 + pax_close_kernel();
91990 + }
91991 mutex_unlock(&sock_diag_table_mutex);
91992
91993 return err;
91994 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
91995
91996 mutex_lock(&sock_diag_table_mutex);
91997 BUG_ON(sock_diag_handlers[family] != hnld);
91998 + pax_open_kernel();
91999 sock_diag_handlers[family] = NULL;
92000 + pax_close_kernel();
92001 mutex_unlock(&sock_diag_table_mutex);
92002 }
92003 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92004 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92005 index 31107ab..ae03d5a 100644
92006 --- a/net/core/sysctl_net_core.c
92007 +++ b/net/core/sysctl_net_core.c
92008 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92009 {
92010 unsigned int orig_size, size;
92011 int ret, i;
92012 - struct ctl_table tmp = {
92013 + ctl_table_no_const tmp = {
92014 .data = &size,
92015 .maxlen = sizeof(size),
92016 .mode = table->mode
92017 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
92018
92019 static __net_init int sysctl_core_net_init(struct net *net)
92020 {
92021 - struct ctl_table *tbl;
92022 + ctl_table_no_const *tbl = NULL;
92023
92024 net->core.sysctl_somaxconn = SOMAXCONN;
92025
92026 - tbl = netns_core_table;
92027 if (!net_eq(net, &init_net)) {
92028 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
92029 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
92030 if (tbl == NULL)
92031 goto err_dup;
92032
92033 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
92034 if (net->user_ns != &init_user_ns) {
92035 tbl[0].procname = NULL;
92036 }
92037 - }
92038 -
92039 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92040 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92041 + } else
92042 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
92043 if (net->core.sysctl_hdr == NULL)
92044 goto err_reg;
92045
92046 return 0;
92047
92048 err_reg:
92049 - if (tbl != netns_core_table)
92050 - kfree(tbl);
92051 + kfree(tbl);
92052 err_dup:
92053 return -ENOMEM;
92054 }
92055 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
92056 kfree(tbl);
92057 }
92058
92059 -static __net_initdata struct pernet_operations sysctl_core_ops = {
92060 +static __net_initconst struct pernet_operations sysctl_core_ops = {
92061 .init = sysctl_core_net_init,
92062 .exit = sysctl_core_net_exit,
92063 };
92064 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
92065 index dd4d506..fb2fb87 100644
92066 --- a/net/decnet/af_decnet.c
92067 +++ b/net/decnet/af_decnet.c
92068 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
92069 .sysctl_rmem = sysctl_decnet_rmem,
92070 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
92071 .obj_size = sizeof(struct dn_sock),
92072 + .slab_flags = SLAB_USERCOPY,
92073 };
92074
92075 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
92076 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
92077 index 5325b54..a0d4d69 100644
92078 --- a/net/decnet/sysctl_net_decnet.c
92079 +++ b/net/decnet/sysctl_net_decnet.c
92080 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
92081
92082 if (len > *lenp) len = *lenp;
92083
92084 - if (copy_to_user(buffer, addr, len))
92085 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
92086 return -EFAULT;
92087
92088 *lenp = len;
92089 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
92090
92091 if (len > *lenp) len = *lenp;
92092
92093 - if (copy_to_user(buffer, devname, len))
92094 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
92095 return -EFAULT;
92096
92097 *lenp = len;
92098 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
92099 index 3b9d5f2..d7015c6 100644
92100 --- a/net/ieee802154/6lowpan.c
92101 +++ b/net/ieee802154/6lowpan.c
92102 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92103 hc06_ptr += 3;
92104 } else {
92105 /* compress nothing */
92106 - memcpy(hc06_ptr, &hdr, 4);
92107 + memcpy(hc06_ptr, hdr, 4);
92108 /* replace the top byte with new ECN | DSCP format */
92109 *hc06_ptr = tmp;
92110 hc06_ptr += 4;
92111 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92112 index dd6b523..dfe558f 100644
92113 --- a/net/ipv4/af_inet.c
92114 +++ b/net/ipv4/af_inet.c
92115 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
92116
92117 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92118
92119 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92120 - if (!sysctl_local_reserved_ports)
92121 - goto out;
92122 -
92123 rc = proto_register(&tcp_prot, 1);
92124 if (rc)
92125 - goto out_free_reserved_ports;
92126 + goto out;
92127
92128 rc = proto_register(&udp_prot, 1);
92129 if (rc)
92130 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
92131 proto_unregister(&udp_prot);
92132 out_unregister_tcp_proto:
92133 proto_unregister(&tcp_prot);
92134 -out_free_reserved_ports:
92135 - kfree(sysctl_local_reserved_ports);
92136 goto out;
92137 }
92138
92139 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92140 index 34ca6d5..b6421e8 100644
92141 --- a/net/ipv4/devinet.c
92142 +++ b/net/ipv4/devinet.c
92143 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92144 idx = 0;
92145 head = &net->dev_index_head[h];
92146 rcu_read_lock();
92147 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92148 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92149 net->dev_base_seq;
92150 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92151 if (idx < s_idx)
92152 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92153 idx = 0;
92154 head = &net->dev_index_head[h];
92155 rcu_read_lock();
92156 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92157 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92158 net->dev_base_seq;
92159 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92160 if (idx < s_idx)
92161 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92162 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92163 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92164
92165 -static struct devinet_sysctl_table {
92166 +static const struct devinet_sysctl_table {
92167 struct ctl_table_header *sysctl_header;
92168 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92169 } devinet_sysctl = {
92170 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92171 int err;
92172 struct ipv4_devconf *all, *dflt;
92173 #ifdef CONFIG_SYSCTL
92174 - struct ctl_table *tbl = ctl_forward_entry;
92175 + ctl_table_no_const *tbl = NULL;
92176 struct ctl_table_header *forw_hdr;
92177 #endif
92178
92179 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92180 goto err_alloc_dflt;
92181
92182 #ifdef CONFIG_SYSCTL
92183 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92184 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92185 if (tbl == NULL)
92186 goto err_alloc_ctl;
92187
92188 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92189 goto err_reg_dflt;
92190
92191 err = -ENOMEM;
92192 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92193 + if (!net_eq(net, &init_net))
92194 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92195 + else
92196 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92197 if (forw_hdr == NULL)
92198 goto err_reg_ctl;
92199 net->ipv4.forw_hdr = forw_hdr;
92200 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92201 err_reg_dflt:
92202 __devinet_sysctl_unregister(all);
92203 err_reg_all:
92204 - if (tbl != ctl_forward_entry)
92205 - kfree(tbl);
92206 + kfree(tbl);
92207 err_alloc_ctl:
92208 #endif
92209 if (dflt != &ipv4_devconf_dflt)
92210 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92211 index b3f627a..b0f3e99 100644
92212 --- a/net/ipv4/fib_frontend.c
92213 +++ b/net/ipv4/fib_frontend.c
92214 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92215 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92216 fib_sync_up(dev);
92217 #endif
92218 - atomic_inc(&net->ipv4.dev_addr_genid);
92219 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92220 rt_cache_flush(dev_net(dev));
92221 break;
92222 case NETDEV_DOWN:
92223 fib_del_ifaddr(ifa, NULL);
92224 - atomic_inc(&net->ipv4.dev_addr_genid);
92225 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92226 if (ifa->ifa_dev->ifa_list == NULL) {
92227 /* Last address was deleted from this interface.
92228 * Disable IP.
92229 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92230 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92231 fib_sync_up(dev);
92232 #endif
92233 - atomic_inc(&net->ipv4.dev_addr_genid);
92234 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92235 rt_cache_flush(net);
92236 break;
92237 case NETDEV_DOWN:
92238 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92239 index d5dbca5..6251d5f 100644
92240 --- a/net/ipv4/fib_semantics.c
92241 +++ b/net/ipv4/fib_semantics.c
92242 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92243 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92244 nh->nh_gw,
92245 nh->nh_parent->fib_scope);
92246 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92247 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92248
92249 return nh->nh_saddr;
92250 }
92251 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92252 index 6acb541..9ea617d 100644
92253 --- a/net/ipv4/inet_connection_sock.c
92254 +++ b/net/ipv4/inet_connection_sock.c
92255 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92256 .range = { 32768, 61000 },
92257 };
92258
92259 -unsigned long *sysctl_local_reserved_ports;
92260 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92261 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92262
92263 void inet_get_local_port_range(int *low, int *high)
92264 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92265 index 7bd8983..b956690 100644
92266 --- a/net/ipv4/inet_hashtables.c
92267 +++ b/net/ipv4/inet_hashtables.c
92268 @@ -18,12 +18,15 @@
92269 #include <linux/sched.h>
92270 #include <linux/slab.h>
92271 #include <linux/wait.h>
92272 +#include <linux/security.h>
92273
92274 #include <net/inet_connection_sock.h>
92275 #include <net/inet_hashtables.h>
92276 #include <net/secure_seq.h>
92277 #include <net/ip.h>
92278
92279 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92280 +
92281 /*
92282 * Allocate and initialize a new local port bind bucket.
92283 * The bindhash mutex for snum's hash chain must be held here.
92284 @@ -287,7 +290,7 @@ begintw:
92285 if (unlikely(!INET_TW_MATCH(sk, net, acookie,
92286 saddr, daddr, ports,
92287 dif))) {
92288 - sock_put(sk);
92289 + inet_twsk_put(inet_twsk(sk));
92290 goto begintw;
92291 }
92292 goto out;
92293 @@ -554,6 +557,8 @@ ok:
92294 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92295 spin_unlock(&head->lock);
92296
92297 + gr_update_task_in_ip_table(current, inet_sk(sk));
92298 +
92299 if (tw) {
92300 inet_twsk_deschedule(tw, death_row);
92301 while (twrefcnt) {
92302 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92303 index 33d5537..da337a4 100644
92304 --- a/net/ipv4/inetpeer.c
92305 +++ b/net/ipv4/inetpeer.c
92306 @@ -503,8 +503,8 @@ relookup:
92307 if (p) {
92308 p->daddr = *daddr;
92309 atomic_set(&p->refcnt, 1);
92310 - atomic_set(&p->rid, 0);
92311 - atomic_set(&p->ip_id_count,
92312 + atomic_set_unchecked(&p->rid, 0);
92313 + atomic_set_unchecked(&p->ip_id_count,
92314 (daddr->family == AF_INET) ?
92315 secure_ip_id(daddr->addr.a4) :
92316 secure_ipv6_id(daddr->addr.a6));
92317 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92318 index b66910a..cfe416e 100644
92319 --- a/net/ipv4/ip_fragment.c
92320 +++ b/net/ipv4/ip_fragment.c
92321 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92322 return 0;
92323
92324 start = qp->rid;
92325 - end = atomic_inc_return(&peer->rid);
92326 + end = atomic_inc_return_unchecked(&peer->rid);
92327 qp->rid = end;
92328
92329 rc = qp->q.fragments && (end - start) > max;
92330 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92331
92332 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92333 {
92334 - struct ctl_table *table;
92335 + ctl_table_no_const *table = NULL;
92336 struct ctl_table_header *hdr;
92337
92338 - table = ip4_frags_ns_ctl_table;
92339 if (!net_eq(net, &init_net)) {
92340 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92341 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92342 if (table == NULL)
92343 goto err_alloc;
92344
92345 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92346 /* Don't export sysctls to unprivileged users */
92347 if (net->user_ns != &init_user_ns)
92348 table[0].procname = NULL;
92349 - }
92350 + hdr = register_net_sysctl(net, "net/ipv4", table);
92351 + } else
92352 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92353
92354 - hdr = register_net_sysctl(net, "net/ipv4", table);
92355 if (hdr == NULL)
92356 goto err_reg;
92357
92358 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92359 return 0;
92360
92361 err_reg:
92362 - if (!net_eq(net, &init_net))
92363 - kfree(table);
92364 + kfree(table);
92365 err_alloc:
92366 return -ENOMEM;
92367 }
92368 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92369 index 8d6939e..19d0a95 100644
92370 --- a/net/ipv4/ip_gre.c
92371 +++ b/net/ipv4/ip_gre.c
92372 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92373 module_param(log_ecn_error, bool, 0644);
92374 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92375
92376 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92377 +static struct rtnl_link_ops ipgre_link_ops;
92378 static int ipgre_tunnel_init(struct net_device *dev);
92379
92380 static int ipgre_net_id __read_mostly;
92381 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92382 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92383 };
92384
92385 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92386 +static struct rtnl_link_ops ipgre_link_ops = {
92387 .kind = "gre",
92388 .maxtype = IFLA_GRE_MAX,
92389 .policy = ipgre_policy,
92390 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92391 .fill_info = ipgre_fill_info,
92392 };
92393
92394 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92395 +static struct rtnl_link_ops ipgre_tap_ops = {
92396 .kind = "gretap",
92397 .maxtype = IFLA_GRE_MAX,
92398 .policy = ipgre_policy,
92399 diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
92400 index a04d872..7f4ab5d 100644
92401 --- a/net/ipv4/ip_output.c
92402 +++ b/net/ipv4/ip_output.c
92403 @@ -836,7 +836,7 @@ static int __ip_append_data(struct sock *sk,
92404 csummode = CHECKSUM_PARTIAL;
92405
92406 cork->length += length;
92407 - if (((length > mtu) || (skb && skb_is_gso(skb))) &&
92408 + if (((length > mtu) || (skb && skb_has_frags(skb))) &&
92409 (sk->sk_protocol == IPPROTO_UDP) &&
92410 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len) {
92411 err = ip_ufo_append_data(sk, queue, getfrag, from, length,
92412 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92413 index d9c4f11..02b82dbc 100644
92414 --- a/net/ipv4/ip_sockglue.c
92415 +++ b/net/ipv4/ip_sockglue.c
92416 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92417 len = min_t(unsigned int, len, opt->optlen);
92418 if (put_user(len, optlen))
92419 return -EFAULT;
92420 - if (copy_to_user(optval, opt->__data, len))
92421 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92422 + copy_to_user(optval, opt->__data, len))
92423 return -EFAULT;
92424 return 0;
92425 }
92426 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92427 if (sk->sk_type != SOCK_STREAM)
92428 return -ENOPROTOOPT;
92429
92430 - msg.msg_control = optval;
92431 + msg.msg_control = (void __force_kernel *)optval;
92432 msg.msg_controllen = len;
92433 msg.msg_flags = flags;
92434
92435 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92436 index 17cc0ff..63856c4 100644
92437 --- a/net/ipv4/ip_vti.c
92438 +++ b/net/ipv4/ip_vti.c
92439 @@ -47,7 +47,7 @@
92440 #define HASH_SIZE 16
92441 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92442
92443 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92444 +static struct rtnl_link_ops vti_link_ops;
92445
92446 static int vti_net_id __read_mostly;
92447 struct vti_net {
92448 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92449 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92450 };
92451
92452 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92453 +static struct rtnl_link_ops vti_link_ops = {
92454 .kind = "vti",
92455 .maxtype = IFLA_VTI_MAX,
92456 .policy = vti_policy,
92457 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92458 index efa1138..20dbba0 100644
92459 --- a/net/ipv4/ipconfig.c
92460 +++ b/net/ipv4/ipconfig.c
92461 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92462
92463 mm_segment_t oldfs = get_fs();
92464 set_fs(get_ds());
92465 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92466 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92467 set_fs(oldfs);
92468 return res;
92469 }
92470 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92471
92472 mm_segment_t oldfs = get_fs();
92473 set_fs(get_ds());
92474 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92475 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92476 set_fs(oldfs);
92477 return res;
92478 }
92479 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92480
92481 mm_segment_t oldfs = get_fs();
92482 set_fs(get_ds());
92483 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92484 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92485 set_fs(oldfs);
92486 return res;
92487 }
92488 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92489 index b3ac3c3..ec6bd95 100644
92490 --- a/net/ipv4/ipip.c
92491 +++ b/net/ipv4/ipip.c
92492 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92493 static int ipip_net_id __read_mostly;
92494
92495 static int ipip_tunnel_init(struct net_device *dev);
92496 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92497 +static struct rtnl_link_ops ipip_link_ops;
92498
92499 static int ipip_err(struct sk_buff *skb, u32 info)
92500 {
92501 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92502 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92503 };
92504
92505 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92506 +static struct rtnl_link_ops ipip_link_ops = {
92507 .kind = "ipip",
92508 .maxtype = IFLA_IPTUN_MAX,
92509 .policy = ipip_policy,
92510 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92511 index 85a4f21..1beb1f5 100644
92512 --- a/net/ipv4/netfilter/arp_tables.c
92513 +++ b/net/ipv4/netfilter/arp_tables.c
92514 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92515 #endif
92516
92517 static int get_info(struct net *net, void __user *user,
92518 - const int *len, int compat)
92519 + int len, int compat)
92520 {
92521 char name[XT_TABLE_MAXNAMELEN];
92522 struct xt_table *t;
92523 int ret;
92524
92525 - if (*len != sizeof(struct arpt_getinfo)) {
92526 - duprintf("length %u != %Zu\n", *len,
92527 + if (len != sizeof(struct arpt_getinfo)) {
92528 + duprintf("length %u != %Zu\n", len,
92529 sizeof(struct arpt_getinfo));
92530 return -EINVAL;
92531 }
92532 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92533 info.size = private->size;
92534 strcpy(info.name, name);
92535
92536 - if (copy_to_user(user, &info, *len) != 0)
92537 + if (copy_to_user(user, &info, len) != 0)
92538 ret = -EFAULT;
92539 else
92540 ret = 0;
92541 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92542
92543 switch (cmd) {
92544 case ARPT_SO_GET_INFO:
92545 - ret = get_info(sock_net(sk), user, len, 1);
92546 + ret = get_info(sock_net(sk), user, *len, 1);
92547 break;
92548 case ARPT_SO_GET_ENTRIES:
92549 ret = compat_get_entries(sock_net(sk), user, len);
92550 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92551
92552 switch (cmd) {
92553 case ARPT_SO_GET_INFO:
92554 - ret = get_info(sock_net(sk), user, len, 0);
92555 + ret = get_info(sock_net(sk), user, *len, 0);
92556 break;
92557
92558 case ARPT_SO_GET_ENTRIES:
92559 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92560 index d23118d..6ad7277 100644
92561 --- a/net/ipv4/netfilter/ip_tables.c
92562 +++ b/net/ipv4/netfilter/ip_tables.c
92563 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92564 #endif
92565
92566 static int get_info(struct net *net, void __user *user,
92567 - const int *len, int compat)
92568 + int len, int compat)
92569 {
92570 char name[XT_TABLE_MAXNAMELEN];
92571 struct xt_table *t;
92572 int ret;
92573
92574 - if (*len != sizeof(struct ipt_getinfo)) {
92575 - duprintf("length %u != %zu\n", *len,
92576 + if (len != sizeof(struct ipt_getinfo)) {
92577 + duprintf("length %u != %zu\n", len,
92578 sizeof(struct ipt_getinfo));
92579 return -EINVAL;
92580 }
92581 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92582 info.size = private->size;
92583 strcpy(info.name, name);
92584
92585 - if (copy_to_user(user, &info, *len) != 0)
92586 + if (copy_to_user(user, &info, len) != 0)
92587 ret = -EFAULT;
92588 else
92589 ret = 0;
92590 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92591
92592 switch (cmd) {
92593 case IPT_SO_GET_INFO:
92594 - ret = get_info(sock_net(sk), user, len, 1);
92595 + ret = get_info(sock_net(sk), user, *len, 1);
92596 break;
92597 case IPT_SO_GET_ENTRIES:
92598 ret = compat_get_entries(sock_net(sk), user, len);
92599 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92600
92601 switch (cmd) {
92602 case IPT_SO_GET_INFO:
92603 - ret = get_info(sock_net(sk), user, len, 0);
92604 + ret = get_info(sock_net(sk), user, *len, 0);
92605 break;
92606
92607 case IPT_SO_GET_ENTRIES:
92608 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92609 index cbc2215..9cb993c 100644
92610 --- a/net/ipv4/netfilter/ipt_ULOG.c
92611 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92612 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92613 ub->qlen++;
92614
92615 pm = nlmsg_data(nlh);
92616 + memset(pm, 0, sizeof(*pm));
92617
92618 /* We might not have a timestamp, get one */
92619 if (skb->tstamp.tv64 == 0)
92620 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92621 }
92622 else if (loginfo->prefix[0] != '\0')
92623 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
92624 - else
92625 - *(pm->prefix) = '\0';
92626
92627 if (in && in->hard_header_len > 0 &&
92628 skb->mac_header != skb->network_header &&
92629 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
92630
92631 if (in)
92632 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
92633 - else
92634 - pm->indev_name[0] = '\0';
92635
92636 if (out)
92637 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
92638 - else
92639 - pm->outdev_name[0] = '\0';
92640
92641 /* copy_len <= skb->len, so can't fail. */
92642 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
92643 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92644 index 746427c..80eab72 100644
92645 --- a/net/ipv4/ping.c
92646 +++ b/net/ipv4/ping.c
92647 @@ -55,7 +55,7 @@
92648
92649
92650 struct ping_table ping_table;
92651 -struct pingv6_ops pingv6_ops;
92652 +struct pingv6_ops *pingv6_ops;
92653 EXPORT_SYMBOL_GPL(pingv6_ops);
92654
92655 static u16 ping_port_rover;
92656 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92657 return -ENODEV;
92658 }
92659 }
92660 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92661 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92662 scoped);
92663 rcu_read_unlock();
92664
92665 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92666 }
92667 #if IS_ENABLED(CONFIG_IPV6)
92668 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92669 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92670 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92671 #endif
92672 }
92673
92674 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92675 info, (u8 *)icmph);
92676 #if IS_ENABLED(CONFIG_IPV6)
92677 } else if (family == AF_INET6) {
92678 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92679 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92680 info, (u8 *)icmph);
92681 #endif
92682 }
92683 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92684 return ip_recv_error(sk, msg, len);
92685 #if IS_ENABLED(CONFIG_IPV6)
92686 } else if (family == AF_INET6) {
92687 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92688 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92689 #endif
92690 }
92691 }
92692 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92693 IP6CB(skb)->iif);
92694
92695 if (inet6_sk(sk)->rxopt.all)
92696 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92697 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92698 #endif
92699 } else {
92700 BUG();
92701 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92702 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92703 0, sock_i_ino(sp),
92704 atomic_read(&sp->sk_refcnt), sp,
92705 - atomic_read(&sp->sk_drops), len);
92706 + atomic_read_unchecked(&sp->sk_drops), len);
92707 }
92708
92709 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92710 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92711 index 6fb2337..9cd6b20 100644
92712 --- a/net/ipv4/raw.c
92713 +++ b/net/ipv4/raw.c
92714 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92715 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92716 {
92717 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92718 - atomic_inc(&sk->sk_drops);
92719 + atomic_inc_unchecked(&sk->sk_drops);
92720 kfree_skb(skb);
92721 return NET_RX_DROP;
92722 }
92723 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92724
92725 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92726 {
92727 + struct icmp_filter filter;
92728 +
92729 if (optlen > sizeof(struct icmp_filter))
92730 optlen = sizeof(struct icmp_filter);
92731 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92732 + if (copy_from_user(&filter, optval, optlen))
92733 return -EFAULT;
92734 + raw_sk(sk)->filter = filter;
92735 return 0;
92736 }
92737
92738 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92739 {
92740 int len, ret = -EFAULT;
92741 + struct icmp_filter filter;
92742
92743 if (get_user(len, optlen))
92744 goto out;
92745 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92746 if (len > sizeof(struct icmp_filter))
92747 len = sizeof(struct icmp_filter);
92748 ret = -EFAULT;
92749 - if (put_user(len, optlen) ||
92750 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92751 + filter = raw_sk(sk)->filter;
92752 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92753 goto out;
92754 ret = 0;
92755 out: return ret;
92756 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92757 0, 0L, 0,
92758 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92759 0, sock_i_ino(sp),
92760 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92761 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92762 }
92763
92764 static int raw_seq_show(struct seq_file *seq, void *v)
92765 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92766 index a9a54a2..647316e 100644
92767 --- a/net/ipv4/route.c
92768 +++ b/net/ipv4/route.c
92769 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92770 .maxlen = sizeof(int),
92771 .mode = 0200,
92772 .proc_handler = ipv4_sysctl_rtcache_flush,
92773 + .extra1 = &init_net,
92774 },
92775 { },
92776 };
92777
92778 static __net_init int sysctl_route_net_init(struct net *net)
92779 {
92780 - struct ctl_table *tbl;
92781 + ctl_table_no_const *tbl = NULL;
92782
92783 - tbl = ipv4_route_flush_table;
92784 if (!net_eq(net, &init_net)) {
92785 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92786 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92787 if (tbl == NULL)
92788 goto err_dup;
92789
92790 /* Don't export sysctls to unprivileged users */
92791 if (net->user_ns != &init_user_ns)
92792 tbl[0].procname = NULL;
92793 - }
92794 - tbl[0].extra1 = net;
92795 + tbl[0].extra1 = net;
92796 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92797 + } else
92798 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92799
92800 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92801 if (net->ipv4.route_hdr == NULL)
92802 goto err_reg;
92803 return 0;
92804
92805 err_reg:
92806 - if (tbl != ipv4_route_flush_table)
92807 - kfree(tbl);
92808 + kfree(tbl);
92809 err_dup:
92810 return -ENOMEM;
92811 }
92812 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92813
92814 static __net_init int rt_genid_init(struct net *net)
92815 {
92816 - atomic_set(&net->rt_genid, 0);
92817 - atomic_set(&net->fnhe_genid, 0);
92818 + atomic_set_unchecked(&net->rt_genid, 0);
92819 + atomic_set_unchecked(&net->fnhe_genid, 0);
92820 get_random_bytes(&net->ipv4.dev_addr_genid,
92821 sizeof(net->ipv4.dev_addr_genid));
92822 return 0;
92823 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92824 index 610e324..fd42e75 100644
92825 --- a/net/ipv4/sysctl_net_ipv4.c
92826 +++ b/net/ipv4/sysctl_net_ipv4.c
92827 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92828 {
92829 int ret;
92830 int range[2];
92831 - struct ctl_table tmp = {
92832 + ctl_table_no_const tmp = {
92833 .data = &range,
92834 .maxlen = sizeof(range),
92835 .mode = table->mode,
92836 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92837 int ret;
92838 gid_t urange[2];
92839 kgid_t low, high;
92840 - struct ctl_table tmp = {
92841 + ctl_table_no_const tmp = {
92842 .data = &urange,
92843 .maxlen = sizeof(urange),
92844 .mode = table->mode,
92845 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92846 void __user *buffer, size_t *lenp, loff_t *ppos)
92847 {
92848 char val[TCP_CA_NAME_MAX];
92849 - struct ctl_table tbl = {
92850 + ctl_table_no_const tbl = {
92851 .data = val,
92852 .maxlen = TCP_CA_NAME_MAX,
92853 };
92854 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92855 void __user *buffer, size_t *lenp,
92856 loff_t *ppos)
92857 {
92858 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92859 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92860 int ret;
92861
92862 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92863 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92864 void __user *buffer, size_t *lenp,
92865 loff_t *ppos)
92866 {
92867 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92868 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92869 int ret;
92870
92871 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92872 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92873 struct mem_cgroup *memcg;
92874 #endif
92875
92876 - struct ctl_table tmp = {
92877 + ctl_table_no_const tmp = {
92878 .data = &vec,
92879 .maxlen = sizeof(vec),
92880 .mode = ctl->mode,
92881 };
92882
92883 if (!write) {
92884 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92885 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92886 + ctl_table_no_const tcp_mem = *ctl;
92887 +
92888 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92889 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92890 }
92891
92892 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92893 @@ -239,7 +241,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92894 void __user *buffer, size_t *lenp,
92895 loff_t *ppos)
92896 {
92897 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92898 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92899 struct tcp_fastopen_context *ctxt;
92900 int ret;
92901 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92902 @@ -482,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
92903 },
92904 {
92905 .procname = "ip_local_reserved_ports",
92906 - .data = NULL, /* initialized in sysctl_ipv4_init */
92907 + .data = sysctl_local_reserved_ports,
92908 .maxlen = 65536,
92909 .mode = 0644,
92910 .proc_handler = proc_do_large_bitmap,
92911 @@ -847,11 +849,10 @@ static struct ctl_table ipv4_net_table[] = {
92912
92913 static __net_init int ipv4_sysctl_init_net(struct net *net)
92914 {
92915 - struct ctl_table *table;
92916 + ctl_table_no_const *table = NULL;
92917
92918 - table = ipv4_net_table;
92919 if (!net_eq(net, &init_net)) {
92920 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92921 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92922 if (table == NULL)
92923 goto err_alloc;
92924
92925 @@ -886,15 +887,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92926
92927 tcp_init_mem(net);
92928
92929 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92930 + if (!net_eq(net, &init_net))
92931 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92932 + else
92933 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92934 if (net->ipv4.ipv4_hdr == NULL)
92935 goto err_reg;
92936
92937 return 0;
92938
92939 err_reg:
92940 - if (!net_eq(net, &init_net))
92941 - kfree(table);
92942 + kfree(table);
92943 err_alloc:
92944 return -ENOMEM;
92945 }
92946 @@ -916,16 +919,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92947 static __init int sysctl_ipv4_init(void)
92948 {
92949 struct ctl_table_header *hdr;
92950 - struct ctl_table *i;
92951 -
92952 - for (i = ipv4_table; i->procname; i++) {
92953 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
92954 - i->data = sysctl_local_reserved_ports;
92955 - break;
92956 - }
92957 - }
92958 - if (!i->procname)
92959 - return -EINVAL;
92960
92961 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
92962 if (hdr == NULL)
92963 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
92964 index 3ca2139..c4cc060 100644
92965 --- a/net/ipv4/tcp_input.c
92966 +++ b/net/ipv4/tcp_input.c
92967 @@ -4379,7 +4379,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
92968 * simplifies code)
92969 */
92970 static void
92971 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92972 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92973 struct sk_buff *head, struct sk_buff *tail,
92974 u32 start, u32 end)
92975 {
92976 @@ -5465,6 +5465,7 @@ discard:
92977 tcp_paws_reject(&tp->rx_opt, 0))
92978 goto discard_and_undo;
92979
92980 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
92981 if (th->syn) {
92982 /* We see SYN without ACK. It is attempt of
92983 * simultaneous connect with crossed SYNs.
92984 @@ -5515,6 +5516,7 @@ discard:
92985 goto discard;
92986 #endif
92987 }
92988 +#endif
92989 /* "fifth, if neither of the SYN or RST bits is set then
92990 * drop the segment and return."
92991 */
92992 @@ -5560,7 +5562,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
92993 goto discard;
92994
92995 if (th->syn) {
92996 - if (th->fin)
92997 + if (th->fin || th->urg || th->psh)
92998 goto discard;
92999 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
93000 return 1;
93001 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
93002 index b299da5..097db06 100644
93003 --- a/net/ipv4/tcp_ipv4.c
93004 +++ b/net/ipv4/tcp_ipv4.c
93005 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
93006 EXPORT_SYMBOL(sysctl_tcp_low_latency);
93007
93008
93009 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93010 +extern int grsec_enable_blackhole;
93011 +#endif
93012 +
93013 #ifdef CONFIG_TCP_MD5SIG
93014 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
93015 __be32 daddr, __be32 saddr, const struct tcphdr *th);
93016 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
93017 return 0;
93018
93019 reset:
93020 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93021 + if (!grsec_enable_blackhole)
93022 +#endif
93023 tcp_v4_send_reset(rsk, skb);
93024 discard:
93025 kfree_skb(skb);
93026 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
93027 TCP_SKB_CB(skb)->sacked = 0;
93028
93029 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93030 - if (!sk)
93031 + if (!sk) {
93032 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93033 + ret = 1;
93034 +#endif
93035 goto no_tcp_socket;
93036 -
93037 + }
93038 process:
93039 - if (sk->sk_state == TCP_TIME_WAIT)
93040 + if (sk->sk_state == TCP_TIME_WAIT) {
93041 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93042 + ret = 2;
93043 +#endif
93044 goto do_time_wait;
93045 + }
93046
93047 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
93048 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93049 @@ -2034,6 +2048,10 @@ csum_error:
93050 bad_packet:
93051 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93052 } else {
93053 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93054 + if (!grsec_enable_blackhole || (ret == 1 &&
93055 + (skb->dev->flags & IFF_LOOPBACK)))
93056 +#endif
93057 tcp_v4_send_reset(NULL, skb);
93058 }
93059
93060 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
93061 index ab1c086..2a8d76b 100644
93062 --- a/net/ipv4/tcp_minisocks.c
93063 +++ b/net/ipv4/tcp_minisocks.c
93064 @@ -27,6 +27,10 @@
93065 #include <net/inet_common.h>
93066 #include <net/xfrm.h>
93067
93068 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93069 +extern int grsec_enable_blackhole;
93070 +#endif
93071 +
93072 int sysctl_tcp_syncookies __read_mostly = 1;
93073 EXPORT_SYMBOL(sysctl_tcp_syncookies);
93074
93075 @@ -715,7 +719,10 @@ embryonic_reset:
93076 * avoid becoming vulnerable to outside attack aiming at
93077 * resetting legit local connections.
93078 */
93079 - req->rsk_ops->send_reset(sk, skb);
93080 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93081 + if (!grsec_enable_blackhole)
93082 +#endif
93083 + req->rsk_ops->send_reset(sk, skb);
93084 } else if (fastopen) { /* received a valid RST pkt */
93085 reqsk_fastopen_remove(sk, req, true);
93086 tcp_reset(sk);
93087 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
93088 index 170737a..75cbd26 100644
93089 --- a/net/ipv4/tcp_output.c
93090 +++ b/net/ipv4/tcp_output.c
93091 @@ -982,6 +982,9 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb)
93092 static void tcp_set_skb_tso_segs(const struct sock *sk, struct sk_buff *skb,
93093 unsigned int mss_now)
93094 {
93095 + /* Make sure we own this skb before messing gso_size/gso_segs */
93096 + WARN_ON_ONCE(skb_cloned(skb));
93097 +
93098 if (skb->len <= mss_now || !sk_can_gso(sk) ||
93099 skb->ip_summed == CHECKSUM_NONE) {
93100 /* Avoid the costly divide in the normal
93101 @@ -1063,9 +1066,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
93102 if (nsize < 0)
93103 nsize = 0;
93104
93105 - if (skb_cloned(skb) &&
93106 - skb_is_nonlinear(skb) &&
93107 - pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
93108 + if (skb_unclone(skb, GFP_ATOMIC))
93109 return -ENOMEM;
93110
93111 /* Get a new skb... force flag on. */
93112 @@ -2334,6 +2335,8 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
93113 int oldpcount = tcp_skb_pcount(skb);
93114
93115 if (unlikely(oldpcount > 1)) {
93116 + if (skb_unclone(skb, GFP_ATOMIC))
93117 + return -ENOMEM;
93118 tcp_init_tso_segs(sk, skb, cur_mss);
93119 tcp_adjust_pcount(sk, skb, oldpcount - tcp_skb_pcount(skb));
93120 }
93121 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
93122 index d4943f6..e7a74a5 100644
93123 --- a/net/ipv4/tcp_probe.c
93124 +++ b/net/ipv4/tcp_probe.c
93125 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
93126 if (cnt + width >= len)
93127 break;
93128
93129 - if (copy_to_user(buf + cnt, tbuf, width))
93130 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
93131 return -EFAULT;
93132 cnt += width;
93133 }
93134 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
93135 index 4b85e6f..22f9ac9 100644
93136 --- a/net/ipv4/tcp_timer.c
93137 +++ b/net/ipv4/tcp_timer.c
93138 @@ -22,6 +22,10 @@
93139 #include <linux/gfp.h>
93140 #include <net/tcp.h>
93141
93142 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93143 +extern int grsec_lastack_retries;
93144 +#endif
93145 +
93146 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
93147 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
93148 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
93149 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
93150 }
93151 }
93152
93153 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93154 + if ((sk->sk_state == TCP_LAST_ACK) &&
93155 + (grsec_lastack_retries > 0) &&
93156 + (grsec_lastack_retries < retry_until))
93157 + retry_until = grsec_lastack_retries;
93158 +#endif
93159 +
93160 if (retransmits_timed_out(sk, retry_until,
93161 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
93162 /* Has it gone just too far? */
93163 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
93164 index 766e6ba..aff2f8d 100644
93165 --- a/net/ipv4/udp.c
93166 +++ b/net/ipv4/udp.c
93167 @@ -87,6 +87,7 @@
93168 #include <linux/types.h>
93169 #include <linux/fcntl.h>
93170 #include <linux/module.h>
93171 +#include <linux/security.h>
93172 #include <linux/socket.h>
93173 #include <linux/sockios.h>
93174 #include <linux/igmp.h>
93175 @@ -112,6 +113,10 @@
93176 #include <net/busy_poll.h>
93177 #include "udp_impl.h"
93178
93179 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93180 +extern int grsec_enable_blackhole;
93181 +#endif
93182 +
93183 struct udp_table udp_table __read_mostly;
93184 EXPORT_SYMBOL(udp_table);
93185
93186 @@ -595,6 +600,9 @@ found:
93187 return s;
93188 }
93189
93190 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93191 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93192 +
93193 /*
93194 * This routine is called by the ICMP module when it gets some
93195 * sort of error condition. If err < 0 then the socket should
93196 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93197 dport = usin->sin_port;
93198 if (dport == 0)
93199 return -EINVAL;
93200 +
93201 + err = gr_search_udp_sendmsg(sk, usin);
93202 + if (err)
93203 + return err;
93204 } else {
93205 if (sk->sk_state != TCP_ESTABLISHED)
93206 return -EDESTADDRREQ;
93207 +
93208 + err = gr_search_udp_sendmsg(sk, NULL);
93209 + if (err)
93210 + return err;
93211 +
93212 daddr = inet->inet_daddr;
93213 dport = inet->inet_dport;
93214 /* Open fast path for connected socket.
93215 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93216 IS_UDPLITE(sk));
93217 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93218 IS_UDPLITE(sk));
93219 - atomic_inc(&sk->sk_drops);
93220 + atomic_inc_unchecked(&sk->sk_drops);
93221 __skb_unlink(skb, rcvq);
93222 __skb_queue_tail(&list_kill, skb);
93223 }
93224 @@ -1223,6 +1240,10 @@ try_again:
93225 if (!skb)
93226 goto out;
93227
93228 + err = gr_search_udp_recvmsg(sk, skb);
93229 + if (err)
93230 + goto out_free;
93231 +
93232 ulen = skb->len - sizeof(struct udphdr);
93233 copied = len;
93234 if (copied > ulen)
93235 @@ -1256,7 +1277,7 @@ try_again:
93236 if (unlikely(err)) {
93237 trace_kfree_skb(skb, udp_recvmsg);
93238 if (!peeked) {
93239 - atomic_inc(&sk->sk_drops);
93240 + atomic_inc_unchecked(&sk->sk_drops);
93241 UDP_INC_STATS_USER(sock_net(sk),
93242 UDP_MIB_INERRORS, is_udplite);
93243 }
93244 @@ -1543,7 +1564,7 @@ csum_error:
93245 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93246 drop:
93247 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93248 - atomic_inc(&sk->sk_drops);
93249 + atomic_inc_unchecked(&sk->sk_drops);
93250 kfree_skb(skb);
93251 return -1;
93252 }
93253 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93254 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93255
93256 if (!skb1) {
93257 - atomic_inc(&sk->sk_drops);
93258 + atomic_inc_unchecked(&sk->sk_drops);
93259 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93260 IS_UDPLITE(sk));
93261 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93262 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93263 goto csum_error;
93264
93265 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93266 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93267 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93268 +#endif
93269 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93270
93271 /*
93272 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93273 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93274 0, sock_i_ino(sp),
93275 atomic_read(&sp->sk_refcnt), sp,
93276 - atomic_read(&sp->sk_drops), len);
93277 + atomic_read_unchecked(&sp->sk_drops), len);
93278 }
93279
93280 int udp4_seq_show(struct seq_file *seq, void *v)
93281 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93282 index 9a459be..c7bc04c 100644
93283 --- a/net/ipv4/xfrm4_policy.c
93284 +++ b/net/ipv4/xfrm4_policy.c
93285 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93286 fl4->flowi4_tos = iph->tos;
93287 }
93288
93289 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93290 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93291 {
93292 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93293
93294 - xfrm4_policy_afinfo.garbage_collect(net);
93295 + xfrm_garbage_collect_deferred(net);
93296 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93297 }
93298
93299 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93300
93301 static int __net_init xfrm4_net_init(struct net *net)
93302 {
93303 - struct ctl_table *table;
93304 + ctl_table_no_const *table = NULL;
93305 struct ctl_table_header *hdr;
93306
93307 - table = xfrm4_policy_table;
93308 if (!net_eq(net, &init_net)) {
93309 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93310 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93311 if (!table)
93312 goto err_alloc;
93313
93314 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93315 - }
93316 -
93317 - hdr = register_net_sysctl(net, "net/ipv4", table);
93318 + hdr = register_net_sysctl(net, "net/ipv4", table);
93319 + } else
93320 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93321 if (!hdr)
93322 goto err_reg;
93323
93324 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93325 return 0;
93326
93327 err_reg:
93328 - if (!net_eq(net, &init_net))
93329 - kfree(table);
93330 + kfree(table);
93331 err_alloc:
93332 return -ENOMEM;
93333 }
93334 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93335 index 0f99f7b..9375cf5 100644
93336 --- a/net/ipv6/addrconf.c
93337 +++ b/net/ipv6/addrconf.c
93338 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93339 idx = 0;
93340 head = &net->dev_index_head[h];
93341 rcu_read_lock();
93342 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93343 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93344 net->dev_base_seq;
93345 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93346 if (idx < s_idx)
93347 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93348 p.iph.ihl = 5;
93349 p.iph.protocol = IPPROTO_IPV6;
93350 p.iph.ttl = 64;
93351 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93352 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93353
93354 if (ops->ndo_do_ioctl) {
93355 mm_segment_t oldfs = get_fs();
93356 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93357 s_ip_idx = ip_idx = cb->args[2];
93358
93359 rcu_read_lock();
93360 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93361 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93362 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93363 idx = 0;
93364 head = &net->dev_index_head[h];
93365 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93366 dst_free(&ifp->rt->dst);
93367 break;
93368 }
93369 - atomic_inc(&net->ipv6.dev_addr_genid);
93370 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93371 }
93372
93373 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93374 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93375 int *valp = ctl->data;
93376 int val = *valp;
93377 loff_t pos = *ppos;
93378 - struct ctl_table lctl;
93379 + ctl_table_no_const lctl;
93380 int ret;
93381
93382 /*
93383 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93384 int *valp = ctl->data;
93385 int val = *valp;
93386 loff_t pos = *ppos;
93387 - struct ctl_table lctl;
93388 + ctl_table_no_const lctl;
93389 int ret;
93390
93391 /*
93392 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93393 index 197e6f4..16d8396 100644
93394 --- a/net/ipv6/datagram.c
93395 +++ b/net/ipv6/datagram.c
93396 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93397 0,
93398 sock_i_ino(sp),
93399 atomic_read(&sp->sk_refcnt), sp,
93400 - atomic_read(&sp->sk_drops));
93401 + atomic_read_unchecked(&sp->sk_drops));
93402 }
93403 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93404 index 7cfc8d2..c5394b6 100644
93405 --- a/net/ipv6/icmp.c
93406 +++ b/net/ipv6/icmp.c
93407 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93408
93409 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93410 {
93411 - struct ctl_table *table;
93412 + ctl_table_no_const *table;
93413
93414 table = kmemdup(ipv6_icmp_table_template,
93415 sizeof(ipv6_icmp_table_template),
93416 diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
93417 index 32b4a16..066640e 100644
93418 --- a/net/ipv6/inet6_hashtables.c
93419 +++ b/net/ipv6/inet6_hashtables.c
93420 @@ -116,7 +116,7 @@ begintw:
93421 }
93422 if (unlikely(!INET6_TW_MATCH(sk, net, saddr, daddr,
93423 ports, dif))) {
93424 - sock_put(sk);
93425 + inet_twsk_put(inet_twsk(sk));
93426 goto begintw;
93427 }
93428 goto out;
93429 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93430 index 8bc717b..76fbb5d 100644
93431 --- a/net/ipv6/ip6_gre.c
93432 +++ b/net/ipv6/ip6_gre.c
93433 @@ -74,7 +74,7 @@ struct ip6gre_net {
93434 struct net_device *fb_tunnel_dev;
93435 };
93436
93437 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93438 +static struct rtnl_link_ops ip6gre_link_ops;
93439 static int ip6gre_tunnel_init(struct net_device *dev);
93440 static void ip6gre_tunnel_setup(struct net_device *dev);
93441 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93442 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93443 }
93444
93445
93446 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93447 +static struct inet6_protocol ip6gre_protocol = {
93448 .handler = ip6gre_rcv,
93449 .err_handler = ip6gre_err,
93450 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93451 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93452 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93453 };
93454
93455 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93456 +static struct rtnl_link_ops ip6gre_link_ops = {
93457 .kind = "ip6gre",
93458 .maxtype = IFLA_GRE_MAX,
93459 .policy = ip6gre_policy,
93460 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93461 .fill_info = ip6gre_fill_info,
93462 };
93463
93464 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93465 +static struct rtnl_link_ops ip6gre_tap_ops = {
93466 .kind = "ip6gretap",
93467 .maxtype = IFLA_GRE_MAX,
93468 .policy = ip6gre_policy,
93469 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
93470 index 44df1c9..2e542d0 100644
93471 --- a/net/ipv6/ip6_output.c
93472 +++ b/net/ipv6/ip6_output.c
93473 @@ -1252,7 +1252,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
93474 skb = skb_peek_tail(&sk->sk_write_queue);
93475 cork->length += length;
93476 if (((length > mtu) ||
93477 - (skb && skb_is_gso(skb))) &&
93478 + (skb && skb_has_frags(skb))) &&
93479 (sk->sk_protocol == IPPROTO_UDP) &&
93480 (rt->dst.dev->features & NETIF_F_UFO)) {
93481 err = ip6_ufo_append_data(sk, getfrag, from, length,
93482 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93483 index cf5d490..30946f0 100644
93484 --- a/net/ipv6/ip6_tunnel.c
93485 +++ b/net/ipv6/ip6_tunnel.c
93486 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93487
93488 static int ip6_tnl_dev_init(struct net_device *dev);
93489 static void ip6_tnl_dev_setup(struct net_device *dev);
93490 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93491 +static struct rtnl_link_ops ip6_link_ops;
93492
93493 static int ip6_tnl_net_id __read_mostly;
93494 struct ip6_tnl_net {
93495 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93496 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93497 };
93498
93499 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93500 +static struct rtnl_link_ops ip6_link_ops = {
93501 .kind = "ip6tnl",
93502 .maxtype = IFLA_IPTUN_MAX,
93503 .policy = ip6_tnl_policy,
93504 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93505 index d1e2e8e..51c19ae 100644
93506 --- a/net/ipv6/ipv6_sockglue.c
93507 +++ b/net/ipv6/ipv6_sockglue.c
93508 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93509 if (sk->sk_type != SOCK_STREAM)
93510 return -ENOPROTOOPT;
93511
93512 - msg.msg_control = optval;
93513 + msg.msg_control = (void __force_kernel *)optval;
93514 msg.msg_controllen = len;
93515 msg.msg_flags = flags;
93516
93517 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93518 index 44400c2..8e11f52 100644
93519 --- a/net/ipv6/netfilter/ip6_tables.c
93520 +++ b/net/ipv6/netfilter/ip6_tables.c
93521 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93522 #endif
93523
93524 static int get_info(struct net *net, void __user *user,
93525 - const int *len, int compat)
93526 + int len, int compat)
93527 {
93528 char name[XT_TABLE_MAXNAMELEN];
93529 struct xt_table *t;
93530 int ret;
93531
93532 - if (*len != sizeof(struct ip6t_getinfo)) {
93533 - duprintf("length %u != %zu\n", *len,
93534 + if (len != sizeof(struct ip6t_getinfo)) {
93535 + duprintf("length %u != %zu\n", len,
93536 sizeof(struct ip6t_getinfo));
93537 return -EINVAL;
93538 }
93539 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93540 info.size = private->size;
93541 strcpy(info.name, name);
93542
93543 - if (copy_to_user(user, &info, *len) != 0)
93544 + if (copy_to_user(user, &info, len) != 0)
93545 ret = -EFAULT;
93546 else
93547 ret = 0;
93548 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93549
93550 switch (cmd) {
93551 case IP6T_SO_GET_INFO:
93552 - ret = get_info(sock_net(sk), user, len, 1);
93553 + ret = get_info(sock_net(sk), user, *len, 1);
93554 break;
93555 case IP6T_SO_GET_ENTRIES:
93556 ret = compat_get_entries(sock_net(sk), user, len);
93557 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93558
93559 switch (cmd) {
93560 case IP6T_SO_GET_INFO:
93561 - ret = get_info(sock_net(sk), user, len, 0);
93562 + ret = get_info(sock_net(sk), user, *len, 0);
93563 break;
93564
93565 case IP6T_SO_GET_ENTRIES:
93566 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93567 index dffdc1a..ccc6678 100644
93568 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93569 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93570 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93571
93572 static int nf_ct_frag6_sysctl_register(struct net *net)
93573 {
93574 - struct ctl_table *table;
93575 + ctl_table_no_const *table = NULL;
93576 struct ctl_table_header *hdr;
93577
93578 - table = nf_ct_frag6_sysctl_table;
93579 if (!net_eq(net, &init_net)) {
93580 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93581 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93582 GFP_KERNEL);
93583 if (table == NULL)
93584 goto err_alloc;
93585 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93586 table[0].data = &net->nf_frag.frags.timeout;
93587 table[1].data = &net->nf_frag.frags.low_thresh;
93588 table[2].data = &net->nf_frag.frags.high_thresh;
93589 - }
93590 -
93591 - hdr = register_net_sysctl(net, "net/netfilter", table);
93592 + hdr = register_net_sysctl(net, "net/netfilter", table);
93593 + } else
93594 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93595 if (hdr == NULL)
93596 goto err_reg;
93597
93598 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93599 return 0;
93600
93601 err_reg:
93602 - if (!net_eq(net, &init_net))
93603 - kfree(table);
93604 + kfree(table);
93605 err_alloc:
93606 return -ENOMEM;
93607 }
93608 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93609 index ab92a36..bb4a528 100644
93610 --- a/net/ipv6/output_core.c
93611 +++ b/net/ipv6/output_core.c
93612 @@ -8,8 +8,8 @@
93613
93614 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93615 {
93616 - static atomic_t ipv6_fragmentation_id;
93617 - int old, new;
93618 + static atomic_unchecked_t ipv6_fragmentation_id;
93619 + int id;
93620
93621 #if IS_ENABLED(CONFIG_IPV6)
93622 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93623 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93624 }
93625 }
93626 #endif
93627 - do {
93628 - old = atomic_read(&ipv6_fragmentation_id);
93629 - new = old + 1;
93630 - if (!new)
93631 - new = 1;
93632 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93633 - fhdr->identification = htonl(new);
93634 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93635 + if (!id)
93636 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93637 + fhdr->identification = htonl(id);
93638 }
93639 EXPORT_SYMBOL(ipv6_select_ident);
93640
93641 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93642 index 18f19df..b46ada1 100644
93643 --- a/net/ipv6/ping.c
93644 +++ b/net/ipv6/ping.c
93645 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93646 };
93647 #endif
93648
93649 +static struct pingv6_ops real_pingv6_ops = {
93650 + .ipv6_recv_error = ipv6_recv_error,
93651 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93652 + .icmpv6_err_convert = icmpv6_err_convert,
93653 + .ipv6_icmp_error = ipv6_icmp_error,
93654 + .ipv6_chk_addr = ipv6_chk_addr,
93655 +};
93656 +
93657 +static struct pingv6_ops dummy_pingv6_ops = {
93658 + .ipv6_recv_error = dummy_ipv6_recv_error,
93659 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93660 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93661 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93662 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93663 +};
93664 +
93665 int __init pingv6_init(void)
93666 {
93667 #ifdef CONFIG_PROC_FS
93668 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93669 if (ret)
93670 return ret;
93671 #endif
93672 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93673 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93674 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93675 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93676 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93677 + pingv6_ops = &real_pingv6_ops;
93678 return inet6_register_protosw(&pingv6_protosw);
93679 }
93680
93681 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93682 */
93683 void pingv6_exit(void)
93684 {
93685 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93686 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93687 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93688 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93689 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93690 + pingv6_ops = &dummy_pingv6_ops;
93691 #ifdef CONFIG_PROC_FS
93692 unregister_pernet_subsys(&ping_v6_net_ops);
93693 #endif
93694 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93695 index cdaed47..515edde9 100644
93696 --- a/net/ipv6/raw.c
93697 +++ b/net/ipv6/raw.c
93698 @@ -108,7 +108,7 @@ found:
93699 */
93700 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93701 {
93702 - struct icmp6hdr *_hdr;
93703 + struct icmp6hdr _hdr;
93704 const struct icmp6hdr *hdr;
93705
93706 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93707 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93708 {
93709 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93710 skb_checksum_complete(skb)) {
93711 - atomic_inc(&sk->sk_drops);
93712 + atomic_inc_unchecked(&sk->sk_drops);
93713 kfree_skb(skb);
93714 return NET_RX_DROP;
93715 }
93716 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93717 struct raw6_sock *rp = raw6_sk(sk);
93718
93719 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93720 - atomic_inc(&sk->sk_drops);
93721 + atomic_inc_unchecked(&sk->sk_drops);
93722 kfree_skb(skb);
93723 return NET_RX_DROP;
93724 }
93725 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93726
93727 if (inet->hdrincl) {
93728 if (skb_checksum_complete(skb)) {
93729 - atomic_inc(&sk->sk_drops);
93730 + atomic_inc_unchecked(&sk->sk_drops);
93731 kfree_skb(skb);
93732 return NET_RX_DROP;
93733 }
93734 @@ -602,7 +602,7 @@ out:
93735 return err;
93736 }
93737
93738 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93739 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93740 struct flowi6 *fl6, struct dst_entry **dstp,
93741 unsigned int flags)
93742 {
93743 @@ -915,12 +915,15 @@ do_confirm:
93744 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93745 char __user *optval, int optlen)
93746 {
93747 + struct icmp6_filter filter;
93748 +
93749 switch (optname) {
93750 case ICMPV6_FILTER:
93751 if (optlen > sizeof(struct icmp6_filter))
93752 optlen = sizeof(struct icmp6_filter);
93753 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93754 + if (copy_from_user(&filter, optval, optlen))
93755 return -EFAULT;
93756 + raw6_sk(sk)->filter = filter;
93757 return 0;
93758 default:
93759 return -ENOPROTOOPT;
93760 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93761 char __user *optval, int __user *optlen)
93762 {
93763 int len;
93764 + struct icmp6_filter filter;
93765
93766 switch (optname) {
93767 case ICMPV6_FILTER:
93768 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93769 len = sizeof(struct icmp6_filter);
93770 if (put_user(len, optlen))
93771 return -EFAULT;
93772 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93773 + filter = raw6_sk(sk)->filter;
93774 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93775 return -EFAULT;
93776 return 0;
93777 default:
93778 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93779 index 1aeb473..bea761c 100644
93780 --- a/net/ipv6/reassembly.c
93781 +++ b/net/ipv6/reassembly.c
93782 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93783
93784 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93785 {
93786 - struct ctl_table *table;
93787 + ctl_table_no_const *table = NULL;
93788 struct ctl_table_header *hdr;
93789
93790 - table = ip6_frags_ns_ctl_table;
93791 if (!net_eq(net, &init_net)) {
93792 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93793 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93794 if (table == NULL)
93795 goto err_alloc;
93796
93797 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93798 /* Don't export sysctls to unprivileged users */
93799 if (net->user_ns != &init_user_ns)
93800 table[0].procname = NULL;
93801 - }
93802 + hdr = register_net_sysctl(net, "net/ipv6", table);
93803 + } else
93804 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93805
93806 - hdr = register_net_sysctl(net, "net/ipv6", table);
93807 if (hdr == NULL)
93808 goto err_reg;
93809
93810 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93811 return 0;
93812
93813 err_reg:
93814 - if (!net_eq(net, &init_net))
93815 - kfree(table);
93816 + kfree(table);
93817 err_alloc:
93818 return -ENOMEM;
93819 }
93820 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93821 index 8d9a93ed..cd89616 100644
93822 --- a/net/ipv6/route.c
93823 +++ b/net/ipv6/route.c
93824 @@ -2926,7 +2926,7 @@ struct ctl_table ipv6_route_table_template[] = {
93825
93826 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93827 {
93828 - struct ctl_table *table;
93829 + ctl_table_no_const *table;
93830
93831 table = kmemdup(ipv6_route_table_template,
93832 sizeof(ipv6_route_table_template),
93833 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93834 index 86f639b..71e355e 100644
93835 --- a/net/ipv6/sit.c
93836 +++ b/net/ipv6/sit.c
93837 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93838 static void ipip6_dev_free(struct net_device *dev);
93839 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93840 __be32 *v4dst);
93841 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93842 +static struct rtnl_link_ops sit_link_ops;
93843
93844 static int sit_net_id __read_mostly;
93845 struct sit_net {
93846 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93847 #endif
93848 };
93849
93850 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93851 +static struct rtnl_link_ops sit_link_ops = {
93852 .kind = "sit",
93853 .maxtype = IFLA_IPTUN_MAX,
93854 .policy = ipip6_policy,
93855 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93856 index 107b2f1..72741a9 100644
93857 --- a/net/ipv6/sysctl_net_ipv6.c
93858 +++ b/net/ipv6/sysctl_net_ipv6.c
93859 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93860
93861 static int __net_init ipv6_sysctl_net_init(struct net *net)
93862 {
93863 - struct ctl_table *ipv6_table;
93864 + ctl_table_no_const *ipv6_table;
93865 struct ctl_table *ipv6_route_table;
93866 struct ctl_table *ipv6_icmp_table;
93867 int err;
93868 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93869 index 6e1649d..75ddb4c 100644
93870 --- a/net/ipv6/tcp_ipv6.c
93871 +++ b/net/ipv6/tcp_ipv6.c
93872 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93873 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93874 }
93875
93876 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93877 +extern int grsec_enable_blackhole;
93878 +#endif
93879 +
93880 static void tcp_v6_hash(struct sock *sk)
93881 {
93882 if (sk->sk_state != TCP_CLOSE) {
93883 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93884 return 0;
93885
93886 reset:
93887 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93888 + if (!grsec_enable_blackhole)
93889 +#endif
93890 tcp_v6_send_reset(sk, skb);
93891 discard:
93892 if (opt_skb)
93893 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93894 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93895 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93896 if (np->rxopt.bits.rxtclass)
93897 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93898 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93899 if (ipv6_opt_accepted(sk, opt_skb)) {
93900 skb_set_owner_r(opt_skb, sk);
93901 opt_skb = xchg(&np->pktoptions, opt_skb);
93902 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93903 TCP_SKB_CB(skb)->sacked = 0;
93904
93905 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93906 - if (!sk)
93907 + if (!sk) {
93908 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93909 + ret = 1;
93910 +#endif
93911 goto no_tcp_socket;
93912 + }
93913
93914 process:
93915 - if (sk->sk_state == TCP_TIME_WAIT)
93916 + if (sk->sk_state == TCP_TIME_WAIT) {
93917 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93918 + ret = 2;
93919 +#endif
93920 goto do_time_wait;
93921 + }
93922
93923 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93924 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93925 @@ -1538,6 +1553,10 @@ csum_error:
93926 bad_packet:
93927 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93928 } else {
93929 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93930 + if (!grsec_enable_blackhole || (ret == 1 &&
93931 + (skb->dev->flags & IFF_LOOPBACK)))
93932 +#endif
93933 tcp_v6_send_reset(NULL, skb);
93934 }
93935
93936 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93937 index f405815..45a68a6 100644
93938 --- a/net/ipv6/udp.c
93939 +++ b/net/ipv6/udp.c
93940 @@ -53,6 +53,10 @@
93941 #include <trace/events/skb.h>
93942 #include "udp_impl.h"
93943
93944 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93945 +extern int grsec_enable_blackhole;
93946 +#endif
93947 +
93948 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93949 {
93950 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93951 @@ -420,7 +424,7 @@ try_again:
93952 if (unlikely(err)) {
93953 trace_kfree_skb(skb, udpv6_recvmsg);
93954 if (!peeked) {
93955 - atomic_inc(&sk->sk_drops);
93956 + atomic_inc_unchecked(&sk->sk_drops);
93957 if (is_udp4)
93958 UDP_INC_STATS_USER(sock_net(sk),
93959 UDP_MIB_INERRORS,
93960 @@ -666,7 +670,7 @@ csum_error:
93961 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93962 drop:
93963 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93964 - atomic_inc(&sk->sk_drops);
93965 + atomic_inc_unchecked(&sk->sk_drops);
93966 kfree_skb(skb);
93967 return -1;
93968 }
93969 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93970 if (likely(skb1 == NULL))
93971 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93972 if (!skb1) {
93973 - atomic_inc(&sk->sk_drops);
93974 + atomic_inc_unchecked(&sk->sk_drops);
93975 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93976 IS_UDPLITE(sk));
93977 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93978 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93979 goto csum_error;
93980
93981 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93982 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93983 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93984 +#endif
93985 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93986
93987 kfree_skb(skb);
93988 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93989 index 23ed03d..6532e67 100644
93990 --- a/net/ipv6/xfrm6_policy.c
93991 +++ b/net/ipv6/xfrm6_policy.c
93992 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93993 }
93994 }
93995
93996 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93997 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93998 {
93999 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94000
94001 - xfrm6_policy_afinfo.garbage_collect(net);
94002 + xfrm_garbage_collect_deferred(net);
94003 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94004 }
94005
94006 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94007
94008 static int __net_init xfrm6_net_init(struct net *net)
94009 {
94010 - struct ctl_table *table;
94011 + ctl_table_no_const *table = NULL;
94012 struct ctl_table_header *hdr;
94013
94014 - table = xfrm6_policy_table;
94015 if (!net_eq(net, &init_net)) {
94016 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94017 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94018 if (!table)
94019 goto err_alloc;
94020
94021 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94022 - }
94023 + hdr = register_net_sysctl(net, "net/ipv6", table);
94024 + } else
94025 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94026
94027 - hdr = register_net_sysctl(net, "net/ipv6", table);
94028 if (!hdr)
94029 goto err_reg;
94030
94031 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94032 return 0;
94033
94034 err_reg:
94035 - if (!net_eq(net, &init_net))
94036 - kfree(table);
94037 + kfree(table);
94038 err_alloc:
94039 return -ENOMEM;
94040 }
94041 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94042 index 41ac7938..75e3bb1 100644
94043 --- a/net/irda/ircomm/ircomm_tty.c
94044 +++ b/net/irda/ircomm/ircomm_tty.c
94045 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94046 add_wait_queue(&port->open_wait, &wait);
94047
94048 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94049 - __FILE__, __LINE__, tty->driver->name, port->count);
94050 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94051
94052 spin_lock_irqsave(&port->lock, flags);
94053 if (!tty_hung_up_p(filp))
94054 - port->count--;
94055 + atomic_dec(&port->count);
94056 port->blocked_open++;
94057 spin_unlock_irqrestore(&port->lock, flags);
94058
94059 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94060 }
94061
94062 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
94063 - __FILE__, __LINE__, tty->driver->name, port->count);
94064 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94065
94066 schedule();
94067 }
94068 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94069
94070 spin_lock_irqsave(&port->lock, flags);
94071 if (!tty_hung_up_p(filp))
94072 - port->count++;
94073 + atomic_inc(&port->count);
94074 port->blocked_open--;
94075 spin_unlock_irqrestore(&port->lock, flags);
94076
94077 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
94078 - __FILE__, __LINE__, tty->driver->name, port->count);
94079 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94080
94081 if (!retval)
94082 port->flags |= ASYNC_NORMAL_ACTIVE;
94083 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
94084
94085 /* ++ is not atomic, so this should be protected - Jean II */
94086 spin_lock_irqsave(&self->port.lock, flags);
94087 - self->port.count++;
94088 + atomic_inc(&self->port.count);
94089 spin_unlock_irqrestore(&self->port.lock, flags);
94090 tty_port_tty_set(&self->port, tty);
94091
94092 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
94093 - self->line, self->port.count);
94094 + self->line, atomic_read(&self->port.count));
94095
94096 /* Not really used by us, but lets do it anyway */
94097 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
94098 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
94099 tty_kref_put(port->tty);
94100 }
94101 port->tty = NULL;
94102 - port->count = 0;
94103 + atomic_set(&port->count, 0);
94104 spin_unlock_irqrestore(&port->lock, flags);
94105
94106 wake_up_interruptible(&port->open_wait);
94107 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
94108 seq_putc(m, '\n');
94109
94110 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
94111 - seq_printf(m, "Open count: %d\n", self->port.count);
94112 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
94113 seq_printf(m, "Max data size: %d\n", self->max_data_size);
94114 seq_printf(m, "Max header size: %d\n", self->max_header_size);
94115
94116 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
94117 index 168aff5..9d43132 100644
94118 --- a/net/iucv/af_iucv.c
94119 +++ b/net/iucv/af_iucv.c
94120 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
94121
94122 write_lock_bh(&iucv_sk_list.lock);
94123
94124 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
94125 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94126 while (__iucv_get_sock_by_name(name)) {
94127 sprintf(name, "%08x",
94128 - atomic_inc_return(&iucv_sk_list.autobind_name));
94129 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94130 }
94131
94132 write_unlock_bh(&iucv_sk_list.lock);
94133 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
94134 index cd5b8ec..f205e6b 100644
94135 --- a/net/iucv/iucv.c
94136 +++ b/net/iucv/iucv.c
94137 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
94138 return NOTIFY_OK;
94139 }
94140
94141 -static struct notifier_block __refdata iucv_cpu_notifier = {
94142 +static struct notifier_block iucv_cpu_notifier = {
94143 .notifier_call = iucv_cpu_notify,
94144 };
94145
94146 diff --git a/net/key/af_key.c b/net/key/af_key.c
94147 index ab8bd2c..3a3eb81 100644
94148 --- a/net/key/af_key.c
94149 +++ b/net/key/af_key.c
94150 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
94151
94152 x->id.proto = proto;
94153 x->id.spi = sa->sadb_sa_spi;
94154 - x->props.replay_window = sa->sadb_sa_replay;
94155 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
94156 + (sizeof(x->replay.bitmap) * 8));
94157 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
94158 x->props.flags |= XFRM_STATE_NOECN;
94159 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
94160 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
94161 static u32 get_acqseq(void)
94162 {
94163 u32 res;
94164 - static atomic_t acqseq;
94165 + static atomic_unchecked_t acqseq;
94166
94167 do {
94168 - res = atomic_inc_return(&acqseq);
94169 + res = atomic_inc_return_unchecked(&acqseq);
94170 } while (!res);
94171 return res;
94172 }
94173 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
94174 index feae495..aedaa2c 100644
94175 --- a/net/l2tp/l2tp_core.c
94176 +++ b/net/l2tp/l2tp_core.c
94177 @@ -496,6 +496,7 @@ out:
94178 static inline int l2tp_verify_udp_checksum(struct sock *sk,
94179 struct sk_buff *skb)
94180 {
94181 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
94182 struct udphdr *uh = udp_hdr(skb);
94183 u16 ulen = ntohs(uh->len);
94184 __wsum psum;
94185 @@ -504,7 +505,7 @@ static inline int l2tp_verify_udp_checksum(struct sock *sk,
94186 return 0;
94187
94188 #if IS_ENABLED(CONFIG_IPV6)
94189 - if (sk->sk_family == PF_INET6) {
94190 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped) {
94191 if (!uh->check) {
94192 LIMIT_NETDEBUG(KERN_INFO "L2TP: IPv6: checksum is 0\n");
94193 return 1;
94194 @@ -1128,7 +1129,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
94195 /* Queue the packet to IP for output */
94196 skb->local_df = 1;
94197 #if IS_ENABLED(CONFIG_IPV6)
94198 - if (skb->sk->sk_family == PF_INET6)
94199 + if (skb->sk->sk_family == PF_INET6 && !tunnel->v4mapped)
94200 error = inet6_csk_xmit(skb, NULL);
94201 else
94202 #endif
94203 @@ -1255,7 +1256,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
94204
94205 /* Calculate UDP checksum if configured to do so */
94206 #if IS_ENABLED(CONFIG_IPV6)
94207 - if (sk->sk_family == PF_INET6)
94208 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
94209 l2tp_xmit_ipv6_csum(sk, skb, udp_len);
94210 else
94211 #endif
94212 @@ -1704,6 +1705,24 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
94213 if (cfg != NULL)
94214 tunnel->debug = cfg->debug;
94215
94216 +#if IS_ENABLED(CONFIG_IPV6)
94217 + if (sk->sk_family == PF_INET6) {
94218 + struct ipv6_pinfo *np = inet6_sk(sk);
94219 +
94220 + if (ipv6_addr_v4mapped(&np->saddr) &&
94221 + ipv6_addr_v4mapped(&np->daddr)) {
94222 + struct inet_sock *inet = inet_sk(sk);
94223 +
94224 + tunnel->v4mapped = true;
94225 + inet->inet_saddr = np->saddr.s6_addr32[3];
94226 + inet->inet_rcv_saddr = np->rcv_saddr.s6_addr32[3];
94227 + inet->inet_daddr = np->daddr.s6_addr32[3];
94228 + } else {
94229 + tunnel->v4mapped = false;
94230 + }
94231 + }
94232 +#endif
94233 +
94234 /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
94235 tunnel->encap = encap;
94236 if (encap == L2TP_ENCAPTYPE_UDP) {
94237 @@ -1712,7 +1731,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
94238 udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv;
94239 udp_sk(sk)->encap_destroy = l2tp_udp_encap_destroy;
94240 #if IS_ENABLED(CONFIG_IPV6)
94241 - if (sk->sk_family == PF_INET6)
94242 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
94243 udpv6_encap_enable();
94244 else
94245 #endif
94246 diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
94247 index 66a559b..6f251cb 100644
94248 --- a/net/l2tp/l2tp_core.h
94249 +++ b/net/l2tp/l2tp_core.h
94250 @@ -194,6 +194,9 @@ struct l2tp_tunnel {
94251 struct sock *sock; /* Parent socket */
94252 int fd; /* Parent fd, if tunnel socket
94253 * was created by userspace */
94254 +#if IS_ENABLED(CONFIG_IPV6)
94255 + bool v4mapped;
94256 +#endif
94257
94258 struct work_struct del_work;
94259
94260 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
94261 index 43dd752..63a23bc 100644
94262 --- a/net/mac80211/cfg.c
94263 +++ b/net/mac80211/cfg.c
94264 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
94265 ret = ieee80211_vif_use_channel(sdata, chandef,
94266 IEEE80211_CHANCTX_EXCLUSIVE);
94267 }
94268 - } else if (local->open_count == local->monitors) {
94269 + } else if (local_read(&local->open_count) == local->monitors) {
94270 local->_oper_chandef = *chandef;
94271 ieee80211_hw_config(local, 0);
94272 }
94273 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
94274 else
94275 local->probe_req_reg--;
94276
94277 - if (!local->open_count)
94278 + if (!local_read(&local->open_count))
94279 break;
94280
94281 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
94282 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
94283 if (chanctx_conf) {
94284 *chandef = chanctx_conf->def;
94285 ret = 0;
94286 - } else if (local->open_count > 0 &&
94287 - local->open_count == local->monitors &&
94288 + } else if (local_read(&local->open_count) > 0 &&
94289 + local_read(&local->open_count) == local->monitors &&
94290 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94291 if (local->use_chanctx)
94292 *chandef = local->monitor_chandef;
94293 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94294 index 8412a30..6e00181 100644
94295 --- a/net/mac80211/ieee80211_i.h
94296 +++ b/net/mac80211/ieee80211_i.h
94297 @@ -28,6 +28,7 @@
94298 #include <net/ieee80211_radiotap.h>
94299 #include <net/cfg80211.h>
94300 #include <net/mac80211.h>
94301 +#include <asm/local.h>
94302 #include "key.h"
94303 #include "sta_info.h"
94304 #include "debug.h"
94305 @@ -907,7 +908,7 @@ struct ieee80211_local {
94306 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94307 spinlock_t queue_stop_reason_lock;
94308
94309 - int open_count;
94310 + local_t open_count;
94311 int monitors, cooked_mntrs;
94312 /* number of interfaces with corresponding FIF_ flags */
94313 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94314 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94315 index cc11759..11d5541 100644
94316 --- a/net/mac80211/iface.c
94317 +++ b/net/mac80211/iface.c
94318 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94319 break;
94320 }
94321
94322 - if (local->open_count == 0) {
94323 + if (local_read(&local->open_count) == 0) {
94324 res = drv_start(local);
94325 if (res)
94326 goto err_del_bss;
94327 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94328 res = drv_add_interface(local, sdata);
94329 if (res)
94330 goto err_stop;
94331 - } else if (local->monitors == 0 && local->open_count == 0) {
94332 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94333 res = ieee80211_add_virtual_monitor(local);
94334 if (res)
94335 goto err_stop;
94336 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94337 atomic_inc(&local->iff_promiscs);
94338
94339 if (coming_up)
94340 - local->open_count++;
94341 + local_inc(&local->open_count);
94342
94343 if (hw_reconf_flags)
94344 ieee80211_hw_config(local, hw_reconf_flags);
94345 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94346 err_del_interface:
94347 drv_remove_interface(local, sdata);
94348 err_stop:
94349 - if (!local->open_count)
94350 + if (!local_read(&local->open_count))
94351 drv_stop(local);
94352 err_del_bss:
94353 sdata->bss = NULL;
94354 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94355 }
94356
94357 if (going_down)
94358 - local->open_count--;
94359 + local_dec(&local->open_count);
94360
94361 switch (sdata->vif.type) {
94362 case NL80211_IFTYPE_AP_VLAN:
94363 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94364 }
94365 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94366
94367 - if (local->open_count == 0)
94368 + if (local_read(&local->open_count) == 0)
94369 ieee80211_clear_tx_pending(local);
94370
94371 /*
94372 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94373
94374 ieee80211_recalc_ps(local, -1);
94375
94376 - if (local->open_count == 0) {
94377 + if (local_read(&local->open_count) == 0) {
94378 ieee80211_stop_device(local);
94379
94380 /* no reconfiguring after stop! */
94381 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94382 ieee80211_configure_filter(local);
94383 ieee80211_hw_config(local, hw_reconf_flags);
94384
94385 - if (local->monitors == local->open_count)
94386 + if (local->monitors == local_read(&local->open_count))
94387 ieee80211_add_virtual_monitor(local);
94388 }
94389
94390 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94391 index 091088a..daf43c7 100644
94392 --- a/net/mac80211/main.c
94393 +++ b/net/mac80211/main.c
94394 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94395 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94396 IEEE80211_CONF_CHANGE_POWER);
94397
94398 - if (changed && local->open_count) {
94399 + if (changed && local_read(&local->open_count)) {
94400 ret = drv_config(local, changed);
94401 /*
94402 * Goal:
94403 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94404 index 3401262..d5cd68d 100644
94405 --- a/net/mac80211/pm.c
94406 +++ b/net/mac80211/pm.c
94407 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94408 struct ieee80211_sub_if_data *sdata;
94409 struct sta_info *sta;
94410
94411 - if (!local->open_count)
94412 + if (!local_read(&local->open_count))
94413 goto suspend;
94414
94415 ieee80211_scan_cancel(local);
94416 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94417 cancel_work_sync(&local->dynamic_ps_enable_work);
94418 del_timer_sync(&local->dynamic_ps_timer);
94419
94420 - local->wowlan = wowlan && local->open_count;
94421 + local->wowlan = wowlan && local_read(&local->open_count);
94422 if (local->wowlan) {
94423 int err = drv_suspend(local, wowlan);
94424 if (err < 0) {
94425 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94426 WARN_ON(!list_empty(&local->chanctx_list));
94427
94428 /* stop hardware - this must stop RX */
94429 - if (local->open_count)
94430 + if (local_read(&local->open_count))
94431 ieee80211_stop_device(local);
94432
94433 suspend:
94434 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94435 index 30d58d2..449ac8e 100644
94436 --- a/net/mac80211/rate.c
94437 +++ b/net/mac80211/rate.c
94438 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94439
94440 ASSERT_RTNL();
94441
94442 - if (local->open_count)
94443 + if (local_read(&local->open_count))
94444 return -EBUSY;
94445
94446 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94447 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94448 index c97a065..ff61928 100644
94449 --- a/net/mac80211/rc80211_pid_debugfs.c
94450 +++ b/net/mac80211/rc80211_pid_debugfs.c
94451 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94452
94453 spin_unlock_irqrestore(&events->lock, status);
94454
94455 - if (copy_to_user(buf, pb, p))
94456 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94457 return -EFAULT;
94458
94459 return p;
94460 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94461 index 2265445..ba14971 100644
94462 --- a/net/mac80211/util.c
94463 +++ b/net/mac80211/util.c
94464 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94465 }
94466 #endif
94467 /* everything else happens only if HW was up & running */
94468 - if (!local->open_count)
94469 + if (!local_read(&local->open_count))
94470 goto wake_up;
94471
94472 /*
94473 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94474 local->in_reconfig = false;
94475 barrier();
94476
94477 - if (local->monitors == local->open_count && local->monitors > 0)
94478 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94479 ieee80211_add_virtual_monitor(local);
94480
94481 /*
94482 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94483 index 56d22ca..87c778f 100644
94484 --- a/net/netfilter/Kconfig
94485 +++ b/net/netfilter/Kconfig
94486 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94487
94488 To compile it as a module, choose M here. If unsure, say N.
94489
94490 +config NETFILTER_XT_MATCH_GRADM
94491 + tristate '"gradm" match support'
94492 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94493 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94494 + ---help---
94495 + The gradm match allows to match on grsecurity RBAC being enabled.
94496 + It is useful when iptables rules are applied early on bootup to
94497 + prevent connections to the machine (except from a trusted host)
94498 + while the RBAC system is disabled.
94499 +
94500 config NETFILTER_XT_MATCH_HASHLIMIT
94501 tristate '"hashlimit" match support'
94502 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94503 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94504 index a1abf87..dbcb7ee 100644
94505 --- a/net/netfilter/Makefile
94506 +++ b/net/netfilter/Makefile
94507 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94508 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94509 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94510 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94511 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94512 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94513 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94514 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94515 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94516 index f771390..145b765 100644
94517 --- a/net/netfilter/ipset/ip_set_core.c
94518 +++ b/net/netfilter/ipset/ip_set_core.c
94519 @@ -1820,7 +1820,7 @@ done:
94520 return ret;
94521 }
94522
94523 -static struct nf_sockopt_ops so_set __read_mostly = {
94524 +static struct nf_sockopt_ops so_set = {
94525 .pf = PF_INET,
94526 .get_optmin = SO_IP_SET,
94527 .get_optmax = SO_IP_SET + 1,
94528 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94529 index 4c8e5c0..5a79b4d 100644
94530 --- a/net/netfilter/ipvs/ip_vs_conn.c
94531 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94532 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94533 /* Increase the refcnt counter of the dest */
94534 ip_vs_dest_hold(dest);
94535
94536 - conn_flags = atomic_read(&dest->conn_flags);
94537 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94538 if (cp->protocol != IPPROTO_UDP)
94539 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94540 flags = cp->flags;
94541 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94542
94543 cp->control = NULL;
94544 atomic_set(&cp->n_control, 0);
94545 - atomic_set(&cp->in_pkts, 0);
94546 + atomic_set_unchecked(&cp->in_pkts, 0);
94547
94548 cp->packet_xmit = NULL;
94549 cp->app = NULL;
94550 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94551
94552 /* Don't drop the entry if its number of incoming packets is not
94553 located in [0, 8] */
94554 - i = atomic_read(&cp->in_pkts);
94555 + i = atomic_read_unchecked(&cp->in_pkts);
94556 if (i > 8 || i < 0) return 0;
94557
94558 if (!todrop_rate[i]) return 0;
94559 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94560 index 4f69e83..da2d8bf 100644
94561 --- a/net/netfilter/ipvs/ip_vs_core.c
94562 +++ b/net/netfilter/ipvs/ip_vs_core.c
94563 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94564 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94565 /* do not touch skb anymore */
94566
94567 - atomic_inc(&cp->in_pkts);
94568 + atomic_inc_unchecked(&cp->in_pkts);
94569 ip_vs_conn_put(cp);
94570 return ret;
94571 }
94572 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94573 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94574 pkts = sysctl_sync_threshold(ipvs);
94575 else
94576 - pkts = atomic_add_return(1, &cp->in_pkts);
94577 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94578
94579 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94580 ip_vs_sync_conn(net, cp, pkts);
94581 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94582 index c8148e4..eff604f 100644
94583 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94584 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94585 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94586 */
94587 ip_vs_rs_hash(ipvs, dest);
94588 }
94589 - atomic_set(&dest->conn_flags, conn_flags);
94590 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94591
94592 /* bind the service */
94593 if (!dest->svc) {
94594 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94595 * align with netns init in ip_vs_control_net_init()
94596 */
94597
94598 -static struct ctl_table vs_vars[] = {
94599 +static ctl_table_no_const vs_vars[] __read_only = {
94600 {
94601 .procname = "amemthresh",
94602 .maxlen = sizeof(int),
94603 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94604 " %-7s %-6d %-10d %-10d\n",
94605 &dest->addr.in6,
94606 ntohs(dest->port),
94607 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94608 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94609 atomic_read(&dest->weight),
94610 atomic_read(&dest->activeconns),
94611 atomic_read(&dest->inactconns));
94612 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94613 "%-7s %-6d %-10d %-10d\n",
94614 ntohl(dest->addr.ip),
94615 ntohs(dest->port),
94616 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94617 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94618 atomic_read(&dest->weight),
94619 atomic_read(&dest->activeconns),
94620 atomic_read(&dest->inactconns));
94621 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94622
94623 entry.addr = dest->addr.ip;
94624 entry.port = dest->port;
94625 - entry.conn_flags = atomic_read(&dest->conn_flags);
94626 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94627 entry.weight = atomic_read(&dest->weight);
94628 entry.u_threshold = dest->u_threshold;
94629 entry.l_threshold = dest->l_threshold;
94630 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94631 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94632 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94633 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94634 - (atomic_read(&dest->conn_flags) &
94635 + (atomic_read_unchecked(&dest->conn_flags) &
94636 IP_VS_CONN_F_FWD_MASK)) ||
94637 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94638 atomic_read(&dest->weight)) ||
94639 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94640 {
94641 int idx;
94642 struct netns_ipvs *ipvs = net_ipvs(net);
94643 - struct ctl_table *tbl;
94644 + ctl_table_no_const *tbl;
94645
94646 atomic_set(&ipvs->dropentry, 0);
94647 spin_lock_init(&ipvs->dropentry_lock);
94648 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94649 index 1383b0e..a486da1 100644
94650 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94651 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94652 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94653 * IPVS LBLC sysctl table
94654 */
94655 #ifdef CONFIG_SYSCTL
94656 -static struct ctl_table vs_vars_table[] = {
94657 +static ctl_table_no_const vs_vars_table[] __read_only = {
94658 {
94659 .procname = "lblc_expiration",
94660 .data = NULL,
94661 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94662 index 3cd85b2..dfab2b8 100644
94663 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94664 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94665 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94666 * IPVS LBLCR sysctl table
94667 */
94668
94669 -static struct ctl_table vs_vars_table[] = {
94670 +static ctl_table_no_const vs_vars_table[] __read_only = {
94671 {
94672 .procname = "lblcr_expiration",
94673 .data = NULL,
94674 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94675 index f448471..995f131 100644
94676 --- a/net/netfilter/ipvs/ip_vs_sync.c
94677 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94678 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94679 cp = cp->control;
94680 if (cp) {
94681 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94682 - pkts = atomic_add_return(1, &cp->in_pkts);
94683 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94684 else
94685 pkts = sysctl_sync_threshold(ipvs);
94686 ip_vs_sync_conn(net, cp->control, pkts);
94687 @@ -771,7 +771,7 @@ control:
94688 if (!cp)
94689 return;
94690 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94691 - pkts = atomic_add_return(1, &cp->in_pkts);
94692 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94693 else
94694 pkts = sysctl_sync_threshold(ipvs);
94695 goto sloop;
94696 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94697
94698 if (opt)
94699 memcpy(&cp->in_seq, opt, sizeof(*opt));
94700 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94701 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94702 cp->state = state;
94703 cp->old_state = cp->state;
94704 /*
94705 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94706 index c47444e..b0961c6 100644
94707 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94708 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94709 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94710 else
94711 rc = NF_ACCEPT;
94712 /* do not touch skb anymore */
94713 - atomic_inc(&cp->in_pkts);
94714 + atomic_inc_unchecked(&cp->in_pkts);
94715 goto out;
94716 }
94717
94718 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94719 else
94720 rc = NF_ACCEPT;
94721 /* do not touch skb anymore */
94722 - atomic_inc(&cp->in_pkts);
94723 + atomic_inc_unchecked(&cp->in_pkts);
94724 goto out;
94725 }
94726
94727 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94728 index 2d3030a..7ba1c0a 100644
94729 --- a/net/netfilter/nf_conntrack_acct.c
94730 +++ b/net/netfilter/nf_conntrack_acct.c
94731 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94732 #ifdef CONFIG_SYSCTL
94733 static int nf_conntrack_acct_init_sysctl(struct net *net)
94734 {
94735 - struct ctl_table *table;
94736 + ctl_table_no_const *table;
94737
94738 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94739 GFP_KERNEL);
94740 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94741 index 0283bae..5febcb0 100644
94742 --- a/net/netfilter/nf_conntrack_core.c
94743 +++ b/net/netfilter/nf_conntrack_core.c
94744 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94745 #define DYING_NULLS_VAL ((1<<30)+1)
94746 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94747
94748 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94749 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94750 +#endif
94751 +
94752 int nf_conntrack_init_net(struct net *net)
94753 {
94754 int ret;
94755 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94756 goto err_stat;
94757 }
94758
94759 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94760 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94761 +#else
94762 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94763 +#endif
94764 if (!net->ct.slabname) {
94765 ret = -ENOMEM;
94766 goto err_slabname;
94767 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94768 index 1df1761..ce8b88a 100644
94769 --- a/net/netfilter/nf_conntrack_ecache.c
94770 +++ b/net/netfilter/nf_conntrack_ecache.c
94771 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94772 #ifdef CONFIG_SYSCTL
94773 static int nf_conntrack_event_init_sysctl(struct net *net)
94774 {
94775 - struct ctl_table *table;
94776 + ctl_table_no_const *table;
94777
94778 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94779 GFP_KERNEL);
94780 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94781 index 974a2a4..52cc6ff 100644
94782 --- a/net/netfilter/nf_conntrack_helper.c
94783 +++ b/net/netfilter/nf_conntrack_helper.c
94784 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94785
94786 static int nf_conntrack_helper_init_sysctl(struct net *net)
94787 {
94788 - struct ctl_table *table;
94789 + ctl_table_no_const *table;
94790
94791 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94792 GFP_KERNEL);
94793 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94794 index 0ab9636..cea3c6a 100644
94795 --- a/net/netfilter/nf_conntrack_proto.c
94796 +++ b/net/netfilter/nf_conntrack_proto.c
94797 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94798
94799 static void
94800 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94801 - struct ctl_table **table,
94802 + ctl_table_no_const **table,
94803 unsigned int users)
94804 {
94805 if (users > 0)
94806 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94807 index a99b6c3..cb372f9 100644
94808 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94809 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94810 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94811 const char *msg;
94812 u_int8_t state;
94813
94814 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94815 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94816 BUG_ON(dh == NULL);
94817
94818 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94819 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94820 out_invalid:
94821 if (LOG_INVALID(net, IPPROTO_DCCP))
94822 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94823 - NULL, msg);
94824 + NULL, "%s", msg);
94825 return false;
94826 }
94827
94828 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94829 u_int8_t type, old_state, new_state;
94830 enum ct_dccp_roles role;
94831
94832 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94833 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94834 BUG_ON(dh == NULL);
94835 type = dh->dccph_type;
94836
94837 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94838 unsigned int cscov;
94839 const char *msg;
94840
94841 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94842 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94843 if (dh == NULL) {
94844 msg = "nf_ct_dccp: short packet ";
94845 goto out_invalid;
94846 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94847
94848 out_invalid:
94849 if (LOG_INVALID(net, IPPROTO_DCCP))
94850 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94851 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94852 return -NF_ACCEPT;
94853 }
94854
94855 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94856 index f641751..d3c5b51 100644
94857 --- a/net/netfilter/nf_conntrack_standalone.c
94858 +++ b/net/netfilter/nf_conntrack_standalone.c
94859 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94860
94861 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94862 {
94863 - struct ctl_table *table;
94864 + ctl_table_no_const *table;
94865
94866 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94867 GFP_KERNEL);
94868 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94869 index 902fb0a..87f7fdb 100644
94870 --- a/net/netfilter/nf_conntrack_timestamp.c
94871 +++ b/net/netfilter/nf_conntrack_timestamp.c
94872 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94873 #ifdef CONFIG_SYSCTL
94874 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94875 {
94876 - struct ctl_table *table;
94877 + ctl_table_no_const *table;
94878
94879 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94880 GFP_KERNEL);
94881 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94882 index 85296d4..8becdec 100644
94883 --- a/net/netfilter/nf_log.c
94884 +++ b/net/netfilter/nf_log.c
94885 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94886
94887 #ifdef CONFIG_SYSCTL
94888 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94889 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94890 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94891
94892 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94893 void __user *buffer, size_t *lenp, loff_t *ppos)
94894 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94895 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94896 mutex_unlock(&nf_log_mutex);
94897 } else {
94898 + ctl_table_no_const nf_log_table = *table;
94899 +
94900 mutex_lock(&nf_log_mutex);
94901 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94902 lockdep_is_held(&nf_log_mutex));
94903 if (!logger)
94904 - table->data = "NONE";
94905 + nf_log_table.data = "NONE";
94906 else
94907 - table->data = logger->name;
94908 - r = proc_dostring(table, write, buffer, lenp, ppos);
94909 + nf_log_table.data = logger->name;
94910 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94911 mutex_unlock(&nf_log_mutex);
94912 }
94913
94914 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94915 index f042ae5..30ea486 100644
94916 --- a/net/netfilter/nf_sockopt.c
94917 +++ b/net/netfilter/nf_sockopt.c
94918 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94919 }
94920 }
94921
94922 - list_add(&reg->list, &nf_sockopts);
94923 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94924 out:
94925 mutex_unlock(&nf_sockopt_mutex);
94926 return ret;
94927 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94928 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94929 {
94930 mutex_lock(&nf_sockopt_mutex);
94931 - list_del(&reg->list);
94932 + pax_list_del((struct list_head *)&reg->list);
94933 mutex_unlock(&nf_sockopt_mutex);
94934 }
94935 EXPORT_SYMBOL(nf_unregister_sockopt);
94936 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94937 index d92cc31..e46f350 100644
94938 --- a/net/netfilter/nfnetlink_log.c
94939 +++ b/net/netfilter/nfnetlink_log.c
94940 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94941 struct nfnl_log_net {
94942 spinlock_t instances_lock;
94943 struct hlist_head instance_table[INSTANCE_BUCKETS];
94944 - atomic_t global_seq;
94945 + atomic_unchecked_t global_seq;
94946 };
94947
94948 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94949 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94950 /* global sequence number */
94951 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94952 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94953 - htonl(atomic_inc_return(&log->global_seq))))
94954 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94955 goto nla_put_failure;
94956
94957 if (data_len) {
94958 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94959 new file mode 100644
94960 index 0000000..c566332
94961 --- /dev/null
94962 +++ b/net/netfilter/xt_gradm.c
94963 @@ -0,0 +1,51 @@
94964 +/*
94965 + * gradm match for netfilter
94966 + * Copyright © Zbigniew Krzystolik, 2010
94967 + *
94968 + * This program is free software; you can redistribute it and/or modify
94969 + * it under the terms of the GNU General Public License; either version
94970 + * 2 or 3 as published by the Free Software Foundation.
94971 + */
94972 +#include <linux/module.h>
94973 +#include <linux/moduleparam.h>
94974 +#include <linux/skbuff.h>
94975 +#include <linux/netfilter/x_tables.h>
94976 +#include <linux/grsecurity.h>
94977 +#include <linux/netfilter/xt_gradm.h>
94978 +
94979 +static bool
94980 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94981 +{
94982 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94983 + bool retval = false;
94984 + if (gr_acl_is_enabled())
94985 + retval = true;
94986 + return retval ^ info->invflags;
94987 +}
94988 +
94989 +static struct xt_match gradm_mt_reg __read_mostly = {
94990 + .name = "gradm",
94991 + .revision = 0,
94992 + .family = NFPROTO_UNSPEC,
94993 + .match = gradm_mt,
94994 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94995 + .me = THIS_MODULE,
94996 +};
94997 +
94998 +static int __init gradm_mt_init(void)
94999 +{
95000 + return xt_register_match(&gradm_mt_reg);
95001 +}
95002 +
95003 +static void __exit gradm_mt_exit(void)
95004 +{
95005 + xt_unregister_match(&gradm_mt_reg);
95006 +}
95007 +
95008 +module_init(gradm_mt_init);
95009 +module_exit(gradm_mt_exit);
95010 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95011 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95012 +MODULE_LICENSE("GPL");
95013 +MODULE_ALIAS("ipt_gradm");
95014 +MODULE_ALIAS("ip6t_gradm");
95015 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95016 index 4fe4fb4..87a89e5 100644
95017 --- a/net/netfilter/xt_statistic.c
95018 +++ b/net/netfilter/xt_statistic.c
95019 @@ -19,7 +19,7 @@
95020 #include <linux/module.h>
95021
95022 struct xt_statistic_priv {
95023 - atomic_t count;
95024 + atomic_unchecked_t count;
95025 } ____cacheline_aligned_in_smp;
95026
95027 MODULE_LICENSE("GPL");
95028 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95029 break;
95030 case XT_STATISTIC_MODE_NTH:
95031 do {
95032 - oval = atomic_read(&info->master->count);
95033 + oval = atomic_read_unchecked(&info->master->count);
95034 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95035 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95036 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95037 if (nval == 0)
95038 ret = !ret;
95039 break;
95040 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95041 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95042 if (info->master == NULL)
95043 return -ENOMEM;
95044 - atomic_set(&info->master->count, info->u.nth.count);
95045 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95046
95047 return 0;
95048 }
95049 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95050 index 0c61b59..941bddd 100644
95051 --- a/net/netlink/af_netlink.c
95052 +++ b/net/netlink/af_netlink.c
95053 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
95054 sk->sk_error_report(sk);
95055 }
95056 }
95057 - atomic_inc(&sk->sk_drops);
95058 + atomic_inc_unchecked(&sk->sk_drops);
95059 }
95060
95061 static void netlink_rcv_wake(struct sock *sk)
95062 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95063 sk_wmem_alloc_get(s),
95064 nlk->cb,
95065 atomic_read(&s->sk_refcnt),
95066 - atomic_read(&s->sk_drops),
95067 + atomic_read_unchecked(&s->sk_drops),
95068 sock_i_ino(s)
95069 );
95070
95071 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95072 index 0c741ce..f8c8ca7 100644
95073 --- a/net/netlink/genetlink.c
95074 +++ b/net/netlink/genetlink.c
95075 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95076 goto errout;
95077 }
95078
95079 + pax_open_kernel();
95080 if (ops->dumpit)
95081 - ops->flags |= GENL_CMD_CAP_DUMP;
95082 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95083 if (ops->doit)
95084 - ops->flags |= GENL_CMD_CAP_DO;
95085 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95086 if (ops->policy)
95087 - ops->flags |= GENL_CMD_CAP_HASPOL;
95088 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95089 + pax_close_kernel();
95090
95091 genl_lock_all();
95092 - list_add_tail(&ops->ops_list, &family->ops_list);
95093 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95094 genl_unlock_all();
95095
95096 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95097 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95098 err = 0;
95099 errout:
95100 return err;
95101 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95102 genl_lock_all();
95103 list_for_each_entry(rc, &family->ops_list, ops_list) {
95104 if (rc == ops) {
95105 - list_del(&ops->ops_list);
95106 + pax_list_del((struct list_head *)&ops->ops_list);
95107 genl_unlock_all();
95108 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95109 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95110 return 0;
95111 }
95112 }
95113 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95114 index 698814b..7cfde4e 100644
95115 --- a/net/netrom/af_netrom.c
95116 +++ b/net/netrom/af_netrom.c
95117 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95118 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95119 } else {
95120 sax->fsa_ax25.sax25_family = AF_NETROM;
95121 - sax->fsa_ax25.sax25_ndigis = 0;
95122 sax->fsa_ax25.sax25_call = nr->source_addr;
95123 *uaddr_len = sizeof(struct sockaddr_ax25);
95124 }
95125 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95126 index 75c8bbf..ee9be59 100644
95127 --- a/net/packet/af_packet.c
95128 +++ b/net/packet/af_packet.c
95129 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95130
95131 spin_lock(&sk->sk_receive_queue.lock);
95132 po->stats.stats1.tp_packets++;
95133 - skb->dropcount = atomic_read(&sk->sk_drops);
95134 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95135 __skb_queue_tail(&sk->sk_receive_queue, skb);
95136 spin_unlock(&sk->sk_receive_queue.lock);
95137 sk->sk_data_ready(sk, skb->len);
95138 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95139 drop_n_acct:
95140 spin_lock(&sk->sk_receive_queue.lock);
95141 po->stats.stats1.tp_drops++;
95142 - atomic_inc(&sk->sk_drops);
95143 + atomic_inc_unchecked(&sk->sk_drops);
95144 spin_unlock(&sk->sk_receive_queue.lock);
95145
95146 drop_n_restore:
95147 @@ -2640,6 +2640,7 @@ out:
95148
95149 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95150 {
95151 + struct sock_extended_err ee;
95152 struct sock_exterr_skb *serr;
95153 struct sk_buff *skb, *skb2;
95154 int copied, err;
95155 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95156 sock_recv_timestamp(msg, sk, skb);
95157
95158 serr = SKB_EXT_ERR(skb);
95159 + ee = serr->ee;
95160 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
95161 - sizeof(serr->ee), &serr->ee);
95162 + sizeof ee, &ee);
95163
95164 msg->msg_flags |= MSG_ERRQUEUE;
95165 err = copied;
95166 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95167 case PACKET_HDRLEN:
95168 if (len > sizeof(int))
95169 len = sizeof(int);
95170 - if (copy_from_user(&val, optval, len))
95171 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
95172 return -EFAULT;
95173 switch (val) {
95174 case TPACKET_V1:
95175 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95176 len = lv;
95177 if (put_user(len, optlen))
95178 return -EFAULT;
95179 - if (copy_to_user(optval, data, len))
95180 + if (len > sizeof(st) || copy_to_user(optval, data, len))
95181 return -EFAULT;
95182 return 0;
95183 }
95184 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
95185 index e774117..900b8b7 100644
95186 --- a/net/phonet/pep.c
95187 +++ b/net/phonet/pep.c
95188 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95189
95190 case PNS_PEP_CTRL_REQ:
95191 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
95192 - atomic_inc(&sk->sk_drops);
95193 + atomic_inc_unchecked(&sk->sk_drops);
95194 break;
95195 }
95196 __skb_pull(skb, 4);
95197 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95198 }
95199
95200 if (pn->rx_credits == 0) {
95201 - atomic_inc(&sk->sk_drops);
95202 + atomic_inc_unchecked(&sk->sk_drops);
95203 err = -ENOBUFS;
95204 break;
95205 }
95206 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
95207 }
95208
95209 if (pn->rx_credits == 0) {
95210 - atomic_inc(&sk->sk_drops);
95211 + atomic_inc_unchecked(&sk->sk_drops);
95212 err = NET_RX_DROP;
95213 break;
95214 }
95215 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
95216 index 1afd138..0b42453 100644
95217 --- a/net/phonet/socket.c
95218 +++ b/net/phonet/socket.c
95219 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
95220 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
95221 sock_i_ino(sk),
95222 atomic_read(&sk->sk_refcnt), sk,
95223 - atomic_read(&sk->sk_drops), &len);
95224 + atomic_read_unchecked(&sk->sk_drops), &len);
95225 }
95226 seq_printf(seq, "%*s\n", 127 - len, "");
95227 return 0;
95228 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
95229 index c02a8c4..3c5b600 100644
95230 --- a/net/phonet/sysctl.c
95231 +++ b/net/phonet/sysctl.c
95232 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
95233 {
95234 int ret;
95235 int range[2] = {local_port_range[0], local_port_range[1]};
95236 - struct ctl_table tmp = {
95237 + ctl_table_no_const tmp = {
95238 .data = &range,
95239 .maxlen = sizeof(range),
95240 .mode = table->mode,
95241 diff --git a/net/rds/cong.c b/net/rds/cong.c
95242 index e5b65ac..f3b6fb7 100644
95243 --- a/net/rds/cong.c
95244 +++ b/net/rds/cong.c
95245 @@ -78,7 +78,7 @@
95246 * finds that the saved generation number is smaller than the global generation
95247 * number, it wakes up the process.
95248 */
95249 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
95250 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
95251
95252 /*
95253 * Congestion monitoring
95254 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
95255 rdsdebug("waking map %p for %pI4\n",
95256 map, &map->m_addr);
95257 rds_stats_inc(s_cong_update_received);
95258 - atomic_inc(&rds_cong_generation);
95259 + atomic_inc_unchecked(&rds_cong_generation);
95260 if (waitqueue_active(&map->m_waitq))
95261 wake_up(&map->m_waitq);
95262 if (waitqueue_active(&rds_poll_waitq))
95263 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
95264
95265 int rds_cong_updated_since(unsigned long *recent)
95266 {
95267 - unsigned long gen = atomic_read(&rds_cong_generation);
95268 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
95269
95270 if (likely(*recent == gen))
95271 return 0;
95272 diff --git a/net/rds/ib.h b/net/rds/ib.h
95273 index 7280ab8..e04f4ea 100644
95274 --- a/net/rds/ib.h
95275 +++ b/net/rds/ib.h
95276 @@ -128,7 +128,7 @@ struct rds_ib_connection {
95277 /* sending acks */
95278 unsigned long i_ack_flags;
95279 #ifdef KERNEL_HAS_ATOMIC64
95280 - atomic64_t i_ack_next; /* next ACK to send */
95281 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95282 #else
95283 spinlock_t i_ack_lock; /* protect i_ack_next */
95284 u64 i_ack_next; /* next ACK to send */
95285 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
95286 index 31b74f5..dc1fbfa 100644
95287 --- a/net/rds/ib_cm.c
95288 +++ b/net/rds/ib_cm.c
95289 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95290 /* Clear the ACK state */
95291 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95292 #ifdef KERNEL_HAS_ATOMIC64
95293 - atomic64_set(&ic->i_ack_next, 0);
95294 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95295 #else
95296 ic->i_ack_next = 0;
95297 #endif
95298 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95299 index 8eb9501..0c386ff 100644
95300 --- a/net/rds/ib_recv.c
95301 +++ b/net/rds/ib_recv.c
95302 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95303 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95304 int ack_required)
95305 {
95306 - atomic64_set(&ic->i_ack_next, seq);
95307 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95308 if (ack_required) {
95309 smp_mb__before_clear_bit();
95310 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95311 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95312 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95313 smp_mb__after_clear_bit();
95314
95315 - return atomic64_read(&ic->i_ack_next);
95316 + return atomic64_read_unchecked(&ic->i_ack_next);
95317 }
95318 #endif
95319
95320 diff --git a/net/rds/iw.h b/net/rds/iw.h
95321 index 04ce3b1..48119a6 100644
95322 --- a/net/rds/iw.h
95323 +++ b/net/rds/iw.h
95324 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95325 /* sending acks */
95326 unsigned long i_ack_flags;
95327 #ifdef KERNEL_HAS_ATOMIC64
95328 - atomic64_t i_ack_next; /* next ACK to send */
95329 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95330 #else
95331 spinlock_t i_ack_lock; /* protect i_ack_next */
95332 u64 i_ack_next; /* next ACK to send */
95333 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95334 index a91e1db..cf3053f 100644
95335 --- a/net/rds/iw_cm.c
95336 +++ b/net/rds/iw_cm.c
95337 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95338 /* Clear the ACK state */
95339 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95340 #ifdef KERNEL_HAS_ATOMIC64
95341 - atomic64_set(&ic->i_ack_next, 0);
95342 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95343 #else
95344 ic->i_ack_next = 0;
95345 #endif
95346 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95347 index 4503335..db566b4 100644
95348 --- a/net/rds/iw_recv.c
95349 +++ b/net/rds/iw_recv.c
95350 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95351 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95352 int ack_required)
95353 {
95354 - atomic64_set(&ic->i_ack_next, seq);
95355 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95356 if (ack_required) {
95357 smp_mb__before_clear_bit();
95358 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95359 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95360 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95361 smp_mb__after_clear_bit();
95362
95363 - return atomic64_read(&ic->i_ack_next);
95364 + return atomic64_read_unchecked(&ic->i_ack_next);
95365 }
95366 #endif
95367
95368 diff --git a/net/rds/rds.h b/net/rds/rds.h
95369 index ec1d731..90a3a8d 100644
95370 --- a/net/rds/rds.h
95371 +++ b/net/rds/rds.h
95372 @@ -449,7 +449,7 @@ struct rds_transport {
95373 void (*sync_mr)(void *trans_private, int direction);
95374 void (*free_mr)(void *trans_private, int invalidate);
95375 void (*flush_mrs)(void);
95376 -};
95377 +} __do_const;
95378
95379 struct rds_sock {
95380 struct sock rs_sk;
95381 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95382 index edac9ef..16bcb98 100644
95383 --- a/net/rds/tcp.c
95384 +++ b/net/rds/tcp.c
95385 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95386 int val = 1;
95387
95388 set_fs(KERNEL_DS);
95389 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95390 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95391 sizeof(val));
95392 set_fs(oldfs);
95393 }
95394 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95395 index 81cf5a4..b5826ff 100644
95396 --- a/net/rds/tcp_send.c
95397 +++ b/net/rds/tcp_send.c
95398 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95399
95400 oldfs = get_fs();
95401 set_fs(KERNEL_DS);
95402 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95403 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95404 sizeof(val));
95405 set_fs(oldfs);
95406 }
95407 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95408 index e61aa60..f07cc89 100644
95409 --- a/net/rxrpc/af_rxrpc.c
95410 +++ b/net/rxrpc/af_rxrpc.c
95411 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95412 __be32 rxrpc_epoch;
95413
95414 /* current debugging ID */
95415 -atomic_t rxrpc_debug_id;
95416 +atomic_unchecked_t rxrpc_debug_id;
95417
95418 /* count of skbs currently in use */
95419 atomic_t rxrpc_n_skbs;
95420 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95421 index e4d9cbc..b229649 100644
95422 --- a/net/rxrpc/ar-ack.c
95423 +++ b/net/rxrpc/ar-ack.c
95424 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95425
95426 _enter("{%d,%d,%d,%d},",
95427 call->acks_hard, call->acks_unacked,
95428 - atomic_read(&call->sequence),
95429 + atomic_read_unchecked(&call->sequence),
95430 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95431
95432 stop = 0;
95433 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95434
95435 /* each Tx packet has a new serial number */
95436 sp->hdr.serial =
95437 - htonl(atomic_inc_return(&call->conn->serial));
95438 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95439
95440 hdr = (struct rxrpc_header *) txb->head;
95441 hdr->serial = sp->hdr.serial;
95442 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95443 */
95444 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95445 {
95446 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95447 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95448 }
95449
95450 /*
95451 @@ -629,7 +629,7 @@ process_further:
95452
95453 latest = ntohl(sp->hdr.serial);
95454 hard = ntohl(ack.firstPacket);
95455 - tx = atomic_read(&call->sequence);
95456 + tx = atomic_read_unchecked(&call->sequence);
95457
95458 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95459 latest,
95460 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95461 goto maybe_reschedule;
95462
95463 send_ACK_with_skew:
95464 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95465 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95466 ntohl(ack.serial));
95467 send_ACK:
95468 mtu = call->conn->trans->peer->if_mtu;
95469 @@ -1173,7 +1173,7 @@ send_ACK:
95470 ackinfo.rxMTU = htonl(5692);
95471 ackinfo.jumbo_max = htonl(4);
95472
95473 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95474 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95475 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95476 ntohl(hdr.serial),
95477 ntohs(ack.maxSkew),
95478 @@ -1191,7 +1191,7 @@ send_ACK:
95479 send_message:
95480 _debug("send message");
95481
95482 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95483 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95484 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95485 send_message_2:
95486
95487 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95488 index a3bbb36..3341fb9 100644
95489 --- a/net/rxrpc/ar-call.c
95490 +++ b/net/rxrpc/ar-call.c
95491 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95492 spin_lock_init(&call->lock);
95493 rwlock_init(&call->state_lock);
95494 atomic_set(&call->usage, 1);
95495 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95496 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95497 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95498
95499 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95500 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95501 index 4106ca9..a338d7a 100644
95502 --- a/net/rxrpc/ar-connection.c
95503 +++ b/net/rxrpc/ar-connection.c
95504 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95505 rwlock_init(&conn->lock);
95506 spin_lock_init(&conn->state_lock);
95507 atomic_set(&conn->usage, 1);
95508 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95509 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95510 conn->avail_calls = RXRPC_MAXCALLS;
95511 conn->size_align = 4;
95512 conn->header_size = sizeof(struct rxrpc_header);
95513 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95514 index e7ed43a..6afa140 100644
95515 --- a/net/rxrpc/ar-connevent.c
95516 +++ b/net/rxrpc/ar-connevent.c
95517 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95518
95519 len = iov[0].iov_len + iov[1].iov_len;
95520
95521 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95522 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95523 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95524
95525 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95526 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95527 index 529572f..c758ca7 100644
95528 --- a/net/rxrpc/ar-input.c
95529 +++ b/net/rxrpc/ar-input.c
95530 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95531 /* track the latest serial number on this connection for ACK packet
95532 * information */
95533 serial = ntohl(sp->hdr.serial);
95534 - hi_serial = atomic_read(&call->conn->hi_serial);
95535 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95536 while (serial > hi_serial)
95537 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95538 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95539 serial);
95540
95541 /* request ACK generation for any ACK or DATA packet that requests
95542 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95543 index a693aca..81e7293 100644
95544 --- a/net/rxrpc/ar-internal.h
95545 +++ b/net/rxrpc/ar-internal.h
95546 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95547 int error; /* error code for local abort */
95548 int debug_id; /* debug ID for printks */
95549 unsigned int call_counter; /* call ID counter */
95550 - atomic_t serial; /* packet serial number counter */
95551 - atomic_t hi_serial; /* highest serial number received */
95552 + atomic_unchecked_t serial; /* packet serial number counter */
95553 + atomic_unchecked_t hi_serial; /* highest serial number received */
95554 u8 avail_calls; /* number of calls available */
95555 u8 size_align; /* data size alignment (for security) */
95556 u8 header_size; /* rxrpc + security header size */
95557 @@ -346,7 +346,7 @@ struct rxrpc_call {
95558 spinlock_t lock;
95559 rwlock_t state_lock; /* lock for state transition */
95560 atomic_t usage;
95561 - atomic_t sequence; /* Tx data packet sequence counter */
95562 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95563 u32 abort_code; /* local/remote abort code */
95564 enum { /* current state of call */
95565 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95566 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95567 */
95568 extern atomic_t rxrpc_n_skbs;
95569 extern __be32 rxrpc_epoch;
95570 -extern atomic_t rxrpc_debug_id;
95571 +extern atomic_unchecked_t rxrpc_debug_id;
95572 extern struct workqueue_struct *rxrpc_workqueue;
95573
95574 /*
95575 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95576 index 87f7135..74d3703 100644
95577 --- a/net/rxrpc/ar-local.c
95578 +++ b/net/rxrpc/ar-local.c
95579 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95580 spin_lock_init(&local->lock);
95581 rwlock_init(&local->services_lock);
95582 atomic_set(&local->usage, 1);
95583 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95584 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95585 memcpy(&local->srx, srx, sizeof(*srx));
95586 }
95587
95588 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95589 index e1ac183..b43e10e 100644
95590 --- a/net/rxrpc/ar-output.c
95591 +++ b/net/rxrpc/ar-output.c
95592 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95593 sp->hdr.cid = call->cid;
95594 sp->hdr.callNumber = call->call_id;
95595 sp->hdr.seq =
95596 - htonl(atomic_inc_return(&call->sequence));
95597 + htonl(atomic_inc_return_unchecked(&call->sequence));
95598 sp->hdr.serial =
95599 - htonl(atomic_inc_return(&conn->serial));
95600 + htonl(atomic_inc_return_unchecked(&conn->serial));
95601 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95602 sp->hdr.userStatus = 0;
95603 sp->hdr.securityIndex = conn->security_ix;
95604 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95605 index bebaa43..2644591 100644
95606 --- a/net/rxrpc/ar-peer.c
95607 +++ b/net/rxrpc/ar-peer.c
95608 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95609 INIT_LIST_HEAD(&peer->error_targets);
95610 spin_lock_init(&peer->lock);
95611 atomic_set(&peer->usage, 1);
95612 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95613 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95614 memcpy(&peer->srx, srx, sizeof(*srx));
95615
95616 rxrpc_assess_MTU_size(peer);
95617 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95618 index 38047f7..9f48511 100644
95619 --- a/net/rxrpc/ar-proc.c
95620 +++ b/net/rxrpc/ar-proc.c
95621 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95622 atomic_read(&conn->usage),
95623 rxrpc_conn_states[conn->state],
95624 key_serial(conn->key),
95625 - atomic_read(&conn->serial),
95626 - atomic_read(&conn->hi_serial));
95627 + atomic_read_unchecked(&conn->serial),
95628 + atomic_read_unchecked(&conn->hi_serial));
95629
95630 return 0;
95631 }
95632 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95633 index 92df566..87ec1bf 100644
95634 --- a/net/rxrpc/ar-transport.c
95635 +++ b/net/rxrpc/ar-transport.c
95636 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95637 spin_lock_init(&trans->client_lock);
95638 rwlock_init(&trans->conn_lock);
95639 atomic_set(&trans->usage, 1);
95640 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95641 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95642
95643 if (peer->srx.transport.family == AF_INET) {
95644 switch (peer->srx.transport_type) {
95645 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95646 index f226709..0e735a8 100644
95647 --- a/net/rxrpc/rxkad.c
95648 +++ b/net/rxrpc/rxkad.c
95649 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95650
95651 len = iov[0].iov_len + iov[1].iov_len;
95652
95653 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95654 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95655 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95656
95657 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95658 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95659
95660 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95661
95662 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95663 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95664 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95665
95666 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95667 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95668 index 547a461e..ea606e3 100644
95669 --- a/net/sctp/ipv6.c
95670 +++ b/net/sctp/ipv6.c
95671 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95672 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95673 };
95674
95675 -static struct sctp_af sctp_af_inet6 = {
95676 +static struct sctp_af sctp_af_inet6 __read_only = {
95677 .sa_family = AF_INET6,
95678 .sctp_xmit = sctp_v6_xmit,
95679 .setsockopt = ipv6_setsockopt,
95680 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95681 #endif
95682 };
95683
95684 -static struct sctp_pf sctp_pf_inet6 = {
95685 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95686 .event_msgname = sctp_inet6_event_msgname,
95687 .skb_msgname = sctp_inet6_skb_msgname,
95688 .af_supported = sctp_inet6_af_supported,
95689 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95690
95691 void sctp_v6_pf_exit(void)
95692 {
95693 - list_del(&sctp_af_inet6.list);
95694 + pax_list_del(&sctp_af_inet6.list);
95695 }
95696
95697 /* Initialize IPv6 support and register with socket layer. */
95698 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95699 index 62526c4..36a13c5 100644
95700 --- a/net/sctp/proc.c
95701 +++ b/net/sctp/proc.c
95702 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95703 seq_printf(seq,
95704 "%8pK %8pK %-3d %-3d %-2d %-4d "
95705 "%4d %8d %8d %7d %5lu %-5d %5d ",
95706 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95707 + assoc, sk,
95708 + sctp_sk(sk)->type, sk->sk_state,
95709 assoc->state, hash,
95710 assoc->assoc_id,
95711 assoc->sndbuf_used,
95712 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95713 index 4a17494d..f7e3fa0 100644
95714 --- a/net/sctp/protocol.c
95715 +++ b/net/sctp/protocol.c
95716 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95717 return 0;
95718 }
95719
95720 + pax_open_kernel();
95721 INIT_LIST_HEAD(&af->list);
95722 - list_add_tail(&af->list, &sctp_address_families);
95723 + pax_close_kernel();
95724 + pax_list_add_tail(&af->list, &sctp_address_families);
95725 return 1;
95726 }
95727
95728 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95729
95730 static struct sctp_af sctp_af_inet;
95731
95732 -static struct sctp_pf sctp_pf_inet = {
95733 +static struct sctp_pf sctp_pf_inet __read_only = {
95734 .event_msgname = sctp_inet_event_msgname,
95735 .skb_msgname = sctp_inet_skb_msgname,
95736 .af_supported = sctp_inet_af_supported,
95737 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95738 };
95739
95740 /* IPv4 address related functions. */
95741 -static struct sctp_af sctp_af_inet = {
95742 +static struct sctp_af sctp_af_inet __read_only = {
95743 .sa_family = AF_INET,
95744 .sctp_xmit = sctp_v4_xmit,
95745 .setsockopt = ip_setsockopt,
95746 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95747
95748 static void sctp_v4_pf_exit(void)
95749 {
95750 - list_del(&sctp_af_inet.list);
95751 + pax_list_del(&sctp_af_inet.list);
95752 }
95753
95754 static int sctp_v4_protosw_init(void)
95755 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95756 index 9da6885..7571898 100644
95757 --- a/net/sctp/sm_sideeffect.c
95758 +++ b/net/sctp/sm_sideeffect.c
95759 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95760 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95761 }
95762
95763 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95764 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95765 NULL,
95766 sctp_generate_t1_cookie_event,
95767 sctp_generate_t1_init_event,
95768 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95769 index cf6c6b0..b978b65 100644
95770 --- a/net/sctp/socket.c
95771 +++ b/net/sctp/socket.c
95772 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95773 {
95774 struct sctp_association *asoc;
95775 struct sctp_ulpevent *event;
95776 + struct sctp_event_subscribe subscribe;
95777
95778 if (optlen > sizeof(struct sctp_event_subscribe))
95779 return -EINVAL;
95780 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95781 + if (copy_from_user(&subscribe, optval, optlen))
95782 return -EFAULT;
95783 + sctp_sk(sk)->subscribe = subscribe;
95784
95785 /*
95786 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95787 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95788 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95789 int __user *optlen)
95790 {
95791 + struct sctp_event_subscribe subscribe;
95792 +
95793 if (len <= 0)
95794 return -EINVAL;
95795 if (len > sizeof(struct sctp_event_subscribe))
95796 len = sizeof(struct sctp_event_subscribe);
95797 if (put_user(len, optlen))
95798 return -EFAULT;
95799 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95800 + subscribe = sctp_sk(sk)->subscribe;
95801 + if (copy_to_user(optval, &subscribe, len))
95802 return -EFAULT;
95803 return 0;
95804 }
95805 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95806 */
95807 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95808 {
95809 + __u32 autoclose;
95810 +
95811 /* Applicable to UDP-style socket only */
95812 if (sctp_style(sk, TCP))
95813 return -EOPNOTSUPP;
95814 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95815 len = sizeof(int);
95816 if (put_user(len, optlen))
95817 return -EFAULT;
95818 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95819 + autoclose = sctp_sk(sk)->autoclose;
95820 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95821 return -EFAULT;
95822 return 0;
95823 }
95824 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95825 */
95826 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95827 {
95828 + struct sctp_initmsg initmsg;
95829 +
95830 if (len < sizeof(struct sctp_initmsg))
95831 return -EINVAL;
95832 len = sizeof(struct sctp_initmsg);
95833 if (put_user(len, optlen))
95834 return -EFAULT;
95835 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95836 + initmsg = sctp_sk(sk)->initmsg;
95837 + if (copy_to_user(optval, &initmsg, len))
95838 return -EFAULT;
95839 return 0;
95840 }
95841 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95842 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95843 if (space_left < addrlen)
95844 return -ENOMEM;
95845 + if (addrlen > sizeof(temp) || addrlen < 0)
95846 + return -EFAULT;
95847 if (copy_to_user(to, &temp, addrlen))
95848 return -EFAULT;
95849 to += addrlen;
95850 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95851 index 9a5c4c9..46e4b29 100644
95852 --- a/net/sctp/sysctl.c
95853 +++ b/net/sctp/sysctl.c
95854 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95855 {
95856 struct net *net = current->nsproxy->net_ns;
95857 char tmp[8];
95858 - struct ctl_table tbl;
95859 + ctl_table_no_const tbl;
95860 int ret;
95861 int changed = 0;
95862 char *none = "none";
95863 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95864
95865 int sctp_sysctl_net_register(struct net *net)
95866 {
95867 - struct ctl_table *table;
95868 + ctl_table_no_const *table;
95869 int i;
95870
95871 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95872 diff --git a/net/socket.c b/net/socket.c
95873 index b2d7c62..f703b02 100644
95874 --- a/net/socket.c
95875 +++ b/net/socket.c
95876 @@ -88,6 +88,7 @@
95877 #include <linux/magic.h>
95878 #include <linux/slab.h>
95879 #include <linux/xattr.h>
95880 +#include <linux/in.h>
95881
95882 #include <asm/uaccess.h>
95883 #include <asm/unistd.h>
95884 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95885 unsigned int sysctl_net_busy_poll __read_mostly;
95886 #endif
95887
95888 +#include <linux/grsock.h>
95889 +
95890 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95891 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95892 unsigned long nr_segs, loff_t pos);
95893 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
95894 */
95895
95896 static DEFINE_SPINLOCK(net_family_lock);
95897 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95898 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95899
95900 /*
95901 * Statistics counters of the socket lists
95902 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95903 &sockfs_dentry_operations, SOCKFS_MAGIC);
95904 }
95905
95906 -static struct vfsmount *sock_mnt __read_mostly;
95907 +struct vfsmount *sock_mnt __read_mostly;
95908
95909 static struct file_system_type sock_fs_type = {
95910 .name = "sockfs",
95911 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95912 return -EAFNOSUPPORT;
95913 if (type < 0 || type >= SOCK_MAX)
95914 return -EINVAL;
95915 + if (protocol < 0)
95916 + return -EINVAL;
95917
95918 /* Compatibility.
95919
95920 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95921 if (err)
95922 return err;
95923
95924 + if(!kern && !gr_search_socket(family, type, protocol)) {
95925 + if (rcu_access_pointer(net_families[family]) == NULL)
95926 + return -EAFNOSUPPORT;
95927 + else
95928 + return -EACCES;
95929 + }
95930 +
95931 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
95932 + if (rcu_access_pointer(net_families[family]) == NULL)
95933 + return -EAFNOSUPPORT;
95934 + else
95935 + return -EACCES;
95936 + }
95937 +
95938 /*
95939 * Allocate the socket and allow the family to set things up. if
95940 * the protocol is 0, the family is instructed to select an appropriate
95941 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95942 if (sock) {
95943 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95944 if (err >= 0) {
95945 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95946 + err = -EACCES;
95947 + goto error;
95948 + }
95949 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95950 + if (err)
95951 + goto error;
95952 +
95953 err = security_socket_bind(sock,
95954 (struct sockaddr *)&address,
95955 addrlen);
95956 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95957 (struct sockaddr *)
95958 &address, addrlen);
95959 }
95960 +error:
95961 fput_light(sock->file, fput_needed);
95962 }
95963 return err;
95964 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95965 if ((unsigned int)backlog > somaxconn)
95966 backlog = somaxconn;
95967
95968 + if (gr_handle_sock_server_other(sock->sk)) {
95969 + err = -EPERM;
95970 + goto error;
95971 + }
95972 +
95973 + err = gr_search_listen(sock);
95974 + if (err)
95975 + goto error;
95976 +
95977 err = security_socket_listen(sock, backlog);
95978 if (!err)
95979 err = sock->ops->listen(sock, backlog);
95980
95981 +error:
95982 fput_light(sock->file, fput_needed);
95983 }
95984 return err;
95985 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95986 newsock->type = sock->type;
95987 newsock->ops = sock->ops;
95988
95989 + if (gr_handle_sock_server_other(sock->sk)) {
95990 + err = -EPERM;
95991 + sock_release(newsock);
95992 + goto out_put;
95993 + }
95994 +
95995 + err = gr_search_accept(sock);
95996 + if (err) {
95997 + sock_release(newsock);
95998 + goto out_put;
95999 + }
96000 +
96001 /*
96002 * We don't need try_module_get here, as the listening socket (sock)
96003 * has the protocol module (sock->ops->owner) held.
96004 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96005 fd_install(newfd, newfile);
96006 err = newfd;
96007
96008 + gr_attach_curr_ip(newsock->sk);
96009 +
96010 out_put:
96011 fput_light(sock->file, fput_needed);
96012 out:
96013 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96014 int, addrlen)
96015 {
96016 struct socket *sock;
96017 + struct sockaddr *sck;
96018 struct sockaddr_storage address;
96019 int err, fput_needed;
96020
96021 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96022 if (err < 0)
96023 goto out_put;
96024
96025 + sck = (struct sockaddr *)&address;
96026 +
96027 + if (gr_handle_sock_client(sck)) {
96028 + err = -EACCES;
96029 + goto out_put;
96030 + }
96031 +
96032 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96033 + if (err)
96034 + goto out_put;
96035 +
96036 err =
96037 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96038 if (err)
96039 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96040 * the protocol.
96041 */
96042
96043 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96044 +
96045 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96046 unsigned int, flags, struct sockaddr __user *, addr,
96047 int, addr_len)
96048 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96049 struct socket *sock;
96050 struct iovec iov;
96051 struct msghdr msg;
96052 - struct sockaddr_storage address;
96053 + struct sockaddr_storage address = { };
96054 int err, err2;
96055 int fput_needed;
96056
96057 @@ -1973,6 +2039,16 @@ struct used_address {
96058 unsigned int name_len;
96059 };
96060
96061 +static int copy_msghdr_from_user(struct msghdr *kmsg,
96062 + struct msghdr __user *umsg)
96063 +{
96064 + if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
96065 + return -EFAULT;
96066 + if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
96067 + return -EINVAL;
96068 + return 0;
96069 +}
96070 +
96071 static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96072 struct msghdr *msg_sys, unsigned int flags,
96073 struct used_address *used_address)
96074 @@ -1991,8 +2067,11 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96075 if (MSG_CMSG_COMPAT & flags) {
96076 if (get_compat_msghdr(msg_sys, msg_compat))
96077 return -EFAULT;
96078 - } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
96079 - return -EFAULT;
96080 + } else {
96081 + err = copy_msghdr_from_user(msg_sys, msg);
96082 + if (err)
96083 + return err;
96084 + }
96085
96086 if (msg_sys->msg_iovlen > UIO_FASTIOV) {
96087 err = -EMSGSIZE;
96088 @@ -2040,7 +2119,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96089 * checking falls down on this.
96090 */
96091 if (copy_from_user(ctl_buf,
96092 - (void __user __force *)msg_sys->msg_control,
96093 + (void __force_user *)msg_sys->msg_control,
96094 ctl_len))
96095 goto out_freectl;
96096 msg_sys->msg_control = ctl_buf;
96097 @@ -2191,7 +2270,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96098 int err, total_len, len;
96099
96100 /* kernel mode address */
96101 - struct sockaddr_storage addr;
96102 + struct sockaddr_storage addr = { };
96103
96104 /* user mode address pointers */
96105 struct sockaddr __user *uaddr;
96106 @@ -2200,8 +2279,11 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96107 if (MSG_CMSG_COMPAT & flags) {
96108 if (get_compat_msghdr(msg_sys, msg_compat))
96109 return -EFAULT;
96110 - } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
96111 - return -EFAULT;
96112 + } else {
96113 + err = copy_msghdr_from_user(msg_sys, msg);
96114 + if (err)
96115 + return err;
96116 + }
96117
96118 if (msg_sys->msg_iovlen > UIO_FASTIOV) {
96119 err = -EMSGSIZE;
96120 @@ -2219,7 +2301,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96121 * kernel msghdr to use the kernel address space)
96122 */
96123
96124 - uaddr = (__force void __user *)msg_sys->msg_name;
96125 + uaddr = (void __force_user *)msg_sys->msg_name;
96126 uaddr_len = COMPAT_NAMELEN(msg);
96127 if (MSG_CMSG_COMPAT & flags) {
96128 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96129 @@ -2974,7 +3056,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96130 old_fs = get_fs();
96131 set_fs(KERNEL_DS);
96132 err = dev_ioctl(net, cmd,
96133 - (struct ifreq __user __force *) &kifr);
96134 + (struct ifreq __force_user *) &kifr);
96135 set_fs(old_fs);
96136
96137 return err;
96138 @@ -3083,7 +3165,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96139
96140 old_fs = get_fs();
96141 set_fs(KERNEL_DS);
96142 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96143 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96144 set_fs(old_fs);
96145
96146 if (cmd == SIOCGIFMAP && !err) {
96147 @@ -3188,7 +3270,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96148 ret |= __get_user(rtdev, &(ur4->rt_dev));
96149 if (rtdev) {
96150 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96151 - r4.rt_dev = (char __user __force *)devname;
96152 + r4.rt_dev = (char __force_user *)devname;
96153 devname[15] = 0;
96154 } else
96155 r4.rt_dev = NULL;
96156 @@ -3414,8 +3496,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96157 int __user *uoptlen;
96158 int err;
96159
96160 - uoptval = (char __user __force *) optval;
96161 - uoptlen = (int __user __force *) optlen;
96162 + uoptval = (char __force_user *) optval;
96163 + uoptlen = (int __force_user *) optlen;
96164
96165 set_fs(KERNEL_DS);
96166 if (level == SOL_SOCKET)
96167 @@ -3435,7 +3517,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96168 char __user *uoptval;
96169 int err;
96170
96171 - uoptval = (char __user __force *) optval;
96172 + uoptval = (char __force_user *) optval;
96173
96174 set_fs(KERNEL_DS);
96175 if (level == SOL_SOCKET)
96176 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96177 index 09fb638..2e6a5c5 100644
96178 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96179 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96180 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96181 uint64_t *handle)
96182 {
96183 struct rsc rsci, *rscp = NULL;
96184 - static atomic64_t ctxhctr;
96185 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96186 long long ctxh;
96187 struct gss_api_mech *gm = NULL;
96188 time_t expiry;
96189 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96190 status = -ENOMEM;
96191 /* the handle needs to be just a unique id,
96192 * use a static counter */
96193 - ctxh = atomic64_inc_return(&ctxhctr);
96194 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96195
96196 /* make a copy for the caller */
96197 *handle = ctxh;
96198 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96199 index ecbc4e3..ad25df8 100644
96200 --- a/net/sunrpc/clnt.c
96201 +++ b/net/sunrpc/clnt.c
96202 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
96203 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96204
96205 /* Increment call count */
96206 - task->tk_msg.rpc_proc->p_count++;
96207 + pax_open_kernel();
96208 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96209 + pax_close_kernel();
96210 clnt->cl_stats->rpccnt++;
96211 task->tk_action = call_reserve;
96212 }
96213 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96214 index 93a7a4e..3b98b9f 100644
96215 --- a/net/sunrpc/sched.c
96216 +++ b/net/sunrpc/sched.c
96217 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96218 #ifdef RPC_DEBUG
96219 static void rpc_task_set_debuginfo(struct rpc_task *task)
96220 {
96221 - static atomic_t rpc_pid;
96222 + static atomic_unchecked_t rpc_pid;
96223
96224 - task->tk_pid = atomic_inc_return(&rpc_pid);
96225 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96226 }
96227 #else
96228 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
96229 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
96230 index b974571..678ed90 100644
96231 --- a/net/sunrpc/svc.c
96232 +++ b/net/sunrpc/svc.c
96233 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
96234 svc_putnl(resv, RPC_SUCCESS);
96235
96236 /* Bump per-procedure stats counter */
96237 - procp->pc_count++;
96238 + pax_open_kernel();
96239 + (*(unsigned int *)&procp->pc_count)++;
96240 + pax_close_kernel();
96241
96242 /* Initialize storage for argp and resp */
96243 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96244 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96245 index c1b6270..05089c1 100644
96246 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96247 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96248 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96249 static unsigned int min_max_inline = 4096;
96250 static unsigned int max_max_inline = 65536;
96251
96252 -atomic_t rdma_stat_recv;
96253 -atomic_t rdma_stat_read;
96254 -atomic_t rdma_stat_write;
96255 -atomic_t rdma_stat_sq_starve;
96256 -atomic_t rdma_stat_rq_starve;
96257 -atomic_t rdma_stat_rq_poll;
96258 -atomic_t rdma_stat_rq_prod;
96259 -atomic_t rdma_stat_sq_poll;
96260 -atomic_t rdma_stat_sq_prod;
96261 +atomic_unchecked_t rdma_stat_recv;
96262 +atomic_unchecked_t rdma_stat_read;
96263 +atomic_unchecked_t rdma_stat_write;
96264 +atomic_unchecked_t rdma_stat_sq_starve;
96265 +atomic_unchecked_t rdma_stat_rq_starve;
96266 +atomic_unchecked_t rdma_stat_rq_poll;
96267 +atomic_unchecked_t rdma_stat_rq_prod;
96268 +atomic_unchecked_t rdma_stat_sq_poll;
96269 +atomic_unchecked_t rdma_stat_sq_prod;
96270
96271 /* Temporary NFS request map and context caches */
96272 struct kmem_cache *svc_rdma_map_cachep;
96273 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96274 len -= *ppos;
96275 if (len > *lenp)
96276 len = *lenp;
96277 - if (len && copy_to_user(buffer, str_buf, len))
96278 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96279 return -EFAULT;
96280 *lenp = len;
96281 *ppos += len;
96282 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96283 {
96284 .procname = "rdma_stat_read",
96285 .data = &rdma_stat_read,
96286 - .maxlen = sizeof(atomic_t),
96287 + .maxlen = sizeof(atomic_unchecked_t),
96288 .mode = 0644,
96289 .proc_handler = read_reset_stat,
96290 },
96291 {
96292 .procname = "rdma_stat_recv",
96293 .data = &rdma_stat_recv,
96294 - .maxlen = sizeof(atomic_t),
96295 + .maxlen = sizeof(atomic_unchecked_t),
96296 .mode = 0644,
96297 .proc_handler = read_reset_stat,
96298 },
96299 {
96300 .procname = "rdma_stat_write",
96301 .data = &rdma_stat_write,
96302 - .maxlen = sizeof(atomic_t),
96303 + .maxlen = sizeof(atomic_unchecked_t),
96304 .mode = 0644,
96305 .proc_handler = read_reset_stat,
96306 },
96307 {
96308 .procname = "rdma_stat_sq_starve",
96309 .data = &rdma_stat_sq_starve,
96310 - .maxlen = sizeof(atomic_t),
96311 + .maxlen = sizeof(atomic_unchecked_t),
96312 .mode = 0644,
96313 .proc_handler = read_reset_stat,
96314 },
96315 {
96316 .procname = "rdma_stat_rq_starve",
96317 .data = &rdma_stat_rq_starve,
96318 - .maxlen = sizeof(atomic_t),
96319 + .maxlen = sizeof(atomic_unchecked_t),
96320 .mode = 0644,
96321 .proc_handler = read_reset_stat,
96322 },
96323 {
96324 .procname = "rdma_stat_rq_poll",
96325 .data = &rdma_stat_rq_poll,
96326 - .maxlen = sizeof(atomic_t),
96327 + .maxlen = sizeof(atomic_unchecked_t),
96328 .mode = 0644,
96329 .proc_handler = read_reset_stat,
96330 },
96331 {
96332 .procname = "rdma_stat_rq_prod",
96333 .data = &rdma_stat_rq_prod,
96334 - .maxlen = sizeof(atomic_t),
96335 + .maxlen = sizeof(atomic_unchecked_t),
96336 .mode = 0644,
96337 .proc_handler = read_reset_stat,
96338 },
96339 {
96340 .procname = "rdma_stat_sq_poll",
96341 .data = &rdma_stat_sq_poll,
96342 - .maxlen = sizeof(atomic_t),
96343 + .maxlen = sizeof(atomic_unchecked_t),
96344 .mode = 0644,
96345 .proc_handler = read_reset_stat,
96346 },
96347 {
96348 .procname = "rdma_stat_sq_prod",
96349 .data = &rdma_stat_sq_prod,
96350 - .maxlen = sizeof(atomic_t),
96351 + .maxlen = sizeof(atomic_unchecked_t),
96352 .mode = 0644,
96353 .proc_handler = read_reset_stat,
96354 },
96355 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96356 index 0ce7552..d074459 100644
96357 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96358 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96359 @@ -501,7 +501,7 @@ next_sge:
96360 svc_rdma_put_context(ctxt, 0);
96361 goto out;
96362 }
96363 - atomic_inc(&rdma_stat_read);
96364 + atomic_inc_unchecked(&rdma_stat_read);
96365
96366 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96367 chl_map->ch[ch_no].count -= read_wr.num_sge;
96368 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96369 dto_q);
96370 list_del_init(&ctxt->dto_q);
96371 } else {
96372 - atomic_inc(&rdma_stat_rq_starve);
96373 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96374 clear_bit(XPT_DATA, &xprt->xpt_flags);
96375 ctxt = NULL;
96376 }
96377 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96378 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96379 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96380 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96381 - atomic_inc(&rdma_stat_recv);
96382 + atomic_inc_unchecked(&rdma_stat_recv);
96383
96384 /* Build up the XDR from the receive buffers. */
96385 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96386 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96387 index c1d124d..acfc59e 100644
96388 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96389 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96390 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96391 write_wr.wr.rdma.remote_addr = to;
96392
96393 /* Post It */
96394 - atomic_inc(&rdma_stat_write);
96395 + atomic_inc_unchecked(&rdma_stat_write);
96396 if (svc_rdma_send(xprt, &write_wr))
96397 goto err;
96398 return 0;
96399 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96400 index 62e4f9b..dd3f2d7 100644
96401 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96402 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96403 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96404 return;
96405
96406 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96407 - atomic_inc(&rdma_stat_rq_poll);
96408 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96409
96410 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96411 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96412 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96413 }
96414
96415 if (ctxt)
96416 - atomic_inc(&rdma_stat_rq_prod);
96417 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96418
96419 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96420 /*
96421 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96422 return;
96423
96424 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96425 - atomic_inc(&rdma_stat_sq_poll);
96426 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96427 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96428 if (wc.status != IB_WC_SUCCESS)
96429 /* Close the transport */
96430 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96431 }
96432
96433 if (ctxt)
96434 - atomic_inc(&rdma_stat_sq_prod);
96435 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96436 }
96437
96438 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96439 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96440 spin_lock_bh(&xprt->sc_lock);
96441 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96442 spin_unlock_bh(&xprt->sc_lock);
96443 - atomic_inc(&rdma_stat_sq_starve);
96444 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96445
96446 /* See if we can opportunistically reap SQ WR to make room */
96447 sq_cq_reap(xprt);
96448 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96449 index e7000be..e3b0ba7 100644
96450 --- a/net/sysctl_net.c
96451 +++ b/net/sysctl_net.c
96452 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96453 kgid_t root_gid = make_kgid(net->user_ns, 0);
96454
96455 /* Allow network administrator to have same access as root. */
96456 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96457 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96458 uid_eq(root_uid, current_euid())) {
96459 int mode = (table->mode >> 6) & 7;
96460 return (mode << 6) | (mode << 3) | mode;
96461 diff --git a/net/tipc/link.c b/net/tipc/link.c
96462 index 0cc3d90..cc42021 100644
96463 --- a/net/tipc/link.c
96464 +++ b/net/tipc/link.c
96465 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96466 struct tipc_msg fragm_hdr;
96467 struct sk_buff *buf, *buf_chain, *prev;
96468 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96469 - const unchar *sect_crs;
96470 + const unchar __user *sect_crs;
96471 int curr_sect;
96472 u32 fragm_no;
96473 int res = 0;
96474 @@ -1207,7 +1207,7 @@ again:
96475
96476 if (!sect_rest) {
96477 sect_rest = msg_sect[++curr_sect].iov_len;
96478 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96479 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96480 }
96481
96482 if (sect_rest < fragm_rest)
96483 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96484 index ced60e2..54eab6c 100644
96485 --- a/net/tipc/msg.c
96486 +++ b/net/tipc/msg.c
96487 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96488 skb_copy_to_linear_data(*buf, hdr, hsz);
96489 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96490 skb_copy_to_linear_data_offset(*buf, pos,
96491 - msg_sect[cnt].iov_base,
96492 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96493 msg_sect[cnt].iov_len);
96494 pos += msg_sect[cnt].iov_len;
96495 }
96496 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96497 index d38bb45..4fd6ac6 100644
96498 --- a/net/tipc/subscr.c
96499 +++ b/net/tipc/subscr.c
96500 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96501 struct kvec msg_sect;
96502 int ret;
96503
96504 - msg_sect.iov_base = (void *)&sub->evt;
96505 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96506 msg_sect.iov_len = sizeof(struct tipc_event);
96507
96508 sub->evt.event = htohl(event, sub->swap);
96509 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96510 index c4ce243..2be7c59 100644
96511 --- a/net/unix/af_unix.c
96512 +++ b/net/unix/af_unix.c
96513 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96514 err = -ECONNREFUSED;
96515 if (!S_ISSOCK(inode->i_mode))
96516 goto put_fail;
96517 +
96518 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96519 + err = -EACCES;
96520 + goto put_fail;
96521 + }
96522 +
96523 u = unix_find_socket_byinode(inode);
96524 if (!u)
96525 goto put_fail;
96526 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96527 if (u) {
96528 struct dentry *dentry;
96529 dentry = unix_sk(u)->path.dentry;
96530 +
96531 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96532 + err = -EPERM;
96533 + sock_put(u);
96534 + goto fail;
96535 + }
96536 +
96537 if (dentry)
96538 touch_atime(&unix_sk(u)->path);
96539 } else
96540 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96541 */
96542 err = security_path_mknod(&path, dentry, mode, 0);
96543 if (!err) {
96544 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96545 + err = -EACCES;
96546 + goto out;
96547 + }
96548 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96549 if (!err) {
96550 res->mnt = mntget(path.mnt);
96551 res->dentry = dget(dentry);
96552 + gr_handle_create(dentry, path.mnt);
96553 }
96554 }
96555 +out:
96556 done_path_create(&path, dentry);
96557 return err;
96558 }
96559 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96560 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96561 "Inode Path\n");
96562 else {
96563 - struct sock *s = v;
96564 + struct sock *s = v, *peer;
96565 struct unix_sock *u = unix_sk(s);
96566 unix_state_lock(s);
96567 + peer = unix_peer(s);
96568 + unix_state_unlock(s);
96569 +
96570 + unix_state_double_lock(s, peer);
96571
96572 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96573 s,
96574 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96575 }
96576 for ( ; i < len; i++)
96577 seq_putc(seq, u->addr->name->sun_path[i]);
96578 - }
96579 - unix_state_unlock(s);
96580 + } else if (peer)
96581 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96582 +
96583 + unix_state_double_unlock(s, peer);
96584 seq_putc(seq, '\n');
96585 }
96586
96587 diff --git a/net/unix/diag.c b/net/unix/diag.c
96588 index d591091..86fa0f3 100644
96589 --- a/net/unix/diag.c
96590 +++ b/net/unix/diag.c
96591 @@ -124,6 +124,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
96592 rep->udiag_family = AF_UNIX;
96593 rep->udiag_type = sk->sk_type;
96594 rep->udiag_state = sk->sk_state;
96595 + rep->pad = 0;
96596 rep->udiag_ino = sk_ino;
96597 sock_diag_save_cookie(sk, rep->udiag_cookie);
96598
96599 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96600 index b3d5150..ff3a837 100644
96601 --- a/net/unix/sysctl_net_unix.c
96602 +++ b/net/unix/sysctl_net_unix.c
96603 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96604
96605 int __net_init unix_sysctl_register(struct net *net)
96606 {
96607 - struct ctl_table *table;
96608 + ctl_table_no_const *table;
96609
96610 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96611 if (table == NULL)
96612 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96613 index c8717c1..08539f5 100644
96614 --- a/net/wireless/wext-core.c
96615 +++ b/net/wireless/wext-core.c
96616 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96617 */
96618
96619 /* Support for very large requests */
96620 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96621 - (user_length > descr->max_tokens)) {
96622 + if (user_length > descr->max_tokens) {
96623 /* Allow userspace to GET more than max so
96624 * we can support any size GET requests.
96625 * There is still a limit : -ENOMEM.
96626 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96627 }
96628 }
96629
96630 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96631 - /*
96632 - * If this is a GET, but not NOMAX, it means that the extra
96633 - * data is not bounded by userspace, but by max_tokens. Thus
96634 - * set the length to max_tokens. This matches the extra data
96635 - * allocation.
96636 - * The driver should fill it with the number of tokens it
96637 - * provided, and it may check iwp->length rather than having
96638 - * knowledge of max_tokens. If the driver doesn't change the
96639 - * iwp->length, this ioctl just copies back max_token tokens
96640 - * filled with zeroes. Hopefully the driver isn't claiming
96641 - * them to be valid data.
96642 - */
96643 - iwp->length = descr->max_tokens;
96644 - }
96645 -
96646 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96647
96648 iwp->length += essid_compat;
96649 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96650 index f77c371..b0cb010 100644
96651 --- a/net/xfrm/xfrm_policy.c
96652 +++ b/net/xfrm/xfrm_policy.c
96653 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96654 {
96655 policy->walk.dead = 1;
96656
96657 - atomic_inc(&policy->genid);
96658 + atomic_inc_unchecked(&policy->genid);
96659
96660 - del_timer(&policy->polq.hold_timer);
96661 + if (del_timer(&policy->polq.hold_timer))
96662 + xfrm_pol_put(policy);
96663 xfrm_queue_purge(&policy->polq.hold_queue);
96664
96665 if (del_timer(&policy->timer))
96666 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96667
96668 spin_lock_bh(&pq->hold_queue.lock);
96669 skb_queue_splice_init(&pq->hold_queue, &list);
96670 - del_timer(&pq->hold_timer);
96671 + if (del_timer(&pq->hold_timer))
96672 + xfrm_pol_put(old);
96673 spin_unlock_bh(&pq->hold_queue.lock);
96674
96675 if (skb_queue_empty(&list))
96676 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96677 spin_lock_bh(&pq->hold_queue.lock);
96678 skb_queue_splice(&list, &pq->hold_queue);
96679 pq->timeout = XFRM_QUEUE_TMO_MIN;
96680 - mod_timer(&pq->hold_timer, jiffies);
96681 + if (!mod_timer(&pq->hold_timer, jiffies))
96682 + xfrm_pol_hold(new);
96683 spin_unlock_bh(&pq->hold_queue.lock);
96684 }
96685
96686 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96687 hlist_add_head(&policy->bydst, chain);
96688 xfrm_pol_hold(policy);
96689 net->xfrm.policy_count[dir]++;
96690 - atomic_inc(&flow_cache_genid);
96691 + atomic_inc_unchecked(&flow_cache_genid);
96692 rt_genid_bump(net);
96693 if (delpol) {
96694 xfrm_policy_requeue(delpol, policy);
96695 @@ -1627,7 +1630,7 @@ free_dst:
96696 goto out;
96697 }
96698
96699 -static int inline
96700 +static inline int
96701 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96702 {
96703 if (!*target) {
96704 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96705 return 0;
96706 }
96707
96708 -static int inline
96709 +static inline int
96710 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96711 {
96712 #ifdef CONFIG_XFRM_SUB_POLICY
96713 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96714 #endif
96715 }
96716
96717 -static int inline
96718 +static inline int
96719 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96720 {
96721 #ifdef CONFIG_XFRM_SUB_POLICY
96722 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96723
96724 xdst->num_pols = num_pols;
96725 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96726 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96727 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96728
96729 return xdst;
96730 }
96731 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
96732
96733 spin_lock(&pq->hold_queue.lock);
96734 skb = skb_peek(&pq->hold_queue);
96735 + if (!skb) {
96736 + spin_unlock(&pq->hold_queue.lock);
96737 + goto out;
96738 + }
96739 dst = skb_dst(skb);
96740 sk = skb->sk;
96741 xfrm_decode_session(skb, &fl, dst->ops->family);
96742 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
96743 goto purge_queue;
96744
96745 pq->timeout = pq->timeout << 1;
96746 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
96747 - return;
96748 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
96749 + xfrm_pol_hold(pol);
96750 + goto out;
96751 }
96752
96753 dst_release(dst);
96754 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
96755 err = dst_output(skb);
96756 }
96757
96758 +out:
96759 + xfrm_pol_put(pol);
96760 return;
96761
96762 purge_queue:
96763 pq->timeout = 0;
96764 xfrm_queue_purge(&pq->hold_queue);
96765 + xfrm_pol_put(pol);
96766 }
96767
96768 static int xdst_queue_output(struct sk_buff *skb)
96769 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
96770 unsigned long sched_next;
96771 struct dst_entry *dst = skb_dst(skb);
96772 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
96773 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
96774 + struct xfrm_policy *pol = xdst->pols[0];
96775 + struct xfrm_policy_queue *pq = &pol->polq;
96776
96777 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
96778 kfree_skb(skb);
96779 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
96780 if (del_timer(&pq->hold_timer)) {
96781 if (time_before(pq->hold_timer.expires, sched_next))
96782 sched_next = pq->hold_timer.expires;
96783 + xfrm_pol_put(pol);
96784 }
96785
96786 __skb_queue_tail(&pq->hold_queue, skb);
96787 - mod_timer(&pq->hold_timer, sched_next);
96788 + if (!mod_timer(&pq->hold_timer, sched_next))
96789 + xfrm_pol_hold(pol);
96790
96791 spin_unlock_bh(&pq->hold_queue.lock);
96792
96793 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
96794 }
96795 EXPORT_SYMBOL(xfrm_garbage_collect);
96796
96797 -static void xfrm_garbage_collect_deferred(struct net *net)
96798 +void xfrm_garbage_collect_deferred(struct net *net)
96799 {
96800 flow_cache_flush_deferred();
96801 __xfrm_garbage_collect(net);
96802 }
96803 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96804
96805 static void xfrm_init_pmtu(struct dst_entry *dst)
96806 {
96807 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96808 if (xdst->xfrm_genid != dst->xfrm->genid)
96809 return 0;
96810 if (xdst->num_pols > 0 &&
96811 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96812 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96813 return 0;
96814
96815 mtu = dst_mtu(dst->child);
96816 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96817 dst_ops->link_failure = xfrm_link_failure;
96818 if (likely(dst_ops->neigh_lookup == NULL))
96819 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96820 - if (likely(afinfo->garbage_collect == NULL))
96821 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96822 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96823 }
96824 spin_unlock(&xfrm_policy_afinfo_lock);
96825 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96826 dst_ops->check = NULL;
96827 dst_ops->negative_advice = NULL;
96828 dst_ops->link_failure = NULL;
96829 - afinfo->garbage_collect = NULL;
96830 }
96831 return err;
96832 }
96833 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96834 sizeof(pol->xfrm_vec[i].saddr));
96835 pol->xfrm_vec[i].encap_family = mp->new_family;
96836 /* flush bundles */
96837 - atomic_inc(&pol->genid);
96838 + atomic_inc_unchecked(&pol->genid);
96839 }
96840 }
96841
96842 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
96843 index 8dafe6d3..dab57da 100644
96844 --- a/net/xfrm/xfrm_replay.c
96845 +++ b/net/xfrm/xfrm_replay.c
96846 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
96847
96848 switch (event) {
96849 case XFRM_REPLAY_UPDATE:
96850 - if (x->replay_maxdiff &&
96851 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96852 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
96853 + if (!x->replay_maxdiff ||
96854 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96855 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
96856 if (x->xflags & XFRM_TIME_DEFER)
96857 event = XFRM_REPLAY_TIMEOUT;
96858 else
96859 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
96860 return 0;
96861
96862 diff = x->replay.seq - seq;
96863 - if (diff >= min_t(unsigned int, x->props.replay_window,
96864 - sizeof(x->replay.bitmap) * 8)) {
96865 + if (diff >= x->props.replay_window) {
96866 x->stats.replay_window++;
96867 goto err;
96868 }
96869 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
96870
96871 switch (event) {
96872 case XFRM_REPLAY_UPDATE:
96873 - if (x->replay_maxdiff &&
96874 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96875 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
96876 + if (!x->replay_maxdiff ||
96877 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96878 + (replay_esn->oseq - preplay_esn->oseq
96879 + < x->replay_maxdiff))) {
96880 if (x->xflags & XFRM_TIME_DEFER)
96881 event = XFRM_REPLAY_TIMEOUT;
96882 else
96883 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
96884
96885 switch (event) {
96886 case XFRM_REPLAY_UPDATE:
96887 - if (!x->replay_maxdiff)
96888 - break;
96889 -
96890 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
96891 - seq_diff = replay_esn->seq - preplay_esn->seq;
96892 - else
96893 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
96894 -
96895 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96896 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
96897 - else
96898 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
96899 -
96900 - if (seq_diff < x->replay_maxdiff &&
96901 - oseq_diff < x->replay_maxdiff) {
96902 + if (x->replay_maxdiff) {
96903 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
96904 + seq_diff = replay_esn->seq - preplay_esn->seq;
96905 + else
96906 + seq_diff = ~preplay_esn->seq + replay_esn->seq
96907 + + 1;
96908
96909 - if (x->xflags & XFRM_TIME_DEFER)
96910 - event = XFRM_REPLAY_TIMEOUT;
96911 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
96912 + oseq_diff = replay_esn->oseq
96913 + - preplay_esn->oseq;
96914 else
96915 - return;
96916 + oseq_diff = ~preplay_esn->oseq
96917 + + replay_esn->oseq + 1;
96918 +
96919 + if (seq_diff >= x->replay_maxdiff ||
96920 + oseq_diff >= x->replay_maxdiff)
96921 + break;
96922 }
96923
96924 + if (x->xflags & XFRM_TIME_DEFER)
96925 + event = XFRM_REPLAY_TIMEOUT;
96926 + else
96927 + return;
96928 +
96929 break;
96930
96931 case XFRM_REPLAY_TIMEOUT:
96932 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96933 index 54c0acd..56814bd 100644
96934 --- a/net/xfrm/xfrm_state.c
96935 +++ b/net/xfrm/xfrm_state.c
96936 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96937
96938 if (unlikely(afinfo == NULL))
96939 return -EAFNOSUPPORT;
96940 - typemap = afinfo->type_map;
96941 + typemap = (const struct xfrm_type **)afinfo->type_map;
96942 spin_lock_bh(&xfrm_type_lock);
96943
96944 - if (likely(typemap[type->proto] == NULL))
96945 + if (likely(typemap[type->proto] == NULL)) {
96946 + pax_open_kernel();
96947 typemap[type->proto] = type;
96948 - else
96949 + pax_close_kernel();
96950 + } else
96951 err = -EEXIST;
96952 spin_unlock_bh(&xfrm_type_lock);
96953 xfrm_state_put_afinfo(afinfo);
96954 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96955
96956 if (unlikely(afinfo == NULL))
96957 return -EAFNOSUPPORT;
96958 - typemap = afinfo->type_map;
96959 + typemap = (const struct xfrm_type **)afinfo->type_map;
96960 spin_lock_bh(&xfrm_type_lock);
96961
96962 if (unlikely(typemap[type->proto] != type))
96963 err = -ENOENT;
96964 - else
96965 + else {
96966 + pax_open_kernel();
96967 typemap[type->proto] = NULL;
96968 + pax_close_kernel();
96969 + }
96970 spin_unlock_bh(&xfrm_type_lock);
96971 xfrm_state_put_afinfo(afinfo);
96972 return err;
96973 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
96974 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
96975 {
96976 struct xfrm_state_afinfo *afinfo;
96977 - const struct xfrm_type **typemap;
96978 const struct xfrm_type *type;
96979 int modload_attempted = 0;
96980
96981 @@ -219,9 +223,8 @@ retry:
96982 afinfo = xfrm_state_get_afinfo(family);
96983 if (unlikely(afinfo == NULL))
96984 return NULL;
96985 - typemap = afinfo->type_map;
96986
96987 - type = typemap[proto];
96988 + type = afinfo->type_map[proto];
96989 if (unlikely(type && !try_module_get(type->owner)))
96990 type = NULL;
96991 if (!type && !modload_attempted) {
96992 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96993 return -EAFNOSUPPORT;
96994
96995 err = -EEXIST;
96996 - modemap = afinfo->mode_map;
96997 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96998 spin_lock_bh(&xfrm_mode_lock);
96999 if (modemap[mode->encap])
97000 goto out;
97001 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97002 if (!try_module_get(afinfo->owner))
97003 goto out;
97004
97005 - mode->afinfo = afinfo;
97006 + pax_open_kernel();
97007 + *(const void **)&mode->afinfo = afinfo;
97008 modemap[mode->encap] = mode;
97009 + pax_close_kernel();
97010 err = 0;
97011
97012 out:
97013 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97014 return -EAFNOSUPPORT;
97015
97016 err = -ENOENT;
97017 - modemap = afinfo->mode_map;
97018 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97019 spin_lock_bh(&xfrm_mode_lock);
97020 if (likely(modemap[mode->encap] == mode)) {
97021 + pax_open_kernel();
97022 modemap[mode->encap] = NULL;
97023 + pax_close_kernel();
97024 module_put(mode->afinfo->owner);
97025 err = 0;
97026 }
97027 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97028 u32 xfrm_get_acqseq(void)
97029 {
97030 u32 res;
97031 - static atomic_t acqseq;
97032 + static atomic_unchecked_t acqseq;
97033
97034 do {
97035 - res = atomic_inc_return(&acqseq);
97036 + res = atomic_inc_return_unchecked(&acqseq);
97037 } while (!res);
97038
97039 return res;
97040 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97041 index 05a6e3d..6716ec9 100644
97042 --- a/net/xfrm/xfrm_sysctl.c
97043 +++ b/net/xfrm/xfrm_sysctl.c
97044 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97045
97046 int __net_init xfrm_sysctl_init(struct net *net)
97047 {
97048 - struct ctl_table *table;
97049 + ctl_table_no_const *table;
97050
97051 __xfrm_sysctl_init(net);
97052
97053 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
97054 index 3f565e4..f964d4c 100644
97055 --- a/net/xfrm/xfrm_user.c
97056 +++ b/net/xfrm/xfrm_user.c
97057 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
97058 memcpy(&x->sel, &p->sel, sizeof(x->sel));
97059 memcpy(&x->lft, &p->lft, sizeof(x->lft));
97060 x->props.mode = p->mode;
97061 - x->props.replay_window = p->replay_window;
97062 + x->props.replay_window = min_t(unsigned int, p->replay_window,
97063 + sizeof(x->replay.bitmap) * 8);
97064 x->props.reqid = p->reqid;
97065 x->props.family = p->family;
97066 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
97067 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
97068 if (x->km.state != XFRM_STATE_VALID)
97069 goto out;
97070
97071 - err = xfrm_replay_verify_len(x->replay_esn, rp);
97072 + err = xfrm_replay_verify_len(x->replay_esn, re);
97073 if (err)
97074 goto out;
97075
97076 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97077 index d5d859c..781cbcb 100644
97078 --- a/scripts/Makefile.build
97079 +++ b/scripts/Makefile.build
97080 @@ -111,7 +111,7 @@ endif
97081 endif
97082
97083 # Do not include host rules unless needed
97084 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97085 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97086 include scripts/Makefile.host
97087 endif
97088
97089 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97090 index 686cb0d..9d653bf 100644
97091 --- a/scripts/Makefile.clean
97092 +++ b/scripts/Makefile.clean
97093 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97094 __clean-files := $(extra-y) $(always) \
97095 $(targets) $(clean-files) \
97096 $(host-progs) \
97097 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97098 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97099 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97100
97101 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97102
97103 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97104 index 1ac414f..38575f7 100644
97105 --- a/scripts/Makefile.host
97106 +++ b/scripts/Makefile.host
97107 @@ -31,6 +31,8 @@
97108 # Note: Shared libraries consisting of C++ files are not supported
97109
97110 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97111 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97112 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97113
97114 # C code
97115 # Executables compiled from a single .c file
97116 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97117 # Shared libaries (only .c supported)
97118 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97119 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97120 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97121 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97122 # Remove .so files from "xxx-objs"
97123 host-cobjs := $(filter-out %.so,$(host-cobjs))
97124 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97125
97126 -#Object (.o) files used by the shared libaries
97127 +# Object (.o) files used by the shared libaries
97128 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97129 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97130
97131 # output directory for programs/.o files
97132 # hostprogs-y := tools/build may have been specified. Retrieve directory
97133 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97134 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97135 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97136 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97137 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97138 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97139 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97140 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97141
97142 obj-dirs += $(host-objdirs)
97143 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97144 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97145 $(call if_changed_dep,host-cshobjs)
97146
97147 +# Compile .c file, create position independent .o file
97148 +# host-cxxshobjs -> .o
97149 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97150 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97151 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97152 + $(call if_changed_dep,host-cxxshobjs)
97153 +
97154 # Link a shared library, based on position independent .o files
97155 # *.o -> .so shared library (host-cshlib)
97156 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97157 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97158 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97159 $(call if_changed,host-cshlib)
97160
97161 +# Link a shared library, based on position independent .o files
97162 +# *.o -> .so shared library (host-cxxshlib)
97163 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97164 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97165 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97166 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97167 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97168 + $(call if_changed,host-cxxshlib)
97169 +
97170 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97171 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97172 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97173
97174 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97175 index 078fe1d..fbdb363 100644
97176 --- a/scripts/basic/fixdep.c
97177 +++ b/scripts/basic/fixdep.c
97178 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97179 /*
97180 * Lookup a value in the configuration string.
97181 */
97182 -static int is_defined_config(const char *name, int len, unsigned int hash)
97183 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97184 {
97185 struct item *aux;
97186
97187 @@ -211,10 +211,10 @@ static void clear_config(void)
97188 /*
97189 * Record the use of a CONFIG_* word.
97190 */
97191 -static void use_config(const char *m, int slen)
97192 +static void use_config(const char *m, unsigned int slen)
97193 {
97194 unsigned int hash = strhash(m, slen);
97195 - int c, i;
97196 + unsigned int c, i;
97197
97198 if (is_defined_config(m, slen, hash))
97199 return;
97200 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97201
97202 static void parse_config_file(const char *map, size_t len)
97203 {
97204 - const int *end = (const int *) (map + len);
97205 + const unsigned int *end = (const unsigned int *) (map + len);
97206 /* start at +1, so that p can never be < map */
97207 - const int *m = (const int *) map + 1;
97208 + const unsigned int *m = (const unsigned int *) map + 1;
97209 const char *p, *q;
97210
97211 for (; m < end; m++) {
97212 @@ -435,7 +435,7 @@ static void print_deps(void)
97213 static void traps(void)
97214 {
97215 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97216 - int *p = (int *)test;
97217 + unsigned int *p = (unsigned int *)test;
97218
97219 if (*p != INT_CONF) {
97220 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97221 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97222 new file mode 100644
97223 index 0000000..5e0222d
97224 --- /dev/null
97225 +++ b/scripts/gcc-plugin.sh
97226 @@ -0,0 +1,17 @@
97227 +#!/bin/bash
97228 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97229 +#include "gcc-plugin.h"
97230 +#include "tree.h"
97231 +#include "tm.h"
97232 +#include "rtl.h"
97233 +#ifdef ENABLE_BUILD_WITH_CXX
97234 +#warning $2
97235 +#else
97236 +#warning $1
97237 +#endif
97238 +EOF`
97239 +if [ $? -eq 0 ]
97240 +then
97241 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97242 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97243 +fi
97244 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97245 index 5de5660..d3deb89 100644
97246 --- a/scripts/headers_install.sh
97247 +++ b/scripts/headers_install.sh
97248 @@ -32,6 +32,7 @@ do
97249 FILE="$(basename "$i")"
97250 sed -r \
97251 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97252 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97253 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97254 -e 's@^#include <linux/compiler.h>@@' \
97255 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97256 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97257 index 0149949..d482a0d 100644
97258 --- a/scripts/link-vmlinux.sh
97259 +++ b/scripts/link-vmlinux.sh
97260 @@ -158,7 +158,7 @@ else
97261 fi;
97262
97263 # final build of init/
97264 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97265 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97266
97267 kallsymso=""
97268 kallsyms_vmlinux=""
97269 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97270 index 2370863..212fbca 100644
97271 --- a/scripts/mod/file2alias.c
97272 +++ b/scripts/mod/file2alias.c
97273 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97274 unsigned long size, unsigned long id_size,
97275 void *symval)
97276 {
97277 - int i;
97278 + unsigned int i;
97279
97280 if (size % id_size || size < id_size) {
97281 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97282 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97283 /* USB is special because the bcdDevice can be matched against a numeric range */
97284 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97285 static void do_usb_entry(void *symval,
97286 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97287 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97288 unsigned char range_lo, unsigned char range_hi,
97289 unsigned char max, struct module *mod)
97290 {
97291 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97292 {
97293 unsigned int devlo, devhi;
97294 unsigned char chi, clo, max;
97295 - int ndigits;
97296 + unsigned int ndigits;
97297
97298 DEF_FIELD(symval, usb_device_id, match_flags);
97299 DEF_FIELD(symval, usb_device_id, idVendor);
97300 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97301 for (i = 0; i < count; i++) {
97302 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97303 char acpi_id[sizeof(*id)];
97304 - int j;
97305 + unsigned int j;
97306
97307 buf_printf(&mod->dev_table_buf,
97308 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97309 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97310
97311 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97312 const char *id = (char *)(*devs)[j].id;
97313 - int i2, j2;
97314 + unsigned int i2, j2;
97315 int dup = 0;
97316
97317 if (!id[0])
97318 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97319 /* add an individual alias for every device entry */
97320 if (!dup) {
97321 char acpi_id[PNP_ID_LEN];
97322 - int k;
97323 + unsigned int k;
97324
97325 buf_printf(&mod->dev_table_buf,
97326 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97327 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97328 static int do_dmi_entry(const char *filename, void *symval,
97329 char *alias)
97330 {
97331 - int i, j;
97332 + unsigned int i, j;
97333 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97334 sprintf(alias, "dmi*");
97335
97336 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97337 index 6216434..050cf89 100644
97338 --- a/scripts/mod/modpost.c
97339 +++ b/scripts/mod/modpost.c
97340 @@ -930,6 +930,7 @@ enum mismatch {
97341 ANY_INIT_TO_ANY_EXIT,
97342 ANY_EXIT_TO_ANY_INIT,
97343 EXPORT_TO_INIT_EXIT,
97344 + DATA_TO_TEXT
97345 };
97346
97347 struct sectioncheck {
97348 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
97349 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97350 .mismatch = EXPORT_TO_INIT_EXIT,
97351 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97352 +},
97353 +/* Do not reference code from writable data */
97354 +{
97355 + .fromsec = { DATA_SECTIONS, NULL },
97356 + .tosec = { TEXT_SECTIONS, NULL },
97357 + .mismatch = DATA_TO_TEXT
97358 }
97359 };
97360
97361 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97362 continue;
97363 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97364 continue;
97365 - if (sym->st_value == addr)
97366 - return sym;
97367 /* Find a symbol nearby - addr are maybe negative */
97368 d = sym->st_value - addr;
97369 + if (d == 0)
97370 + return sym;
97371 if (d < 0)
97372 d = addr - sym->st_value;
97373 if (d < distance) {
97374 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
97375 tosym, prl_to, prl_to, tosym);
97376 free(prl_to);
97377 break;
97378 + case DATA_TO_TEXT:
97379 +#if 0
97380 + fprintf(stderr,
97381 + "The %s %s:%s references\n"
97382 + "the %s %s:%s%s\n",
97383 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97384 +#endif
97385 + break;
97386 }
97387 fprintf(stderr, "\n");
97388 }
97389 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97390 static void check_sec_ref(struct module *mod, const char *modname,
97391 struct elf_info *elf)
97392 {
97393 - int i;
97394 + unsigned int i;
97395 Elf_Shdr *sechdrs = elf->sechdrs;
97396
97397 /* Walk through all sections */
97398 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97399 va_end(ap);
97400 }
97401
97402 -void buf_write(struct buffer *buf, const char *s, int len)
97403 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97404 {
97405 if (buf->size - buf->pos < len) {
97406 buf->size += len + SZ;
97407 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97408 if (fstat(fileno(file), &st) < 0)
97409 goto close_write;
97410
97411 - if (st.st_size != b->pos)
97412 + if (st.st_size != (off_t)b->pos)
97413 goto close_write;
97414
97415 tmp = NOFAIL(malloc(b->pos));
97416 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97417 index 51207e4..f7d603d 100644
97418 --- a/scripts/mod/modpost.h
97419 +++ b/scripts/mod/modpost.h
97420 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97421
97422 struct buffer {
97423 char *p;
97424 - int pos;
97425 - int size;
97426 + unsigned int pos;
97427 + unsigned int size;
97428 };
97429
97430 void __attribute__((format(printf, 2, 3)))
97431 buf_printf(struct buffer *buf, const char *fmt, ...);
97432
97433 void
97434 -buf_write(struct buffer *buf, const char *s, int len);
97435 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97436
97437 struct module {
97438 struct module *next;
97439 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97440 index 9dfcd6d..099068e 100644
97441 --- a/scripts/mod/sumversion.c
97442 +++ b/scripts/mod/sumversion.c
97443 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97444 goto out;
97445 }
97446
97447 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97448 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97449 warn("writing sum in %s failed: %s\n",
97450 filename, strerror(errno));
97451 goto out;
97452 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97453 index 0865b3e..7235dd4 100644
97454 --- a/scripts/module-common.lds
97455 +++ b/scripts/module-common.lds
97456 @@ -6,6 +6,10 @@
97457 SECTIONS {
97458 /DISCARD/ : { *(.discard) }
97459
97460 + .rodata : {
97461 + *(.rodata) *(.rodata.*)
97462 + *(.data..read_only)
97463 + }
97464 __ksymtab : { *(SORT(___ksymtab+*)) }
97465 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97466 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97467 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97468 index acb8650..b8c5f02 100644
97469 --- a/scripts/package/builddeb
97470 +++ b/scripts/package/builddeb
97471 @@ -246,6 +246,7 @@ fi
97472 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97473 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97474 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97475 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97476 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97477 mkdir -p "$destdir"
97478 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97479 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97480 index 68bb4ef..2f419e1 100644
97481 --- a/scripts/pnmtologo.c
97482 +++ b/scripts/pnmtologo.c
97483 @@ -244,14 +244,14 @@ static void write_header(void)
97484 fprintf(out, " * Linux logo %s\n", logoname);
97485 fputs(" */\n\n", out);
97486 fputs("#include <linux/linux_logo.h>\n\n", out);
97487 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97488 + fprintf(out, "static unsigned char %s_data[] = {\n",
97489 logoname);
97490 }
97491
97492 static void write_footer(void)
97493 {
97494 fputs("\n};\n\n", out);
97495 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97496 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97497 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97498 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97499 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97500 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97501 fputs("\n};\n\n", out);
97502
97503 /* write logo clut */
97504 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97505 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97506 logoname);
97507 write_hex_cnt = 0;
97508 for (i = 0; i < logo_clutsize; i++) {
97509 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97510 index f5eb43d..1814de8 100644
97511 --- a/scripts/sortextable.h
97512 +++ b/scripts/sortextable.h
97513 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97514 const char *secstrtab;
97515 const char *strtab;
97516 char *extab_image;
97517 - int extab_index = 0;
97518 - int i;
97519 - int idx;
97520 + unsigned int extab_index = 0;
97521 + unsigned int i;
97522 + unsigned int idx;
97523
97524 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97525 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97526 diff --git a/security/Kconfig b/security/Kconfig
97527 index e9c6ac7..5b9d82e 100644
97528 --- a/security/Kconfig
97529 +++ b/security/Kconfig
97530 @@ -4,6 +4,959 @@
97531
97532 menu "Security options"
97533
97534 +menu "Grsecurity"
97535 +
97536 + config ARCH_TRACK_EXEC_LIMIT
97537 + bool
97538 +
97539 + config PAX_KERNEXEC_PLUGIN
97540 + bool
97541 +
97542 + config PAX_PER_CPU_PGD
97543 + bool
97544 +
97545 + config TASK_SIZE_MAX_SHIFT
97546 + int
97547 + depends on X86_64
97548 + default 47 if !PAX_PER_CPU_PGD
97549 + default 42 if PAX_PER_CPU_PGD
97550 +
97551 + config PAX_ENABLE_PAE
97552 + bool
97553 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97554 +
97555 + config PAX_USERCOPY_SLABS
97556 + bool
97557 +
97558 +config GRKERNSEC
97559 + bool "Grsecurity"
97560 + select CRYPTO
97561 + select CRYPTO_SHA256
97562 + select PROC_FS
97563 + select STOP_MACHINE
97564 + select TTY
97565 + help
97566 + If you say Y here, you will be able to configure many features
97567 + that will enhance the security of your system. It is highly
97568 + recommended that you say Y here and read through the help
97569 + for each option so that you fully understand the features and
97570 + can evaluate their usefulness for your machine.
97571 +
97572 +choice
97573 + prompt "Configuration Method"
97574 + depends on GRKERNSEC
97575 + default GRKERNSEC_CONFIG_CUSTOM
97576 + help
97577 +
97578 +config GRKERNSEC_CONFIG_AUTO
97579 + bool "Automatic"
97580 + help
97581 + If you choose this configuration method, you'll be able to answer a small
97582 + number of simple questions about how you plan to use this kernel.
97583 + The settings of grsecurity and PaX will be automatically configured for
97584 + the highest commonly-used settings within the provided constraints.
97585 +
97586 + If you require additional configuration, custom changes can still be made
97587 + from the "custom configuration" menu.
97588 +
97589 +config GRKERNSEC_CONFIG_CUSTOM
97590 + bool "Custom"
97591 + help
97592 + If you choose this configuration method, you'll be able to configure all
97593 + grsecurity and PaX settings manually. Via this method, no options are
97594 + automatically enabled.
97595 +
97596 +endchoice
97597 +
97598 +choice
97599 + prompt "Usage Type"
97600 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97601 + default GRKERNSEC_CONFIG_SERVER
97602 + help
97603 +
97604 +config GRKERNSEC_CONFIG_SERVER
97605 + bool "Server"
97606 + help
97607 + Choose this option if you plan to use this kernel on a server.
97608 +
97609 +config GRKERNSEC_CONFIG_DESKTOP
97610 + bool "Desktop"
97611 + help
97612 + Choose this option if you plan to use this kernel on a desktop.
97613 +
97614 +endchoice
97615 +
97616 +choice
97617 + prompt "Virtualization Type"
97618 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97619 + default GRKERNSEC_CONFIG_VIRT_NONE
97620 + help
97621 +
97622 +config GRKERNSEC_CONFIG_VIRT_NONE
97623 + bool "None"
97624 + help
97625 + Choose this option if this kernel will be run on bare metal.
97626 +
97627 +config GRKERNSEC_CONFIG_VIRT_GUEST
97628 + bool "Guest"
97629 + help
97630 + Choose this option if this kernel will be run as a VM guest.
97631 +
97632 +config GRKERNSEC_CONFIG_VIRT_HOST
97633 + bool "Host"
97634 + help
97635 + Choose this option if this kernel will be run as a VM host.
97636 +
97637 +endchoice
97638 +
97639 +choice
97640 + prompt "Virtualization Hardware"
97641 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97642 + help
97643 +
97644 +config GRKERNSEC_CONFIG_VIRT_EPT
97645 + bool "EPT/RVI Processor Support"
97646 + depends on X86
97647 + help
97648 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97649 + hardware virtualization. This allows for additional kernel hardening protections
97650 + to operate without additional performance impact.
97651 +
97652 + To see if your Intel processor supports EPT, see:
97653 + http://ark.intel.com/Products/VirtualizationTechnology
97654 + (Most Core i3/5/7 support EPT)
97655 +
97656 + To see if your AMD processor supports RVI, see:
97657 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97658 +
97659 +config GRKERNSEC_CONFIG_VIRT_SOFT
97660 + bool "First-gen/No Hardware Virtualization"
97661 + help
97662 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97663 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97664 +
97665 +endchoice
97666 +
97667 +choice
97668 + prompt "Virtualization Software"
97669 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97670 + help
97671 +
97672 +config GRKERNSEC_CONFIG_VIRT_XEN
97673 + bool "Xen"
97674 + help
97675 + Choose this option if this kernel is running as a Xen guest or host.
97676 +
97677 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97678 + bool "VMWare"
97679 + help
97680 + Choose this option if this kernel is running as a VMWare guest or host.
97681 +
97682 +config GRKERNSEC_CONFIG_VIRT_KVM
97683 + bool "KVM"
97684 + help
97685 + Choose this option if this kernel is running as a KVM guest or host.
97686 +
97687 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97688 + bool "VirtualBox"
97689 + help
97690 + Choose this option if this kernel is running as a VirtualBox guest or host.
97691 +
97692 +endchoice
97693 +
97694 +choice
97695 + prompt "Required Priorities"
97696 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97697 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97698 + help
97699 +
97700 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97701 + bool "Performance"
97702 + help
97703 + Choose this option if performance is of highest priority for this deployment
97704 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97705 + clearing of structures intended for userland, and freed memory sanitizing will
97706 + be disabled.
97707 +
97708 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97709 + bool "Security"
97710 + help
97711 + Choose this option if security is of highest priority for this deployment of
97712 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97713 + for userland, and freed memory sanitizing will be enabled for this kernel.
97714 + In a worst-case scenario, these features can introduce a 20% performance hit
97715 + (UDEREF on x64 contributing half of this hit).
97716 +
97717 +endchoice
97718 +
97719 +menu "Default Special Groups"
97720 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97721 +
97722 +config GRKERNSEC_PROC_GID
97723 + int "GID exempted from /proc restrictions"
97724 + default 1001
97725 + help
97726 + Setting this GID determines which group will be exempted from
97727 + grsecurity's /proc restrictions, allowing users of the specified
97728 + group to view network statistics and the existence of other users'
97729 + processes on the system. This GID may also be chosen at boot time
97730 + via "grsec_proc_gid=" on the kernel commandline.
97731 +
97732 +config GRKERNSEC_TPE_UNTRUSTED_GID
97733 + int "GID for TPE-untrusted users"
97734 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97735 + default 1005
97736 + help
97737 + Setting this GID determines which group untrusted users should
97738 + be added to. These users will be placed under grsecurity's Trusted Path
97739 + Execution mechanism, preventing them from executing their own binaries.
97740 + The users will only be able to execute binaries in directories owned and
97741 + writable only by the root user. If the sysctl option is enabled, a sysctl
97742 + option with name "tpe_gid" is created.
97743 +
97744 +config GRKERNSEC_TPE_TRUSTED_GID
97745 + int "GID for TPE-trusted users"
97746 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97747 + default 1005
97748 + help
97749 + Setting this GID determines what group TPE restrictions will be
97750 + *disabled* for. If the sysctl option is enabled, a sysctl option
97751 + with name "tpe_gid" is created.
97752 +
97753 +config GRKERNSEC_SYMLINKOWN_GID
97754 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97755 + depends on GRKERNSEC_CONFIG_SERVER
97756 + default 1006
97757 + help
97758 + Setting this GID determines what group kernel-enforced
97759 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97760 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97761 +
97762 +
97763 +endmenu
97764 +
97765 +menu "Customize Configuration"
97766 +depends on GRKERNSEC
97767 +
97768 +menu "PaX"
97769 +
97770 +config PAX
97771 + bool "Enable various PaX features"
97772 + default y if GRKERNSEC_CONFIG_AUTO
97773 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97774 + help
97775 + This allows you to enable various PaX features. PaX adds
97776 + intrusion prevention mechanisms to the kernel that reduce
97777 + the risks posed by exploitable memory corruption bugs.
97778 +
97779 +menu "PaX Control"
97780 + depends on PAX
97781 +
97782 +config PAX_SOFTMODE
97783 + bool 'Support soft mode'
97784 + help
97785 + Enabling this option will allow you to run PaX in soft mode, that
97786 + is, PaX features will not be enforced by default, only on executables
97787 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97788 + support as they are the only way to mark executables for soft mode use.
97789 +
97790 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97791 + line option on boot. Furthermore you can control various PaX features
97792 + at runtime via the entries in /proc/sys/kernel/pax.
97793 +
97794 +config PAX_EI_PAX
97795 + bool 'Use legacy ELF header marking'
97796 + default y if GRKERNSEC_CONFIG_AUTO
97797 + help
97798 + Enabling this option will allow you to control PaX features on
97799 + a per executable basis via the 'chpax' utility available at
97800 + http://pax.grsecurity.net/. The control flags will be read from
97801 + an otherwise reserved part of the ELF header. This marking has
97802 + numerous drawbacks (no support for soft-mode, toolchain does not
97803 + know about the non-standard use of the ELF header) therefore it
97804 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97805 + support.
97806 +
97807 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97808 + support as well, they will override the legacy EI_PAX marks.
97809 +
97810 + If you enable none of the marking options then all applications
97811 + will run with PaX enabled on them by default.
97812 +
97813 +config PAX_PT_PAX_FLAGS
97814 + bool 'Use ELF program header marking'
97815 + default y if GRKERNSEC_CONFIG_AUTO
97816 + help
97817 + Enabling this option will allow you to control PaX features on
97818 + a per executable basis via the 'paxctl' utility available at
97819 + http://pax.grsecurity.net/. The control flags will be read from
97820 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97821 + has the benefits of supporting both soft mode and being fully
97822 + integrated into the toolchain (the binutils patch is available
97823 + from http://pax.grsecurity.net).
97824 +
97825 + Note that if you enable the legacy EI_PAX marking support as well,
97826 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97827 +
97828 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97829 + must make sure that the marks are the same if a binary has both marks.
97830 +
97831 + If you enable none of the marking options then all applications
97832 + will run with PaX enabled on them by default.
97833 +
97834 +config PAX_XATTR_PAX_FLAGS
97835 + bool 'Use filesystem extended attributes marking'
97836 + default y if GRKERNSEC_CONFIG_AUTO
97837 + select CIFS_XATTR if CIFS
97838 + select EXT2_FS_XATTR if EXT2_FS
97839 + select EXT3_FS_XATTR if EXT3_FS
97840 + select EXT4_FS_XATTR if EXT4_FS
97841 + select JFFS2_FS_XATTR if JFFS2_FS
97842 + select REISERFS_FS_XATTR if REISERFS_FS
97843 + select SQUASHFS_XATTR if SQUASHFS
97844 + select TMPFS_XATTR if TMPFS
97845 + select UBIFS_FS_XATTR if UBIFS_FS
97846 + help
97847 + Enabling this option will allow you to control PaX features on
97848 + a per executable basis via the 'setfattr' utility. The control
97849 + flags will be read from the user.pax.flags extended attribute of
97850 + the file. This marking has the benefit of supporting binary-only
97851 + applications that self-check themselves (e.g., skype) and would
97852 + not tolerate chpax/paxctl changes. The main drawback is that
97853 + extended attributes are not supported by some filesystems (e.g.,
97854 + isofs, udf, vfat) so copying files through such filesystems will
97855 + lose the extended attributes and these PaX markings.
97856 +
97857 + Note that if you enable the legacy EI_PAX marking support as well,
97858 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97859 +
97860 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97861 + must make sure that the marks are the same if a binary has both marks.
97862 +
97863 + If you enable none of the marking options then all applications
97864 + will run with PaX enabled on them by default.
97865 +
97866 +choice
97867 + prompt 'MAC system integration'
97868 + default PAX_HAVE_ACL_FLAGS
97869 + help
97870 + Mandatory Access Control systems have the option of controlling
97871 + PaX flags on a per executable basis, choose the method supported
97872 + by your particular system.
97873 +
97874 + - "none": if your MAC system does not interact with PaX,
97875 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97876 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97877 +
97878 + NOTE: this option is for developers/integrators only.
97879 +
97880 + config PAX_NO_ACL_FLAGS
97881 + bool 'none'
97882 +
97883 + config PAX_HAVE_ACL_FLAGS
97884 + bool 'direct'
97885 +
97886 + config PAX_HOOK_ACL_FLAGS
97887 + bool 'hook'
97888 +endchoice
97889 +
97890 +endmenu
97891 +
97892 +menu "Non-executable pages"
97893 + depends on PAX
97894 +
97895 +config PAX_NOEXEC
97896 + bool "Enforce non-executable pages"
97897 + default y if GRKERNSEC_CONFIG_AUTO
97898 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97899 + help
97900 + By design some architectures do not allow for protecting memory
97901 + pages against execution or even if they do, Linux does not make
97902 + use of this feature. In practice this means that if a page is
97903 + readable (such as the stack or heap) it is also executable.
97904 +
97905 + There is a well known exploit technique that makes use of this
97906 + fact and a common programming mistake where an attacker can
97907 + introduce code of his choice somewhere in the attacked program's
97908 + memory (typically the stack or the heap) and then execute it.
97909 +
97910 + If the attacked program was running with different (typically
97911 + higher) privileges than that of the attacker, then he can elevate
97912 + his own privilege level (e.g. get a root shell, write to files for
97913 + which he does not have write access to, etc).
97914 +
97915 + Enabling this option will let you choose from various features
97916 + that prevent the injection and execution of 'foreign' code in
97917 + a program.
97918 +
97919 + This will also break programs that rely on the old behaviour and
97920 + expect that dynamically allocated memory via the malloc() family
97921 + of functions is executable (which it is not). Notable examples
97922 + are the XFree86 4.x server, the java runtime and wine.
97923 +
97924 +config PAX_PAGEEXEC
97925 + bool "Paging based non-executable pages"
97926 + default y if GRKERNSEC_CONFIG_AUTO
97927 + 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)
97928 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97929 + help
97930 + This implementation is based on the paging feature of the CPU.
97931 + On i386 without hardware non-executable bit support there is a
97932 + variable but usually low performance impact, however on Intel's
97933 + P4 core based CPUs it is very high so you should not enable this
97934 + for kernels meant to be used on such CPUs.
97935 +
97936 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97937 + with hardware non-executable bit support there is no performance
97938 + impact, on ppc the impact is negligible.
97939 +
97940 + Note that several architectures require various emulations due to
97941 + badly designed userland ABIs, this will cause a performance impact
97942 + but will disappear as soon as userland is fixed. For example, ppc
97943 + userland MUST have been built with secure-plt by a recent toolchain.
97944 +
97945 +config PAX_SEGMEXEC
97946 + bool "Segmentation based non-executable pages"
97947 + default y if GRKERNSEC_CONFIG_AUTO
97948 + depends on PAX_NOEXEC && X86_32
97949 + help
97950 + This implementation is based on the segmentation feature of the
97951 + CPU and has a very small performance impact, however applications
97952 + will be limited to a 1.5 GB address space instead of the normal
97953 + 3 GB.
97954 +
97955 +config PAX_EMUTRAMP
97956 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
97957 + default y if PARISC
97958 + help
97959 + There are some programs and libraries that for one reason or
97960 + another attempt to execute special small code snippets from
97961 + non-executable memory pages. Most notable examples are the
97962 + signal handler return code generated by the kernel itself and
97963 + the GCC trampolines.
97964 +
97965 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
97966 + such programs will no longer work under your kernel.
97967 +
97968 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
97969 + utilities to enable trampoline emulation for the affected programs
97970 + yet still have the protection provided by the non-executable pages.
97971 +
97972 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
97973 + your system will not even boot.
97974 +
97975 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
97976 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
97977 + for the affected files.
97978 +
97979 + NOTE: enabling this feature *may* open up a loophole in the
97980 + protection provided by non-executable pages that an attacker
97981 + could abuse. Therefore the best solution is to not have any
97982 + files on your system that would require this option. This can
97983 + be achieved by not using libc5 (which relies on the kernel
97984 + signal handler return code) and not using or rewriting programs
97985 + that make use of the nested function implementation of GCC.
97986 + Skilled users can just fix GCC itself so that it implements
97987 + nested function calls in a way that does not interfere with PaX.
97988 +
97989 +config PAX_EMUSIGRT
97990 + bool "Automatically emulate sigreturn trampolines"
97991 + depends on PAX_EMUTRAMP && PARISC
97992 + default y
97993 + help
97994 + Enabling this option will have the kernel automatically detect
97995 + and emulate signal return trampolines executing on the stack
97996 + that would otherwise lead to task termination.
97997 +
97998 + This solution is intended as a temporary one for users with
97999 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98000 + Modula-3 runtime, etc) or executables linked to such, basically
98001 + everything that does not specify its own SA_RESTORER function in
98002 + normal executable memory like glibc 2.1+ does.
98003 +
98004 + On parisc you MUST enable this option, otherwise your system will
98005 + not even boot.
98006 +
98007 + NOTE: this feature cannot be disabled on a per executable basis
98008 + and since it *does* open up a loophole in the protection provided
98009 + by non-executable pages, the best solution is to not have any
98010 + files on your system that would require this option.
98011 +
98012 +config PAX_MPROTECT
98013 + bool "Restrict mprotect()"
98014 + default y if GRKERNSEC_CONFIG_AUTO
98015 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98016 + help
98017 + Enabling this option will prevent programs from
98018 + - changing the executable status of memory pages that were
98019 + not originally created as executable,
98020 + - making read-only executable pages writable again,
98021 + - creating executable pages from anonymous memory,
98022 + - making read-only-after-relocations (RELRO) data pages writable again.
98023 +
98024 + You should say Y here to complete the protection provided by
98025 + the enforcement of non-executable pages.
98026 +
98027 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98028 + this feature on a per file basis.
98029 +
98030 +config PAX_MPROTECT_COMPAT
98031 + bool "Use legacy/compat protection demoting (read help)"
98032 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98033 + depends on PAX_MPROTECT
98034 + help
98035 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98036 + by sending the proper error code to the application. For some broken
98037 + userland, this can cause problems with Python or other applications. The
98038 + current implementation however allows for applications like clamav to
98039 + detect if JIT compilation/execution is allowed and to fall back gracefully
98040 + to an interpreter-based mode if it does not. While we encourage everyone
98041 + to use the current implementation as-is and push upstream to fix broken
98042 + userland (note that the RWX logging option can assist with this), in some
98043 + environments this may not be possible. Having to disable MPROTECT
98044 + completely on certain binaries reduces the security benefit of PaX,
98045 + so this option is provided for those environments to revert to the old
98046 + behavior.
98047 +
98048 +config PAX_ELFRELOCS
98049 + bool "Allow ELF text relocations (read help)"
98050 + depends on PAX_MPROTECT
98051 + default n
98052 + help
98053 + Non-executable pages and mprotect() restrictions are effective
98054 + in preventing the introduction of new executable code into an
98055 + attacked task's address space. There remain only two venues
98056 + for this kind of attack: if the attacker can execute already
98057 + existing code in the attacked task then he can either have it
98058 + create and mmap() a file containing his code or have it mmap()
98059 + an already existing ELF library that does not have position
98060 + independent code in it and use mprotect() on it to make it
98061 + writable and copy his code there. While protecting against
98062 + the former approach is beyond PaX, the latter can be prevented
98063 + by having only PIC ELF libraries on one's system (which do not
98064 + need to relocate their code). If you are sure this is your case,
98065 + as is the case with all modern Linux distributions, then leave
98066 + this option disabled. You should say 'n' here.
98067 +
98068 +config PAX_ETEXECRELOCS
98069 + bool "Allow ELF ET_EXEC text relocations"
98070 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98071 + select PAX_ELFRELOCS
98072 + default y
98073 + help
98074 + On some architectures there are incorrectly created applications
98075 + that require text relocations and would not work without enabling
98076 + this option. If you are an alpha, ia64 or parisc user, you should
98077 + enable this option and disable it once you have made sure that
98078 + none of your applications need it.
98079 +
98080 +config PAX_EMUPLT
98081 + bool "Automatically emulate ELF PLT"
98082 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98083 + default y
98084 + help
98085 + Enabling this option will have the kernel automatically detect
98086 + and emulate the Procedure Linkage Table entries in ELF files.
98087 + On some architectures such entries are in writable memory, and
98088 + become non-executable leading to task termination. Therefore
98089 + it is mandatory that you enable this option on alpha, parisc,
98090 + sparc and sparc64, otherwise your system would not even boot.
98091 +
98092 + NOTE: this feature *does* open up a loophole in the protection
98093 + provided by the non-executable pages, therefore the proper
98094 + solution is to modify the toolchain to produce a PLT that does
98095 + not need to be writable.
98096 +
98097 +config PAX_DLRESOLVE
98098 + bool 'Emulate old glibc resolver stub'
98099 + depends on PAX_EMUPLT && SPARC
98100 + default n
98101 + help
98102 + This option is needed if userland has an old glibc (before 2.4)
98103 + that puts a 'save' instruction into the runtime generated resolver
98104 + stub that needs special emulation.
98105 +
98106 +config PAX_KERNEXEC
98107 + bool "Enforce non-executable kernel pages"
98108 + 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))
98109 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98110 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98111 + select PAX_KERNEXEC_PLUGIN if X86_64
98112 + help
98113 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98114 + that is, enabling this option will make it harder to inject
98115 + and execute 'foreign' code in kernel memory itself.
98116 +
98117 +choice
98118 + prompt "Return Address Instrumentation Method"
98119 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98120 + depends on PAX_KERNEXEC_PLUGIN
98121 + help
98122 + Select the method used to instrument function pointer dereferences.
98123 + Note that binary modules cannot be instrumented by this approach.
98124 +
98125 + Note that the implementation requires a gcc with plugin support,
98126 + i.e., gcc 4.5 or newer. You may need to install the supporting
98127 + headers explicitly in addition to the normal gcc package.
98128 +
98129 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98130 + bool "bts"
98131 + help
98132 + This method is compatible with binary only modules but has
98133 + a higher runtime overhead.
98134 +
98135 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98136 + bool "or"
98137 + depends on !PARAVIRT
98138 + help
98139 + This method is incompatible with binary only modules but has
98140 + a lower runtime overhead.
98141 +endchoice
98142 +
98143 +config PAX_KERNEXEC_PLUGIN_METHOD
98144 + string
98145 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98146 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98147 + default ""
98148 +
98149 +config PAX_KERNEXEC_MODULE_TEXT
98150 + int "Minimum amount of memory reserved for module code"
98151 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98152 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98153 + depends on PAX_KERNEXEC && X86_32
98154 + help
98155 + Due to implementation details the kernel must reserve a fixed
98156 + amount of memory for runtime allocated code (such as modules)
98157 + at compile time that cannot be changed at runtime. Here you
98158 + can specify the minimum amount in MB that will be reserved.
98159 + Due to the same implementation details this size will always
98160 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98161 + the actually available memory for runtime allocated code will
98162 + usually be more than this minimum.
98163 +
98164 + The default 4 MB should be enough for most users but if you have
98165 + an excessive number of modules (e.g., most distribution configs
98166 + compile many drivers as modules) or use huge modules such as
98167 + nvidia's kernel driver, you will need to adjust this amount.
98168 + A good rule of thumb is to look at your currently loaded kernel
98169 + modules and add up their sizes.
98170 +
98171 +endmenu
98172 +
98173 +menu "Address Space Layout Randomization"
98174 + depends on PAX
98175 +
98176 +config PAX_ASLR
98177 + bool "Address Space Layout Randomization"
98178 + default y if GRKERNSEC_CONFIG_AUTO
98179 + help
98180 + Many if not most exploit techniques rely on the knowledge of
98181 + certain addresses in the attacked program. The following options
98182 + will allow the kernel to apply a certain amount of randomization
98183 + to specific parts of the program thereby forcing an attacker to
98184 + guess them in most cases. Any failed guess will most likely crash
98185 + the attacked program which allows the kernel to detect such attempts
98186 + and react on them. PaX itself provides no reaction mechanisms,
98187 + instead it is strongly encouraged that you make use of Nergal's
98188 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98189 + (http://www.grsecurity.net/) built-in crash detection features or
98190 + develop one yourself.
98191 +
98192 + By saying Y here you can choose to randomize the following areas:
98193 + - top of the task's kernel stack
98194 + - top of the task's userland stack
98195 + - base address for mmap() requests that do not specify one
98196 + (this includes all libraries)
98197 + - base address of the main executable
98198 +
98199 + It is strongly recommended to say Y here as address space layout
98200 + randomization has negligible impact on performance yet it provides
98201 + a very effective protection.
98202 +
98203 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98204 + this feature on a per file basis.
98205 +
98206 +config PAX_RANDKSTACK
98207 + bool "Randomize kernel stack base"
98208 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98209 + depends on X86_TSC && X86
98210 + help
98211 + By saying Y here the kernel will randomize every task's kernel
98212 + stack on every system call. This will not only force an attacker
98213 + to guess it but also prevent him from making use of possible
98214 + leaked information about it.
98215 +
98216 + Since the kernel stack is a rather scarce resource, randomization
98217 + may cause unexpected stack overflows, therefore you should very
98218 + carefully test your system. Note that once enabled in the kernel
98219 + configuration, this feature cannot be disabled on a per file basis.
98220 +
98221 +config PAX_RANDUSTACK
98222 + bool "Randomize user stack base"
98223 + default y if GRKERNSEC_CONFIG_AUTO
98224 + depends on PAX_ASLR
98225 + help
98226 + By saying Y here the kernel will randomize every task's userland
98227 + stack. The randomization is done in two steps where the second
98228 + one may apply a big amount of shift to the top of the stack and
98229 + cause problems for programs that want to use lots of memory (more
98230 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98231 + For this reason the second step can be controlled by 'chpax' or
98232 + 'paxctl' on a per file basis.
98233 +
98234 +config PAX_RANDMMAP
98235 + bool "Randomize mmap() base"
98236 + default y if GRKERNSEC_CONFIG_AUTO
98237 + depends on PAX_ASLR
98238 + help
98239 + By saying Y here the kernel will use a randomized base address for
98240 + mmap() requests that do not specify one themselves. As a result
98241 + all dynamically loaded libraries will appear at random addresses
98242 + and therefore be harder to exploit by a technique where an attacker
98243 + attempts to execute library code for his purposes (e.g. spawn a
98244 + shell from an exploited program that is running at an elevated
98245 + privilege level).
98246 +
98247 + Furthermore, if a program is relinked as a dynamic ELF file, its
98248 + base address will be randomized as well, completing the full
98249 + randomization of the address space layout. Attacking such programs
98250 + becomes a guess game. You can find an example of doing this at
98251 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98252 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98253 +
98254 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98255 + feature on a per file basis.
98256 +
98257 +endmenu
98258 +
98259 +menu "Miscellaneous hardening features"
98260 +
98261 +config PAX_MEMORY_SANITIZE
98262 + bool "Sanitize all freed memory"
98263 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98264 + depends on !HIBERNATION
98265 + help
98266 + By saying Y here the kernel will erase memory pages and slab objects
98267 + as soon as they are freed. This in turn reduces the lifetime of data
98268 + stored in them, making it less likely that sensitive information such
98269 + as passwords, cryptographic secrets, etc stay in memory for too long.
98270 +
98271 + This is especially useful for programs whose runtime is short, long
98272 + lived processes and the kernel itself benefit from this as long as
98273 + they ensure timely freeing of memory that may hold sensitive
98274 + information.
98275 +
98276 + A nice side effect of the sanitization of slab objects is the
98277 + reduction of possible info leaks caused by padding bytes within the
98278 + leaky structures. Use-after-free bugs for structures containing
98279 + pointers can also be detected as dereferencing the sanitized pointer
98280 + will generate an access violation.
98281 +
98282 + The tradeoff is performance impact, on a single CPU system kernel
98283 + compilation sees a 3% slowdown, other systems and workloads may vary
98284 + and you are advised to test this feature on your expected workload
98285 + before deploying it.
98286 +
98287 + To reduce the performance penalty by sanitizing pages only, albeit
98288 + limiting the effectiveness of this feature at the same time, slab
98289 + sanitization can be disabled with the kernel commandline parameter
98290 + "pax_sanitize_slab=0".
98291 +
98292 + Note that this feature does not protect data stored in live pages,
98293 + e.g., process memory swapped to disk may stay there for a long time.
98294 +
98295 +config PAX_MEMORY_STACKLEAK
98296 + bool "Sanitize kernel stack"
98297 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98298 + depends on X86
98299 + help
98300 + By saying Y here the kernel will erase the kernel stack before it
98301 + returns from a system call. This in turn reduces the information
98302 + that a kernel stack leak bug can reveal.
98303 +
98304 + Note that such a bug can still leak information that was put on
98305 + the stack by the current system call (the one eventually triggering
98306 + the bug) but traces of earlier system calls on the kernel stack
98307 + cannot leak anymore.
98308 +
98309 + The tradeoff is performance impact: on a single CPU system kernel
98310 + compilation sees a 1% slowdown, other systems and workloads may vary
98311 + and you are advised to test this feature on your expected workload
98312 + before deploying it.
98313 +
98314 + Note that the full feature requires a gcc with plugin support,
98315 + i.e., gcc 4.5 or newer. You may need to install the supporting
98316 + headers explicitly in addition to the normal gcc package. Using
98317 + older gcc versions means that functions with large enough stack
98318 + frames may leave uninitialized memory behind that may be exposed
98319 + to a later syscall leaking the stack.
98320 +
98321 +config PAX_MEMORY_STRUCTLEAK
98322 + bool "Forcibly initialize local variables copied to userland"
98323 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98324 + help
98325 + By saying Y here the kernel will zero initialize some local
98326 + variables that are going to be copied to userland. This in
98327 + turn prevents unintended information leakage from the kernel
98328 + stack should later code forget to explicitly set all parts of
98329 + the copied variable.
98330 +
98331 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98332 + at a much smaller coverage.
98333 +
98334 + Note that the implementation requires a gcc with plugin support,
98335 + i.e., gcc 4.5 or newer. You may need to install the supporting
98336 + headers explicitly in addition to the normal gcc package.
98337 +
98338 +config PAX_MEMORY_UDEREF
98339 + bool "Prevent invalid userland pointer dereference"
98340 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98341 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98342 + select PAX_PER_CPU_PGD if X86_64
98343 + help
98344 + By saying Y here the kernel will be prevented from dereferencing
98345 + userland pointers in contexts where the kernel expects only kernel
98346 + pointers. This is both a useful runtime debugging feature and a
98347 + security measure that prevents exploiting a class of kernel bugs.
98348 +
98349 + The tradeoff is that some virtualization solutions may experience
98350 + a huge slowdown and therefore you should not enable this feature
98351 + for kernels meant to run in such environments. Whether a given VM
98352 + solution is affected or not is best determined by simply trying it
98353 + out, the performance impact will be obvious right on boot as this
98354 + mechanism engages from very early on. A good rule of thumb is that
98355 + VMs running on CPUs without hardware virtualization support (i.e.,
98356 + the majority of IA-32 CPUs) will likely experience the slowdown.
98357 +
98358 + On X86_64 the kernel will make use of PCID support when available
98359 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98360 + or performance impact. Pass pax_weakuderef on the kernel command
98361 + line to choose the latter.
98362 +
98363 +config PAX_REFCOUNT
98364 + bool "Prevent various kernel object reference counter overflows"
98365 + default y if GRKERNSEC_CONFIG_AUTO
98366 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98367 + help
98368 + By saying Y here the kernel will detect and prevent overflowing
98369 + various (but not all) kinds of object reference counters. Such
98370 + overflows can normally occur due to bugs only and are often, if
98371 + not always, exploitable.
98372 +
98373 + The tradeoff is that data structures protected by an overflowed
98374 + refcount will never be freed and therefore will leak memory. Note
98375 + that this leak also happens even without this protection but in
98376 + that case the overflow can eventually trigger the freeing of the
98377 + data structure while it is still being used elsewhere, resulting
98378 + in the exploitable situation that this feature prevents.
98379 +
98380 + Since this has a negligible performance impact, you should enable
98381 + this feature.
98382 +
98383 +config PAX_CONSTIFY_PLUGIN
98384 + bool "Automatically constify eligible structures"
98385 + default y
98386 + depends on !UML && PAX_KERNEXEC
98387 + help
98388 + By saying Y here the compiler will automatically constify a class
98389 + of types that contain only function pointers. This reduces the
98390 + kernel's attack surface and also produces a better memory layout.
98391 +
98392 + Note that the implementation requires a gcc with plugin support,
98393 + i.e., gcc 4.5 or newer. You may need to install the supporting
98394 + headers explicitly in addition to the normal gcc package.
98395 +
98396 + Note that if some code really has to modify constified variables
98397 + then the source code will have to be patched to allow it. Examples
98398 + can be found in PaX itself (the no_const attribute) and for some
98399 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98400 +
98401 +config PAX_USERCOPY
98402 + bool "Harden heap object copies between kernel and userland"
98403 + default y if GRKERNSEC_CONFIG_AUTO
98404 + depends on ARM || IA64 || PPC || SPARC || X86
98405 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98406 + select PAX_USERCOPY_SLABS
98407 + help
98408 + By saying Y here the kernel will enforce the size of heap objects
98409 + when they are copied in either direction between the kernel and
98410 + userland, even if only a part of the heap object is copied.
98411 +
98412 + Specifically, this checking prevents information leaking from the
98413 + kernel heap during kernel to userland copies (if the kernel heap
98414 + object is otherwise fully initialized) and prevents kernel heap
98415 + overflows during userland to kernel copies.
98416 +
98417 + Note that the current implementation provides the strictest bounds
98418 + checks for the SLUB allocator.
98419 +
98420 + Enabling this option also enables per-slab cache protection against
98421 + data in a given cache being copied into/out of via userland
98422 + accessors. Though the whitelist of regions will be reduced over
98423 + time, it notably protects important data structures like task structs.
98424 +
98425 + If frame pointers are enabled on x86, this option will also restrict
98426 + copies into and out of the kernel stack to local variables within a
98427 + single frame.
98428 +
98429 + Since this has a negligible performance impact, you should enable
98430 + this feature.
98431 +
98432 +config PAX_USERCOPY_DEBUG
98433 + bool
98434 + depends on X86 && PAX_USERCOPY
98435 + default n
98436 +
98437 +config PAX_SIZE_OVERFLOW
98438 + bool "Prevent various integer overflows in function size parameters"
98439 + default y if GRKERNSEC_CONFIG_AUTO
98440 + depends on X86
98441 + help
98442 + By saying Y here the kernel recomputes expressions of function
98443 + arguments marked by a size_overflow attribute with double integer
98444 + precision (DImode/TImode for 32/64 bit integer types).
98445 +
98446 + The recomputed argument is checked against TYPE_MAX and an event
98447 + is logged on overflow and the triggering process is killed.
98448 +
98449 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98450 +
98451 + Note that the implementation requires a gcc with plugin support,
98452 + i.e., gcc 4.5 or newer. You may need to install the supporting
98453 + headers explicitly in addition to the normal gcc package.
98454 +
98455 +config PAX_LATENT_ENTROPY
98456 + bool "Generate some entropy during boot and runtime"
98457 + default y if GRKERNSEC_CONFIG_AUTO
98458 + help
98459 + By saying Y here the kernel will instrument some kernel code to
98460 + extract some entropy from both original and artificially created
98461 + program state. This will help especially embedded systems where
98462 + there is little 'natural' source of entropy normally. The cost
98463 + is some slowdown of the boot process and fork and irq processing.
98464 +
98465 + When pax_extra_latent_entropy is passed on the kernel command line,
98466 + entropy will be extracted from up to the first 4GB of RAM while the
98467 + runtime memory allocator is being initialized. This costs even more
98468 + slowdown of the boot process.
98469 +
98470 + Note that the implementation requires a gcc with plugin support,
98471 + i.e., gcc 4.5 or newer. You may need to install the supporting
98472 + headers explicitly in addition to the normal gcc package.
98473 +
98474 + Note that entropy extracted this way is not cryptographically
98475 + secure!
98476 +
98477 +endmenu
98478 +
98479 +endmenu
98480 +
98481 +source grsecurity/Kconfig
98482 +
98483 +endmenu
98484 +
98485 +endmenu
98486 +
98487 source security/keys/Kconfig
98488
98489 config SECURITY_DMESG_RESTRICT
98490 @@ -103,7 +1056,7 @@ config INTEL_TXT
98491 config LSM_MMAP_MIN_ADDR
98492 int "Low address space for LSM to protect from user allocation"
98493 depends on SECURITY && SECURITY_SELINUX
98494 - default 32768 if ARM
98495 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98496 default 65536
98497 help
98498 This is the portion of low virtual memory which should be protected
98499 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98500 index 9b9013b..51ebf96 100644
98501 --- a/security/apparmor/Kconfig
98502 +++ b/security/apparmor/Kconfig
98503 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98504 boot.
98505
98506 If you are unsure how to answer this question, answer 1.
98507 +
98508 +config SECURITY_APPARMOR_COMPAT_24
98509 + bool "Enable AppArmor 2.4 compatability"
98510 + depends on SECURITY_APPARMOR
98511 + default y
98512 + help
98513 + This option enables compatability with AppArmor 2.4. It is
98514 + recommended if compatability with older versions of AppArmor
98515 + is desired.
98516 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98517 index 16c15ec..42b7c9f 100644
98518 --- a/security/apparmor/apparmorfs.c
98519 +++ b/security/apparmor/apparmorfs.c
98520 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98521 .release = single_release,
98522 };
98523
98524 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98525 +/**
98526 + * __next_namespace - find the next namespace to list
98527 + * @root: root namespace to stop search at (NOT NULL)
98528 + * @ns: current ns position (NOT NULL)
98529 + *
98530 + * Find the next namespace from @ns under @root and handle all locking needed
98531 + * while switching current namespace.
98532 + *
98533 + * Returns: next namespace or NULL if at last namespace under @root
98534 + * NOTE: will not unlock root->lock
98535 + */
98536 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98537 + struct aa_namespace *ns)
98538 +{
98539 + struct aa_namespace *parent;
98540 +
98541 + /* is next namespace a child */
98542 + if (!list_empty(&ns->sub_ns)) {
98543 + struct aa_namespace *next;
98544 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98545 + read_lock(&next->lock);
98546 + return next;
98547 + }
98548 +
98549 + /* check if the next ns is a sibling, parent, gp, .. */
98550 + parent = ns->parent;
98551 + while (parent) {
98552 + read_unlock(&ns->lock);
98553 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98554 + read_lock(&ns->lock);
98555 + return ns;
98556 + }
98557 + if (parent == root)
98558 + return NULL;
98559 + ns = parent;
98560 + parent = parent->parent;
98561 + }
98562 +
98563 + return NULL;
98564 +}
98565 +
98566 +/**
98567 + * __first_profile - find the first profile in a namespace
98568 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98569 + * @ns: namespace to start in (NOT NULL)
98570 + *
98571 + * Returns: unrefcounted profile or NULL if no profile
98572 + */
98573 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98574 + struct aa_namespace *ns)
98575 +{
98576 + for ( ; ns; ns = __next_namespace(root, ns)) {
98577 + if (!list_empty(&ns->base.profiles))
98578 + return list_first_entry(&ns->base.profiles,
98579 + struct aa_profile, base.list);
98580 + }
98581 + return NULL;
98582 +}
98583 +
98584 +/**
98585 + * __next_profile - step to the next profile in a profile tree
98586 + * @profile: current profile in tree (NOT NULL)
98587 + *
98588 + * Perform a depth first taversal on the profile tree in a namespace
98589 + *
98590 + * Returns: next profile or NULL if done
98591 + * Requires: profile->ns.lock to be held
98592 + */
98593 +static struct aa_profile *__next_profile(struct aa_profile *p)
98594 +{
98595 + struct aa_profile *parent;
98596 + struct aa_namespace *ns = p->ns;
98597 +
98598 + /* is next profile a child */
98599 + if (!list_empty(&p->base.profiles))
98600 + return list_first_entry(&p->base.profiles, typeof(*p),
98601 + base.list);
98602 +
98603 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98604 + parent = p->parent;
98605 + while (parent) {
98606 + list_for_each_entry_continue(p, &parent->base.profiles,
98607 + base.list)
98608 + return p;
98609 + p = parent;
98610 + parent = parent->parent;
98611 + }
98612 +
98613 + /* is next another profile in the namespace */
98614 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98615 + return p;
98616 +
98617 + return NULL;
98618 +}
98619 +
98620 +/**
98621 + * next_profile - step to the next profile in where ever it may be
98622 + * @root: root namespace (NOT NULL)
98623 + * @profile: current profile (NOT NULL)
98624 + *
98625 + * Returns: next profile or NULL if there isn't one
98626 + */
98627 +static struct aa_profile *next_profile(struct aa_namespace *root,
98628 + struct aa_profile *profile)
98629 +{
98630 + struct aa_profile *next = __next_profile(profile);
98631 + if (next)
98632 + return next;
98633 +
98634 + /* finished all profiles in namespace move to next namespace */
98635 + return __first_profile(root, __next_namespace(root, profile->ns));
98636 +}
98637 +
98638 +/**
98639 + * p_start - start a depth first traversal of profile tree
98640 + * @f: seq_file to fill
98641 + * @pos: current position
98642 + *
98643 + * Returns: first profile under current namespace or NULL if none found
98644 + *
98645 + * acquires first ns->lock
98646 + */
98647 +static void *p_start(struct seq_file *f, loff_t *pos)
98648 + __acquires(root->lock)
98649 +{
98650 + struct aa_profile *profile = NULL;
98651 + struct aa_namespace *root = aa_current_profile()->ns;
98652 + loff_t l = *pos;
98653 + f->private = aa_get_namespace(root);
98654 +
98655 +
98656 + /* find the first profile */
98657 + read_lock(&root->lock);
98658 + profile = __first_profile(root, root);
98659 +
98660 + /* skip to position */
98661 + for (; profile && l > 0; l--)
98662 + profile = next_profile(root, profile);
98663 +
98664 + return profile;
98665 +}
98666 +
98667 +/**
98668 + * p_next - read the next profile entry
98669 + * @f: seq_file to fill
98670 + * @p: profile previously returned
98671 + * @pos: current position
98672 + *
98673 + * Returns: next profile after @p or NULL if none
98674 + *
98675 + * may acquire/release locks in namespace tree as necessary
98676 + */
98677 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98678 +{
98679 + struct aa_profile *profile = p;
98680 + struct aa_namespace *root = f->private;
98681 + (*pos)++;
98682 +
98683 + return next_profile(root, profile);
98684 +}
98685 +
98686 +/**
98687 + * p_stop - stop depth first traversal
98688 + * @f: seq_file we are filling
98689 + * @p: the last profile writen
98690 + *
98691 + * Release all locking done by p_start/p_next on namespace tree
98692 + */
98693 +static void p_stop(struct seq_file *f, void *p)
98694 + __releases(root->lock)
98695 +{
98696 + struct aa_profile *profile = p;
98697 + struct aa_namespace *root = f->private, *ns;
98698 +
98699 + if (profile) {
98700 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98701 + read_unlock(&ns->lock);
98702 + }
98703 + read_unlock(&root->lock);
98704 + aa_put_namespace(root);
98705 +}
98706 +
98707 +/**
98708 + * seq_show_profile - show a profile entry
98709 + * @f: seq_file to file
98710 + * @p: current position (profile) (NOT NULL)
98711 + *
98712 + * Returns: error on failure
98713 + */
98714 +static int seq_show_profile(struct seq_file *f, void *p)
98715 +{
98716 + struct aa_profile *profile = (struct aa_profile *)p;
98717 + struct aa_namespace *root = f->private;
98718 +
98719 + if (profile->ns != root)
98720 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98721 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98722 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98723 +
98724 + return 0;
98725 +}
98726 +
98727 +static const struct seq_operations aa_fs_profiles_op = {
98728 + .start = p_start,
98729 + .next = p_next,
98730 + .stop = p_stop,
98731 + .show = seq_show_profile,
98732 +};
98733 +
98734 +static int profiles_open(struct inode *inode, struct file *file)
98735 +{
98736 + return seq_open(file, &aa_fs_profiles_op);
98737 +}
98738 +
98739 +static int profiles_release(struct inode *inode, struct file *file)
98740 +{
98741 + return seq_release(inode, file);
98742 +}
98743 +
98744 +const struct file_operations aa_fs_profiles_fops = {
98745 + .open = profiles_open,
98746 + .read = seq_read,
98747 + .llseek = seq_lseek,
98748 + .release = profiles_release,
98749 +};
98750 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98751 +
98752 /** Base file system setup **/
98753
98754 static struct aa_fs_entry aa_fs_entry_file[] = {
98755 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98756 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98757 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98758 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98759 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98760 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98761 +#endif
98762 AA_FS_DIR("features", aa_fs_entry_features),
98763 { }
98764 };
98765 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98766 index 2e2a0dd..a0cbc44 100644
98767 --- a/security/apparmor/lsm.c
98768 +++ b/security/apparmor/lsm.c
98769 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98770 return error;
98771 }
98772
98773 -static struct security_operations apparmor_ops = {
98774 +static struct security_operations apparmor_ops __read_only = {
98775 .name = "apparmor",
98776
98777 .ptrace_access_check = apparmor_ptrace_access_check,
98778 diff --git a/security/commoncap.c b/security/commoncap.c
98779 index c44b6fe..932df30 100644
98780 --- a/security/commoncap.c
98781 +++ b/security/commoncap.c
98782 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98783 return 0;
98784 }
98785
98786 +/* returns:
98787 + 1 for suid privilege
98788 + 2 for sgid privilege
98789 + 3 for fscap privilege
98790 +*/
98791 +int is_privileged_binary(const struct dentry *dentry)
98792 +{
98793 + struct cpu_vfs_cap_data capdata;
98794 + struct inode *inode = dentry->d_inode;
98795 +
98796 + if (!inode || S_ISDIR(inode->i_mode))
98797 + return 0;
98798 +
98799 + if (inode->i_mode & S_ISUID)
98800 + return 1;
98801 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98802 + return 2;
98803 +
98804 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98805 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98806 + return 3;
98807 + }
98808 +
98809 + return 0;
98810 +}
98811 +
98812 /*
98813 * Attempt to get the on-exec apply capability sets for an executable file from
98814 * its xattrs and, if present, apply them to the proposed credentials being
98815 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98816 const struct cred *cred = current_cred();
98817 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98818
98819 + if (gr_acl_enable_at_secure())
98820 + return 1;
98821 +
98822 if (!uid_eq(cred->uid, root_uid)) {
98823 if (bprm->cap_effective)
98824 return 1;
98825 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98826 index b3dd616..4bb17f3 100644
98827 --- a/security/integrity/ima/ima.h
98828 +++ b/security/integrity/ima/ima.h
98829 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98830 extern spinlock_t ima_queue_lock;
98831
98832 struct ima_h_table {
98833 - atomic_long_t len; /* number of stored measurements in the list */
98834 - atomic_long_t violations;
98835 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98836 + atomic_long_unchecked_t violations;
98837 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98838 };
98839 extern struct ima_h_table ima_htable;
98840 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98841 index 1c03e8f1..398a941 100644
98842 --- a/security/integrity/ima/ima_api.c
98843 +++ b/security/integrity/ima/ima_api.c
98844 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98845 int result;
98846
98847 /* can overflow, only indicator */
98848 - atomic_long_inc(&ima_htable.violations);
98849 + atomic_long_inc_unchecked(&ima_htable.violations);
98850
98851 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98852 if (!entry) {
98853 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98854 index 38477c9..87a60c7 100644
98855 --- a/security/integrity/ima/ima_fs.c
98856 +++ b/security/integrity/ima/ima_fs.c
98857 @@ -28,12 +28,12 @@
98858 static int valid_policy = 1;
98859 #define TMPBUFLEN 12
98860 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98861 - loff_t *ppos, atomic_long_t *val)
98862 + loff_t *ppos, atomic_long_unchecked_t *val)
98863 {
98864 char tmpbuf[TMPBUFLEN];
98865 ssize_t len;
98866
98867 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98868 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98869 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98870 }
98871
98872 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98873 index ff63fe0..809cd96 100644
98874 --- a/security/integrity/ima/ima_queue.c
98875 +++ b/security/integrity/ima/ima_queue.c
98876 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98877 INIT_LIST_HEAD(&qe->later);
98878 list_add_tail_rcu(&qe->later, &ima_measurements);
98879
98880 - atomic_long_inc(&ima_htable.len);
98881 + atomic_long_inc_unchecked(&ima_htable.len);
98882 key = ima_hash_key(entry->digest);
98883 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98884 return 0;
98885 diff --git a/security/keys/compat.c b/security/keys/compat.c
98886 index d65fa7f..cbfe366 100644
98887 --- a/security/keys/compat.c
98888 +++ b/security/keys/compat.c
98889 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98890 if (ret == 0)
98891 goto no_payload_free;
98892
98893 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98894 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98895 err:
98896 if (iov != iovstack)
98897 kfree(iov);
98898 diff --git a/security/keys/internal.h b/security/keys/internal.h
98899 index d4f1468..cc52f92 100644
98900 --- a/security/keys/internal.h
98901 +++ b/security/keys/internal.h
98902 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98903 extern long keyctl_invalidate_key(key_serial_t);
98904
98905 extern long keyctl_instantiate_key_common(key_serial_t,
98906 - const struct iovec *,
98907 + const struct iovec __user *,
98908 unsigned, size_t, key_serial_t);
98909
98910 /*
98911 diff --git a/security/keys/key.c b/security/keys/key.c
98912 index 8fb7c7b..ba3610d 100644
98913 --- a/security/keys/key.c
98914 +++ b/security/keys/key.c
98915 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98916
98917 atomic_set(&key->usage, 1);
98918 init_rwsem(&key->sem);
98919 - lockdep_set_class(&key->sem, &type->lock_class);
98920 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98921 key->type = type;
98922 key->user = user;
98923 key->quotalen = quotalen;
98924 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98925 struct key_type *p;
98926 int ret;
98927
98928 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98929 + pax_open_kernel();
98930 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98931 + pax_close_kernel();
98932
98933 ret = -EEXIST;
98934 down_write(&key_types_sem);
98935 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98936 }
98937
98938 /* store the type */
98939 - list_add(&ktype->link, &key_types_list);
98940 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98941
98942 pr_notice("Key type %s registered\n", ktype->name);
98943 ret = 0;
98944 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98945 void unregister_key_type(struct key_type *ktype)
98946 {
98947 down_write(&key_types_sem);
98948 - list_del_init(&ktype->link);
98949 + pax_list_del_init((struct list_head *)&ktype->link);
98950 downgrade_write(&key_types_sem);
98951 key_gc_keytype(ktype);
98952 pr_notice("Key type %s unregistered\n", ktype->name);
98953 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98954 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98955
98956 /* add the special key types */
98957 - list_add_tail(&key_type_keyring.link, &key_types_list);
98958 - list_add_tail(&key_type_dead.link, &key_types_list);
98959 - list_add_tail(&key_type_user.link, &key_types_list);
98960 - list_add_tail(&key_type_logon.link, &key_types_list);
98961 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
98962 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
98963 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
98964 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
98965
98966 /* record the root user tracking */
98967 rb_link_node(&root_key_user.node,
98968 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
98969 index 33cfd27..842fc5a 100644
98970 --- a/security/keys/keyctl.c
98971 +++ b/security/keys/keyctl.c
98972 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
98973 /*
98974 * Copy the iovec data from userspace
98975 */
98976 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98977 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
98978 unsigned ioc)
98979 {
98980 for (; ioc > 0; ioc--) {
98981 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98982 * If successful, 0 will be returned.
98983 */
98984 long keyctl_instantiate_key_common(key_serial_t id,
98985 - const struct iovec *payload_iov,
98986 + const struct iovec __user *payload_iov,
98987 unsigned ioc,
98988 size_t plen,
98989 key_serial_t ringid)
98990 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
98991 [0].iov_len = plen
98992 };
98993
98994 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
98995 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
98996 }
98997
98998 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
98999 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99000 if (ret == 0)
99001 goto no_payload_free;
99002
99003 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99004 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99005 err:
99006 if (iov != iovstack)
99007 kfree(iov);
99008 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99009 index 6ece7f2..ecdb55c 100644
99010 --- a/security/keys/keyring.c
99011 +++ b/security/keys/keyring.c
99012 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99013 ret = -EFAULT;
99014
99015 for (loop = 0; loop < klist->nkeys; loop++) {
99016 + key_serial_t serial;
99017 key = rcu_deref_link_locked(klist, loop,
99018 keyring);
99019 + serial = key->serial;
99020
99021 tmp = sizeof(key_serial_t);
99022 if (tmp > buflen)
99023 tmp = buflen;
99024
99025 - if (copy_to_user(buffer,
99026 - &key->serial,
99027 - tmp) != 0)
99028 + if (copy_to_user(buffer, &serial, tmp))
99029 goto error;
99030
99031 buflen -= tmp;
99032 diff --git a/security/min_addr.c b/security/min_addr.c
99033 index f728728..6457a0c 100644
99034 --- a/security/min_addr.c
99035 +++ b/security/min_addr.c
99036 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99037 */
99038 static void update_mmap_min_addr(void)
99039 {
99040 +#ifndef SPARC
99041 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99042 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99043 mmap_min_addr = dac_mmap_min_addr;
99044 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99045 #else
99046 mmap_min_addr = dac_mmap_min_addr;
99047 #endif
99048 +#endif
99049 }
99050
99051 /*
99052 diff --git a/security/security.c b/security/security.c
99053 index 94b35ae..f4e7751 100644
99054 --- a/security/security.c
99055 +++ b/security/security.c
99056 @@ -33,8 +33,8 @@
99057 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99058 CONFIG_DEFAULT_SECURITY;
99059
99060 -static struct security_operations *security_ops;
99061 -static struct security_operations default_security_ops = {
99062 +struct security_operations *security_ops __read_only;
99063 +struct security_operations default_security_ops __read_only = {
99064 .name = "default",
99065 };
99066
99067 @@ -73,11 +73,6 @@ int __init security_init(void)
99068 return 0;
99069 }
99070
99071 -void reset_security_ops(void)
99072 -{
99073 - security_ops = &default_security_ops;
99074 -}
99075 -
99076 /* Save user chosen LSM */
99077 static int __init choose_lsm(char *str)
99078 {
99079 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99080 index dad36a6..7e5ffbf 100644
99081 --- a/security/selinux/avc.c
99082 +++ b/security/selinux/avc.c
99083 @@ -59,7 +59,7 @@ struct avc_node {
99084 struct avc_cache {
99085 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99086 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99087 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99088 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99089 atomic_t active_nodes;
99090 u32 latest_notif; /* latest revocation notification */
99091 };
99092 @@ -167,7 +167,7 @@ void __init avc_init(void)
99093 spin_lock_init(&avc_cache.slots_lock[i]);
99094 }
99095 atomic_set(&avc_cache.active_nodes, 0);
99096 - atomic_set(&avc_cache.lru_hint, 0);
99097 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99098
99099 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99100 0, SLAB_PANIC, NULL);
99101 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99102 spinlock_t *lock;
99103
99104 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99105 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99106 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99107 head = &avc_cache.slots[hvalue];
99108 lock = &avc_cache.slots_lock[hvalue];
99109
99110 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99111 index c956390..1899f06 100644
99112 --- a/security/selinux/hooks.c
99113 +++ b/security/selinux/hooks.c
99114 @@ -97,8 +97,6 @@
99115
99116 #define NUM_SEL_MNT_OPTS 5
99117
99118 -extern struct security_operations *security_ops;
99119 -
99120 /* SECMARK reference count */
99121 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
99122
99123 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99124
99125 #endif
99126
99127 -static struct security_operations selinux_ops = {
99128 +static struct security_operations selinux_ops __read_only = {
99129 .name = "selinux",
99130
99131 .ptrace_access_check = selinux_ptrace_access_check,
99132 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
99133 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99134 static int selinux_disabled;
99135
99136 +extern struct security_operations *security_ops;
99137 +extern struct security_operations default_security_ops;
99138 +
99139 int selinux_disable(void)
99140 {
99141 if (ss_initialized) {
99142 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
99143 selinux_disabled = 1;
99144 selinux_enabled = 0;
99145
99146 - reset_security_ops();
99147 + pax_open_kernel();
99148 + security_ops = &default_security_ops;
99149 + pax_close_kernel();
99150
99151 /* Try to destroy the avc node cache */
99152 avc_disable();
99153 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99154 index 65f67cb..3f141ef 100644
99155 --- a/security/selinux/include/xfrm.h
99156 +++ b/security/selinux/include/xfrm.h
99157 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
99158
99159 static inline void selinux_xfrm_notify_policyload(void)
99160 {
99161 - atomic_inc(&flow_cache_genid);
99162 + atomic_inc_unchecked(&flow_cache_genid);
99163 rt_genid_bump(&init_net);
99164 }
99165 #else
99166 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99167 index eefbd10..9f10ddb 100644
99168 --- a/security/smack/smack_lsm.c
99169 +++ b/security/smack/smack_lsm.c
99170 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99171 return 0;
99172 }
99173
99174 -struct security_operations smack_ops = {
99175 +struct security_operations smack_ops __read_only = {
99176 .name = "smack",
99177
99178 .ptrace_access_check = smack_ptrace_access_check,
99179 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99180 index 390c646..f2f8db3 100644
99181 --- a/security/tomoyo/mount.c
99182 +++ b/security/tomoyo/mount.c
99183 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99184 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99185 need_dev = -1; /* dev_name is a directory */
99186 } else {
99187 + if (!capable(CAP_SYS_ADMIN)) {
99188 + error = -EPERM;
99189 + goto out;
99190 + }
99191 fstype = get_fs_type(type);
99192 if (!fstype) {
99193 error = -ENODEV;
99194 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99195 index f0b756e..b129202 100644
99196 --- a/security/tomoyo/tomoyo.c
99197 +++ b/security/tomoyo/tomoyo.c
99198 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99199 * tomoyo_security_ops is a "struct security_operations" which is used for
99200 * registering TOMOYO.
99201 */
99202 -static struct security_operations tomoyo_security_ops = {
99203 +static struct security_operations tomoyo_security_ops __read_only = {
99204 .name = "tomoyo",
99205 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99206 .cred_prepare = tomoyo_cred_prepare,
99207 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99208 index 20ef514..4182bed 100644
99209 --- a/security/yama/Kconfig
99210 +++ b/security/yama/Kconfig
99211 @@ -1,6 +1,6 @@
99212 config SECURITY_YAMA
99213 bool "Yama support"
99214 - depends on SECURITY
99215 + depends on SECURITY && !GRKERNSEC
99216 select SECURITYFS
99217 select SECURITY_PATH
99218 default n
99219 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99220 index 13c88fbc..f8c115e 100644
99221 --- a/security/yama/yama_lsm.c
99222 +++ b/security/yama/yama_lsm.c
99223 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99224 }
99225
99226 #ifndef CONFIG_SECURITY_YAMA_STACKED
99227 -static struct security_operations yama_ops = {
99228 +static struct security_operations yama_ops __read_only = {
99229 .name = "yama",
99230
99231 .ptrace_access_check = yama_ptrace_access_check,
99232 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99233 #endif
99234
99235 #ifdef CONFIG_SYSCTL
99236 +static int zero __read_only;
99237 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99238 +
99239 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99240 void __user *buffer, size_t *lenp, loff_t *ppos)
99241 {
99242 - int rc;
99243 + ctl_table_no_const yama_table;
99244
99245 if (write && !capable(CAP_SYS_PTRACE))
99246 return -EPERM;
99247
99248 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99249 - if (rc)
99250 - return rc;
99251 -
99252 + yama_table = *table;
99253 /* Lock the max value if it ever gets set. */
99254 - if (write && *(int *)table->data == *(int *)table->extra2)
99255 - table->extra1 = table->extra2;
99256 -
99257 - return rc;
99258 + if (ptrace_scope == max_scope)
99259 + yama_table.extra1 = &max_scope;
99260 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99261 }
99262
99263 -static int zero;
99264 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99265 -
99266 struct ctl_path yama_sysctl_path[] = {
99267 { .procname = "kernel", },
99268 { .procname = "yama", },
99269 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99270 index 4cedc69..e59d8a3 100644
99271 --- a/sound/aoa/codecs/onyx.c
99272 +++ b/sound/aoa/codecs/onyx.c
99273 @@ -54,7 +54,7 @@ struct onyx {
99274 spdif_locked:1,
99275 analog_locked:1,
99276 original_mute:2;
99277 - int open_count;
99278 + local_t open_count;
99279 struct codec_info *codec_info;
99280
99281 /* mutex serializes concurrent access to the device
99282 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99283 struct onyx *onyx = cii->codec_data;
99284
99285 mutex_lock(&onyx->mutex);
99286 - onyx->open_count++;
99287 + local_inc(&onyx->open_count);
99288 mutex_unlock(&onyx->mutex);
99289
99290 return 0;
99291 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99292 struct onyx *onyx = cii->codec_data;
99293
99294 mutex_lock(&onyx->mutex);
99295 - onyx->open_count--;
99296 - if (!onyx->open_count)
99297 + if (local_dec_and_test(&onyx->open_count))
99298 onyx->spdif_locked = onyx->analog_locked = 0;
99299 mutex_unlock(&onyx->mutex);
99300
99301 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99302 index ffd2025..df062c9 100644
99303 --- a/sound/aoa/codecs/onyx.h
99304 +++ b/sound/aoa/codecs/onyx.h
99305 @@ -11,6 +11,7 @@
99306 #include <linux/i2c.h>
99307 #include <asm/pmac_low_i2c.h>
99308 #include <asm/prom.h>
99309 +#include <asm/local.h>
99310
99311 /* PCM3052 register definitions */
99312
99313 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99314 index 4c1cc51..16040040 100644
99315 --- a/sound/core/oss/pcm_oss.c
99316 +++ b/sound/core/oss/pcm_oss.c
99317 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99318 if (in_kernel) {
99319 mm_segment_t fs;
99320 fs = snd_enter_user();
99321 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99322 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99323 snd_leave_user(fs);
99324 } else {
99325 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99326 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99327 }
99328 if (ret != -EPIPE && ret != -ESTRPIPE)
99329 break;
99330 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99331 if (in_kernel) {
99332 mm_segment_t fs;
99333 fs = snd_enter_user();
99334 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99335 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99336 snd_leave_user(fs);
99337 } else {
99338 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99339 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99340 }
99341 if (ret == -EPIPE) {
99342 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99343 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99344 struct snd_pcm_plugin_channel *channels;
99345 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99346 if (!in_kernel) {
99347 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99348 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99349 return -EFAULT;
99350 buf = runtime->oss.buffer;
99351 }
99352 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99353 }
99354 } else {
99355 tmp = snd_pcm_oss_write2(substream,
99356 - (const char __force *)buf,
99357 + (const char __force_kernel *)buf,
99358 runtime->oss.period_bytes, 0);
99359 if (tmp <= 0)
99360 goto err;
99361 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99362 struct snd_pcm_runtime *runtime = substream->runtime;
99363 snd_pcm_sframes_t frames, frames1;
99364 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99365 - char __user *final_dst = (char __force __user *)buf;
99366 + char __user *final_dst = (char __force_user *)buf;
99367 if (runtime->oss.plugin_first) {
99368 struct snd_pcm_plugin_channel *channels;
99369 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99370 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99371 xfer += tmp;
99372 runtime->oss.buffer_used -= tmp;
99373 } else {
99374 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99375 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99376 runtime->oss.period_bytes, 0);
99377 if (tmp <= 0)
99378 goto err;
99379 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99380 size1);
99381 size1 /= runtime->channels; /* frames */
99382 fs = snd_enter_user();
99383 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99384 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99385 snd_leave_user(fs);
99386 }
99387 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99388 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99389 index af49721..e85058e 100644
99390 --- a/sound/core/pcm_compat.c
99391 +++ b/sound/core/pcm_compat.c
99392 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99393 int err;
99394
99395 fs = snd_enter_user();
99396 - err = snd_pcm_delay(substream, &delay);
99397 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99398 snd_leave_user(fs);
99399 if (err < 0)
99400 return err;
99401 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99402 index a68d4c6..72af3cf 100644
99403 --- a/sound/core/pcm_native.c
99404 +++ b/sound/core/pcm_native.c
99405 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99406 switch (substream->stream) {
99407 case SNDRV_PCM_STREAM_PLAYBACK:
99408 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99409 - (void __user *)arg);
99410 + (void __force_user *)arg);
99411 break;
99412 case SNDRV_PCM_STREAM_CAPTURE:
99413 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99414 - (void __user *)arg);
99415 + (void __force_user *)arg);
99416 break;
99417 default:
99418 result = -EINVAL;
99419 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99420 index 040c60e..989a19a 100644
99421 --- a/sound/core/seq/seq_device.c
99422 +++ b/sound/core/seq/seq_device.c
99423 @@ -64,7 +64,7 @@ struct ops_list {
99424 int argsize; /* argument size */
99425
99426 /* operators */
99427 - struct snd_seq_dev_ops ops;
99428 + struct snd_seq_dev_ops *ops;
99429
99430 /* registered devices */
99431 struct list_head dev_list; /* list of devices */
99432 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99433
99434 mutex_lock(&ops->reg_mutex);
99435 /* copy driver operators */
99436 - ops->ops = *entry;
99437 + ops->ops = entry;
99438 ops->driver |= DRIVER_LOADED;
99439 ops->argsize = argsize;
99440
99441 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99442 dev->name, ops->id, ops->argsize, dev->argsize);
99443 return -EINVAL;
99444 }
99445 - if (ops->ops.init_device(dev) >= 0) {
99446 + if (ops->ops->init_device(dev) >= 0) {
99447 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99448 ops->num_init_devices++;
99449 } else {
99450 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99451 dev->name, ops->id, ops->argsize, dev->argsize);
99452 return -EINVAL;
99453 }
99454 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99455 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99456 dev->status = SNDRV_SEQ_DEVICE_FREE;
99457 dev->driver_data = NULL;
99458 ops->num_init_devices--;
99459 diff --git a/sound/core/sound.c b/sound/core/sound.c
99460 index f002bd9..c462985 100644
99461 --- a/sound/core/sound.c
99462 +++ b/sound/core/sound.c
99463 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99464 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99465 default: return;
99466 }
99467 - request_module(str);
99468 + request_module("%s", str);
99469 }
99470
99471 #endif /* modular kernel */
99472 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99473 index 4e0dd22..7a1f32c 100644
99474 --- a/sound/drivers/mts64.c
99475 +++ b/sound/drivers/mts64.c
99476 @@ -29,6 +29,7 @@
99477 #include <sound/initval.h>
99478 #include <sound/rawmidi.h>
99479 #include <sound/control.h>
99480 +#include <asm/local.h>
99481
99482 #define CARD_NAME "Miditerminal 4140"
99483 #define DRIVER_NAME "MTS64"
99484 @@ -67,7 +68,7 @@ struct mts64 {
99485 struct pardevice *pardev;
99486 int pardev_claimed;
99487
99488 - int open_count;
99489 + local_t open_count;
99490 int current_midi_output_port;
99491 int current_midi_input_port;
99492 u8 mode[MTS64_NUM_INPUT_PORTS];
99493 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99494 {
99495 struct mts64 *mts = substream->rmidi->private_data;
99496
99497 - if (mts->open_count == 0) {
99498 + if (local_read(&mts->open_count) == 0) {
99499 /* We don't need a spinlock here, because this is just called
99500 if the device has not been opened before.
99501 So there aren't any IRQs from the device */
99502 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99503
99504 msleep(50);
99505 }
99506 - ++(mts->open_count);
99507 + local_inc(&mts->open_count);
99508
99509 return 0;
99510 }
99511 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99512 struct mts64 *mts = substream->rmidi->private_data;
99513 unsigned long flags;
99514
99515 - --(mts->open_count);
99516 - if (mts->open_count == 0) {
99517 + if (local_dec_return(&mts->open_count) == 0) {
99518 /* We need the spinlock_irqsave here because we can still
99519 have IRQs at this point */
99520 spin_lock_irqsave(&mts->lock, flags);
99521 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99522
99523 msleep(500);
99524
99525 - } else if (mts->open_count < 0)
99526 - mts->open_count = 0;
99527 + } else if (local_read(&mts->open_count) < 0)
99528 + local_set(&mts->open_count, 0);
99529
99530 return 0;
99531 }
99532 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99533 index b953fb4..1999c01 100644
99534 --- a/sound/drivers/opl4/opl4_lib.c
99535 +++ b/sound/drivers/opl4/opl4_lib.c
99536 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99537 MODULE_DESCRIPTION("OPL4 driver");
99538 MODULE_LICENSE("GPL");
99539
99540 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99541 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99542 {
99543 int timeout = 10;
99544 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99545 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99546 index 991018d..8984740 100644
99547 --- a/sound/drivers/portman2x4.c
99548 +++ b/sound/drivers/portman2x4.c
99549 @@ -48,6 +48,7 @@
99550 #include <sound/initval.h>
99551 #include <sound/rawmidi.h>
99552 #include <sound/control.h>
99553 +#include <asm/local.h>
99554
99555 #define CARD_NAME "Portman 2x4"
99556 #define DRIVER_NAME "portman"
99557 @@ -85,7 +86,7 @@ struct portman {
99558 struct pardevice *pardev;
99559 int pardev_claimed;
99560
99561 - int open_count;
99562 + local_t open_count;
99563 int mode[PORTMAN_NUM_INPUT_PORTS];
99564 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99565 };
99566 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99567 index ea995af..f1bfa37 100644
99568 --- a/sound/firewire/amdtp.c
99569 +++ b/sound/firewire/amdtp.c
99570 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99571 ptr = s->pcm_buffer_pointer + data_blocks;
99572 if (ptr >= pcm->runtime->buffer_size)
99573 ptr -= pcm->runtime->buffer_size;
99574 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99575 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99576
99577 s->pcm_period_pointer += data_blocks;
99578 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99579 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99580 */
99581 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99582 {
99583 - ACCESS_ONCE(s->source_node_id_field) =
99584 + ACCESS_ONCE_RW(s->source_node_id_field) =
99585 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99586 }
99587 EXPORT_SYMBOL(amdtp_out_stream_update);
99588 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99589 index f6103d6..4843fbf 100644
99590 --- a/sound/firewire/amdtp.h
99591 +++ b/sound/firewire/amdtp.h
99592 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99593 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99594 struct snd_pcm_substream *pcm)
99595 {
99596 - ACCESS_ONCE(s->pcm) = pcm;
99597 + ACCESS_ONCE_RW(s->pcm) = pcm;
99598 }
99599
99600 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99601 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99602 index 58a5afe..af5bd64 100644
99603 --- a/sound/firewire/isight.c
99604 +++ b/sound/firewire/isight.c
99605 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99606 ptr += count;
99607 if (ptr >= runtime->buffer_size)
99608 ptr -= runtime->buffer_size;
99609 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99610 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99611
99612 isight->period_counter += count;
99613 if (isight->period_counter >= runtime->period_size) {
99614 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99615 if (err < 0)
99616 return err;
99617
99618 - ACCESS_ONCE(isight->pcm_active) = true;
99619 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99620
99621 return 0;
99622 }
99623 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99624 {
99625 struct isight *isight = substream->private_data;
99626
99627 - ACCESS_ONCE(isight->pcm_active) = false;
99628 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99629
99630 mutex_lock(&isight->mutex);
99631 isight_stop_streaming(isight);
99632 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99633
99634 switch (cmd) {
99635 case SNDRV_PCM_TRIGGER_START:
99636 - ACCESS_ONCE(isight->pcm_running) = true;
99637 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99638 break;
99639 case SNDRV_PCM_TRIGGER_STOP:
99640 - ACCESS_ONCE(isight->pcm_running) = false;
99641 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99642 break;
99643 default:
99644 return -EINVAL;
99645 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99646 index 505fc81..62e569e 100644
99647 --- a/sound/firewire/scs1x.c
99648 +++ b/sound/firewire/scs1x.c
99649 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99650 {
99651 struct scs *scs = stream->rmidi->private_data;
99652
99653 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99654 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99655 if (up) {
99656 scs->output_idle = false;
99657 tasklet_schedule(&scs->tasklet);
99658 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99659 {
99660 struct scs *scs = stream->rmidi->private_data;
99661
99662 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99663 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99664 }
99665
99666 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99667 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99668
99669 snd_card_disconnect(scs->card);
99670
99671 - ACCESS_ONCE(scs->output) = NULL;
99672 - ACCESS_ONCE(scs->input) = NULL;
99673 + ACCESS_ONCE_RW(scs->output) = NULL;
99674 + ACCESS_ONCE_RW(scs->input) = NULL;
99675
99676 wait_event(scs->idle_wait, scs->output_idle);
99677
99678 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99679 index 048439a..3be9f6f 100644
99680 --- a/sound/oss/sb_audio.c
99681 +++ b/sound/oss/sb_audio.c
99682 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99683 buf16 = (signed short *)(localbuf + localoffs);
99684 while (c)
99685 {
99686 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99687 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99688 if (copy_from_user(lbuf8,
99689 userbuf+useroffs + p,
99690 locallen))
99691 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99692 index 7d8803a..559f8d0 100644
99693 --- a/sound/oss/swarm_cs4297a.c
99694 +++ b/sound/oss/swarm_cs4297a.c
99695 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99696 {
99697 struct cs4297a_state *s;
99698 u32 pwr, id;
99699 - mm_segment_t fs;
99700 int rval;
99701 #ifndef CONFIG_BCM_CS4297A_CSWARM
99702 u64 cfg;
99703 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99704 if (!rval) {
99705 char *sb1250_duart_present;
99706
99707 +#if 0
99708 + mm_segment_t fs;
99709 fs = get_fs();
99710 set_fs(KERNEL_DS);
99711 -#if 0
99712 val = SOUND_MASK_LINE;
99713 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99714 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99715 val = initvol[i].vol;
99716 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99717 }
99718 + set_fs(fs);
99719 // cs4297a_write_ac97(s, 0x18, 0x0808);
99720 #else
99721 // cs4297a_write_ac97(s, 0x5e, 0x180);
99722 cs4297a_write_ac97(s, 0x02, 0x0808);
99723 cs4297a_write_ac97(s, 0x18, 0x0808);
99724 #endif
99725 - set_fs(fs);
99726
99727 list_add(&s->list, &cs4297a_devs);
99728
99729 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99730 index 8a005f0..4fe3059 100644
99731 --- a/sound/pci/hda/hda_codec.c
99732 +++ b/sound/pci/hda/hda_codec.c
99733 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99734 mutex_unlock(&preset_mutex);
99735
99736 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99737 - char name[32];
99738 if (!mod_requested)
99739 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99740 - codec->vendor_id);
99741 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99742 else
99743 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99744 - (codec->vendor_id >> 16) & 0xffff);
99745 - request_module(name);
99746 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99747 mod_requested++;
99748 goto again;
99749 }
99750 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99751 index 4631a23..001ae57 100644
99752 --- a/sound/pci/ymfpci/ymfpci.h
99753 +++ b/sound/pci/ymfpci/ymfpci.h
99754 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99755 spinlock_t reg_lock;
99756 spinlock_t voice_lock;
99757 wait_queue_head_t interrupt_sleep;
99758 - atomic_t interrupt_sleep_count;
99759 + atomic_unchecked_t interrupt_sleep_count;
99760 struct snd_info_entry *proc_entry;
99761 const struct firmware *dsp_microcode;
99762 const struct firmware *controller_microcode;
99763 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99764 index d591c15..8cb8f94 100644
99765 --- a/sound/pci/ymfpci/ymfpci_main.c
99766 +++ b/sound/pci/ymfpci/ymfpci_main.c
99767 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99768 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99769 break;
99770 }
99771 - if (atomic_read(&chip->interrupt_sleep_count)) {
99772 - atomic_set(&chip->interrupt_sleep_count, 0);
99773 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99774 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99775 wake_up(&chip->interrupt_sleep);
99776 }
99777 __end:
99778 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99779 continue;
99780 init_waitqueue_entry(&wait, current);
99781 add_wait_queue(&chip->interrupt_sleep, &wait);
99782 - atomic_inc(&chip->interrupt_sleep_count);
99783 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99784 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99785 remove_wait_queue(&chip->interrupt_sleep, &wait);
99786 }
99787 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99788 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99789 spin_unlock(&chip->reg_lock);
99790
99791 - if (atomic_read(&chip->interrupt_sleep_count)) {
99792 - atomic_set(&chip->interrupt_sleep_count, 0);
99793 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99794 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99795 wake_up(&chip->interrupt_sleep);
99796 }
99797 }
99798 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99799 spin_lock_init(&chip->reg_lock);
99800 spin_lock_init(&chip->voice_lock);
99801 init_waitqueue_head(&chip->interrupt_sleep);
99802 - atomic_set(&chip->interrupt_sleep_count, 0);
99803 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99804 chip->card = card;
99805 chip->pci = pci;
99806 chip->irq = -1;
99807 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99808 index 2f2d837..3e3f1f6 100644
99809 --- a/sound/soc/fsl/fsl_ssi.c
99810 +++ b/sound/soc/fsl/fsl_ssi.c
99811 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99812 {
99813 struct fsl_ssi_private *ssi_private;
99814 int ret = 0;
99815 - struct device_attribute *dev_attr = NULL;
99816 + device_attribute_no_const *dev_attr = NULL;
99817 struct device_node *np = pdev->dev.of_node;
99818 const char *p, *sprop;
99819 const uint32_t *iprop;
99820 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99821 new file mode 100644
99822 index 0000000..50f2f2f
99823 --- /dev/null
99824 +++ b/tools/gcc/.gitignore
99825 @@ -0,0 +1 @@
99826 +size_overflow_hash.h
99827 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99828 new file mode 100644
99829 index 0000000..144dbee
99830 --- /dev/null
99831 +++ b/tools/gcc/Makefile
99832 @@ -0,0 +1,45 @@
99833 +#CC := gcc
99834 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99835 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99836 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99837 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99838 +
99839 +ifeq ($(PLUGINCC),$(HOSTCC))
99840 +HOSTLIBS := hostlibs
99841 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99842 +else
99843 +HOSTLIBS := hostcxxlibs
99844 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99845 +endif
99846 +
99847 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99848 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99849 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99850 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99851 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99852 +$(HOSTLIBS)-y += colorize_plugin.so
99853 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99854 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99855 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99856 +
99857 +always := $($(HOSTLIBS)-y)
99858 +
99859 +constify_plugin-objs := constify_plugin.o
99860 +stackleak_plugin-objs := stackleak_plugin.o
99861 +kallocstat_plugin-objs := kallocstat_plugin.o
99862 +kernexec_plugin-objs := kernexec_plugin.o
99863 +checker_plugin-objs := checker_plugin.o
99864 +colorize_plugin-objs := colorize_plugin.o
99865 +size_overflow_plugin-objs := size_overflow_plugin.o
99866 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99867 +structleak_plugin-objs := structleak_plugin.o
99868 +
99869 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99870 +
99871 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99872 + cmd_build_size_overflow_hash = \
99873 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99874 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99875 + $(call if_changed,build_size_overflow_hash)
99876 +
99877 +targets += size_overflow_hash.h
99878 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99879 new file mode 100644
99880 index 0000000..22f03c0
99881 --- /dev/null
99882 +++ b/tools/gcc/checker_plugin.c
99883 @@ -0,0 +1,172 @@
99884 +/*
99885 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99886 + * Licensed under the GPL v2
99887 + *
99888 + * Note: the choice of the license means that the compilation process is
99889 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99890 + * but for the kernel it doesn't matter since it doesn't link against
99891 + * any of the gcc libraries
99892 + *
99893 + * gcc plugin to implement various sparse (source code checker) features
99894 + *
99895 + * TODO:
99896 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99897 + *
99898 + * BUGS:
99899 + * - none known
99900 + */
99901 +#include "gcc-plugin.h"
99902 +#include "config.h"
99903 +#include "system.h"
99904 +#include "coretypes.h"
99905 +#include "tree.h"
99906 +#include "tree-pass.h"
99907 +#include "flags.h"
99908 +#include "intl.h"
99909 +#include "toplev.h"
99910 +#include "plugin.h"
99911 +//#include "expr.h" where are you...
99912 +#include "diagnostic.h"
99913 +#include "plugin-version.h"
99914 +#include "tm.h"
99915 +#include "function.h"
99916 +#include "basic-block.h"
99917 +#include "gimple.h"
99918 +#include "rtl.h"
99919 +#include "emit-rtl.h"
99920 +#include "tree-flow.h"
99921 +#include "target.h"
99922 +
99923 +extern void c_register_addr_space (const char *str, addr_space_t as);
99924 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99925 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99926 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99927 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99928 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99929 +
99930 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99931 +extern rtx emit_move_insn(rtx x, rtx y);
99932 +
99933 +int plugin_is_GPL_compatible;
99934 +
99935 +static struct plugin_info checker_plugin_info = {
99936 + .version = "201111150100",
99937 + .help = NULL,
99938 +};
99939 +
99940 +#define ADDR_SPACE_KERNEL 0
99941 +#define ADDR_SPACE_FORCE_KERNEL 1
99942 +#define ADDR_SPACE_USER 2
99943 +#define ADDR_SPACE_FORCE_USER 3
99944 +#define ADDR_SPACE_IOMEM 0
99945 +#define ADDR_SPACE_FORCE_IOMEM 0
99946 +#define ADDR_SPACE_PERCPU 0
99947 +#define ADDR_SPACE_FORCE_PERCPU 0
99948 +#define ADDR_SPACE_RCU 0
99949 +#define ADDR_SPACE_FORCE_RCU 0
99950 +
99951 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99952 +{
99953 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99954 +}
99955 +
99956 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
99957 +{
99958 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
99959 +}
99960 +
99961 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
99962 +{
99963 + return default_addr_space_valid_pointer_mode(mode, as);
99964 +}
99965 +
99966 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
99967 +{
99968 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
99969 +}
99970 +
99971 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
99972 +{
99973 + return default_addr_space_legitimize_address(x, oldx, mode, as);
99974 +}
99975 +
99976 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
99977 +{
99978 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
99979 + return true;
99980 +
99981 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
99982 + return true;
99983 +
99984 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
99985 + return true;
99986 +
99987 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
99988 + return true;
99989 +
99990 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
99991 + return true;
99992 +
99993 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
99994 + return true;
99995 +
99996 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
99997 + return true;
99998 +
99999 + return subset == superset;
100000 +}
100001 +
100002 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100003 +{
100004 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100005 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100006 +
100007 + return op;
100008 +}
100009 +
100010 +static void register_checker_address_spaces(void *event_data, void *data)
100011 +{
100012 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100013 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100014 + c_register_addr_space("__user", ADDR_SPACE_USER);
100015 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100016 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100017 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100018 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100019 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100020 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100021 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100022 +
100023 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100024 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100025 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100026 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100027 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100028 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100029 + targetm.addr_space.convert = checker_addr_space_convert;
100030 +}
100031 +
100032 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100033 +{
100034 + const char * const plugin_name = plugin_info->base_name;
100035 + const int argc = plugin_info->argc;
100036 + const struct plugin_argument * const argv = plugin_info->argv;
100037 + int i;
100038 +
100039 + if (!plugin_default_version_check(version, &gcc_version)) {
100040 + error(G_("incompatible gcc/plugin versions"));
100041 + return 1;
100042 + }
100043 +
100044 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100045 +
100046 + for (i = 0; i < argc; ++i)
100047 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100048 +
100049 + if (TARGET_64BIT == 0)
100050 + return 0;
100051 +
100052 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100053 +
100054 + return 0;
100055 +}
100056 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100057 new file mode 100644
100058 index 0000000..414fe5e
100059 --- /dev/null
100060 +++ b/tools/gcc/colorize_plugin.c
100061 @@ -0,0 +1,151 @@
100062 +/*
100063 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100064 + * Licensed under the GPL v2
100065 + *
100066 + * Note: the choice of the license means that the compilation process is
100067 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100068 + * but for the kernel it doesn't matter since it doesn't link against
100069 + * any of the gcc libraries
100070 + *
100071 + * gcc plugin to colorize diagnostic output
100072 + *
100073 + */
100074 +
100075 +#include "gcc-plugin.h"
100076 +#include "config.h"
100077 +#include "system.h"
100078 +#include "coretypes.h"
100079 +#include "tree.h"
100080 +#include "tree-pass.h"
100081 +#include "flags.h"
100082 +#include "intl.h"
100083 +#include "toplev.h"
100084 +#include "plugin.h"
100085 +#include "diagnostic.h"
100086 +#include "plugin-version.h"
100087 +#include "tm.h"
100088 +
100089 +int plugin_is_GPL_compatible;
100090 +
100091 +static struct plugin_info colorize_plugin_info = {
100092 + .version = "201302112000",
100093 + .help = NULL,
100094 +};
100095 +
100096 +#define GREEN "\033[32m\033[2m"
100097 +#define LIGHTGREEN "\033[32m\033[1m"
100098 +#define YELLOW "\033[33m\033[2m"
100099 +#define LIGHTYELLOW "\033[33m\033[1m"
100100 +#define RED "\033[31m\033[2m"
100101 +#define LIGHTRED "\033[31m\033[1m"
100102 +#define BLUE "\033[34m\033[2m"
100103 +#define LIGHTBLUE "\033[34m\033[1m"
100104 +#define BRIGHT "\033[m\033[1m"
100105 +#define NORMAL "\033[m"
100106 +
100107 +static diagnostic_starter_fn old_starter;
100108 +static diagnostic_finalizer_fn old_finalizer;
100109 +
100110 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100111 +{
100112 + const char *color;
100113 + char *newprefix;
100114 +
100115 + switch (diagnostic->kind) {
100116 + case DK_NOTE:
100117 + color = LIGHTBLUE;
100118 + break;
100119 +
100120 + case DK_PEDWARN:
100121 + case DK_WARNING:
100122 + color = LIGHTYELLOW;
100123 + break;
100124 +
100125 + case DK_ERROR:
100126 + case DK_FATAL:
100127 + case DK_ICE:
100128 + case DK_PERMERROR:
100129 + case DK_SORRY:
100130 + color = LIGHTRED;
100131 + break;
100132 +
100133 + default:
100134 + color = NORMAL;
100135 + }
100136 +
100137 + old_starter(context, diagnostic);
100138 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100139 + return;
100140 + pp_destroy_prefix(context->printer);
100141 + pp_set_prefix(context->printer, newprefix);
100142 +}
100143 +
100144 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100145 +{
100146 + old_finalizer(context, diagnostic);
100147 +}
100148 +
100149 +static void colorize_arm(void)
100150 +{
100151 + old_starter = diagnostic_starter(global_dc);
100152 + old_finalizer = diagnostic_finalizer(global_dc);
100153 +
100154 + diagnostic_starter(global_dc) = start_colorize;
100155 + diagnostic_finalizer(global_dc) = finalize_colorize;
100156 +}
100157 +
100158 +static unsigned int execute_colorize_rearm(void)
100159 +{
100160 + if (diagnostic_starter(global_dc) == start_colorize)
100161 + return 0;
100162 +
100163 + colorize_arm();
100164 + return 0;
100165 +}
100166 +
100167 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100168 + .pass = {
100169 + .type = SIMPLE_IPA_PASS,
100170 + .name = "colorize_rearm",
100171 +#if BUILDING_GCC_VERSION >= 4008
100172 + .optinfo_flags = OPTGROUP_NONE,
100173 +#endif
100174 + .gate = NULL,
100175 + .execute = execute_colorize_rearm,
100176 + .sub = NULL,
100177 + .next = NULL,
100178 + .static_pass_number = 0,
100179 + .tv_id = TV_NONE,
100180 + .properties_required = 0,
100181 + .properties_provided = 0,
100182 + .properties_destroyed = 0,
100183 + .todo_flags_start = 0,
100184 + .todo_flags_finish = 0
100185 + }
100186 +};
100187 +
100188 +static void colorize_start_unit(void *gcc_data, void *user_data)
100189 +{
100190 + colorize_arm();
100191 +}
100192 +
100193 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100194 +{
100195 + const char * const plugin_name = plugin_info->base_name;
100196 + struct register_pass_info colorize_rearm_pass_info = {
100197 + .pass = &pass_ipa_colorize_rearm.pass,
100198 + .reference_pass_name = "*free_lang_data",
100199 + .ref_pass_instance_number = 1,
100200 + .pos_op = PASS_POS_INSERT_AFTER
100201 + };
100202 +
100203 + if (!plugin_default_version_check(version, &gcc_version)) {
100204 + error(G_("incompatible gcc/plugin versions"));
100205 + return 1;
100206 + }
100207 +
100208 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100209 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100210 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100211 + return 0;
100212 +}
100213 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100214 new file mode 100644
100215 index 0000000..c17312d
100216 --- /dev/null
100217 +++ b/tools/gcc/constify_plugin.c
100218 @@ -0,0 +1,560 @@
100219 +/*
100220 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100221 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100222 + * Licensed under the GPL v2, or (at your option) v3
100223 + *
100224 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100225 + *
100226 + * Homepage:
100227 + * http://www.grsecurity.net/~ephox/const_plugin/
100228 + *
100229 + * Usage:
100230 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100231 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100232 + */
100233 +
100234 +#include "gcc-plugin.h"
100235 +#include "config.h"
100236 +#include "system.h"
100237 +#include "coretypes.h"
100238 +#include "tree.h"
100239 +#include "tree-pass.h"
100240 +#include "flags.h"
100241 +#include "intl.h"
100242 +#include "toplev.h"
100243 +#include "plugin.h"
100244 +#include "diagnostic.h"
100245 +#include "plugin-version.h"
100246 +#include "tm.h"
100247 +#include "function.h"
100248 +#include "basic-block.h"
100249 +#include "gimple.h"
100250 +#include "rtl.h"
100251 +#include "emit-rtl.h"
100252 +#include "tree-flow.h"
100253 +#include "target.h"
100254 +#include "langhooks.h"
100255 +
100256 +// should come from c-tree.h if only it were installed for gcc 4.5...
100257 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100258 +
100259 +// unused type flag in all versions 4.5-4.8
100260 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100261 +
100262 +int plugin_is_GPL_compatible;
100263 +
100264 +static struct plugin_info const_plugin_info = {
100265 + .version = "201305231310",
100266 + .help = "no-constify\tturn off constification\n",
100267 +};
100268 +
100269 +typedef struct {
100270 + bool has_fptr_field;
100271 + bool has_writable_field;
100272 + bool has_do_const_field;
100273 + bool has_no_const_field;
100274 +} constify_info;
100275 +
100276 +static const_tree get_field_type(const_tree field)
100277 +{
100278 + return strip_array_types(TREE_TYPE(field));
100279 +}
100280 +
100281 +static bool is_fptr(const_tree field)
100282 +{
100283 + const_tree ptr = get_field_type(field);
100284 +
100285 + if (TREE_CODE(ptr) != POINTER_TYPE)
100286 + return false;
100287 +
100288 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100289 +}
100290 +
100291 +/*
100292 + * determine whether the given structure type meets the requirements for automatic constification,
100293 + * including the constification attributes on nested structure types
100294 + */
100295 +static void constifiable(const_tree node, constify_info *cinfo)
100296 +{
100297 + const_tree field;
100298 +
100299 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100300 +
100301 + // e.g., pointer to structure fields while still constructing the structure type
100302 + if (TYPE_FIELDS(node) == NULL_TREE)
100303 + return;
100304 +
100305 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100306 + const_tree type = get_field_type(field);
100307 + enum tree_code code = TREE_CODE(type);
100308 +
100309 + if (node == type)
100310 + continue;
100311 +
100312 + if (is_fptr(field))
100313 + cinfo->has_fptr_field = true;
100314 + else if (!TREE_READONLY(field))
100315 + cinfo->has_writable_field = true;
100316 +
100317 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100318 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100319 + cinfo->has_do_const_field = true;
100320 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100321 + cinfo->has_no_const_field = true;
100322 + else
100323 + constifiable(type, cinfo);
100324 + }
100325 + }
100326 +}
100327 +
100328 +static bool constified(const_tree node)
100329 +{
100330 + constify_info cinfo = {
100331 + .has_fptr_field = false,
100332 + .has_writable_field = false,
100333 + .has_do_const_field = false,
100334 + .has_no_const_field = false
100335 + };
100336 +
100337 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100338 +
100339 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100340 + gcc_assert(!TYPE_READONLY(node));
100341 + return false;
100342 + }
100343 +
100344 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100345 + gcc_assert(TYPE_READONLY(node));
100346 + return true;
100347 + }
100348 +
100349 + constifiable(node, &cinfo);
100350 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100351 + return false;
100352 +
100353 + return TYPE_READONLY(node);
100354 +}
100355 +
100356 +static void deconstify_tree(tree node);
100357 +
100358 +static void deconstify_type(tree type)
100359 +{
100360 + tree field;
100361 +
100362 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100363 +
100364 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100365 + const_tree fieldtype = get_field_type(field);
100366 +
100367 + // special case handling of simple ptr-to-same-array-type members
100368 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100369 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100370 +
100371 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100372 + continue;
100373 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100374 + continue;
100375 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100376 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100377 + TREE_TYPE(TREE_TYPE(field)) = type;
100378 + }
100379 + continue;
100380 + }
100381 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100382 + continue;
100383 + if (!constified(fieldtype))
100384 + continue;
100385 +
100386 + deconstify_tree(field);
100387 + TREE_READONLY(field) = 0;
100388 + }
100389 + TYPE_READONLY(type) = 0;
100390 + C_TYPE_FIELDS_READONLY(type) = 0;
100391 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100392 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100393 +}
100394 +
100395 +static void deconstify_tree(tree node)
100396 +{
100397 + tree old_type, new_type, field;
100398 +
100399 + old_type = TREE_TYPE(node);
100400 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100401 + node = TREE_TYPE(node) = copy_node(old_type);
100402 + old_type = TREE_TYPE(old_type);
100403 + }
100404 +
100405 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100406 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100407 +
100408 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100409 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100410 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100411 + DECL_FIELD_CONTEXT(field) = new_type;
100412 +
100413 + deconstify_type(new_type);
100414 +
100415 + TREE_TYPE(node) = new_type;
100416 +}
100417 +
100418 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100419 +{
100420 + tree type;
100421 + constify_info cinfo = {
100422 + .has_fptr_field = false,
100423 + .has_writable_field = false,
100424 + .has_do_const_field = false,
100425 + .has_no_const_field = false
100426 + };
100427 +
100428 + *no_add_attrs = true;
100429 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100430 + error("%qE attribute does not apply to functions", name);
100431 + return NULL_TREE;
100432 + }
100433 +
100434 + if (TREE_CODE(*node) == PARM_DECL) {
100435 + error("%qE attribute does not apply to function parameters", name);
100436 + return NULL_TREE;
100437 + }
100438 +
100439 + if (TREE_CODE(*node) == VAR_DECL) {
100440 + error("%qE attribute does not apply to variables", name);
100441 + return NULL_TREE;
100442 + }
100443 +
100444 + if (TYPE_P(*node)) {
100445 + *no_add_attrs = false;
100446 + type = *node;
100447 + } else {
100448 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100449 + type = TREE_TYPE(*node);
100450 + }
100451 +
100452 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100453 + error("%qE attribute applies to struct and union types only", name);
100454 + return NULL_TREE;
100455 + }
100456 +
100457 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100458 + error("%qE attribute is already applied to the type", name);
100459 + return NULL_TREE;
100460 + }
100461 +
100462 + if (TYPE_P(*node)) {
100463 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100464 + error("%qE attribute is incompatible with 'do_const'", name);
100465 + return NULL_TREE;
100466 + }
100467 +
100468 + constifiable(type, &cinfo);
100469 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100470 + deconstify_tree(*node);
100471 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100472 + return NULL_TREE;
100473 + }
100474 +
100475 + error("%qE attribute used on type that is not constified", name);
100476 + return NULL_TREE;
100477 +}
100478 +
100479 +static void constify_type(tree type)
100480 +{
100481 + TYPE_READONLY(type) = 1;
100482 + C_TYPE_FIELDS_READONLY(type) = 1;
100483 + TYPE_CONSTIFY_VISITED(type) = 1;
100484 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100485 +}
100486 +
100487 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100488 +{
100489 + *no_add_attrs = true;
100490 + if (!TYPE_P(*node)) {
100491 + error("%qE attribute applies to types only", name);
100492 + return NULL_TREE;
100493 + }
100494 +
100495 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100496 + error("%qE attribute applies to struct and union types only", name);
100497 + return NULL_TREE;
100498 + }
100499 +
100500 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100501 + error("%qE attribute is already applied to the type", name);
100502 + return NULL_TREE;
100503 + }
100504 +
100505 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100506 + error("%qE attribute is incompatible with 'no_const'", name);
100507 + return NULL_TREE;
100508 + }
100509 +
100510 + *no_add_attrs = false;
100511 + return NULL_TREE;
100512 +}
100513 +
100514 +static struct attribute_spec no_const_attr = {
100515 + .name = "no_const",
100516 + .min_length = 0,
100517 + .max_length = 0,
100518 + .decl_required = false,
100519 + .type_required = false,
100520 + .function_type_required = false,
100521 + .handler = handle_no_const_attribute,
100522 +#if BUILDING_GCC_VERSION >= 4007
100523 + .affects_type_identity = true
100524 +#endif
100525 +};
100526 +
100527 +static struct attribute_spec do_const_attr = {
100528 + .name = "do_const",
100529 + .min_length = 0,
100530 + .max_length = 0,
100531 + .decl_required = false,
100532 + .type_required = false,
100533 + .function_type_required = false,
100534 + .handler = handle_do_const_attribute,
100535 +#if BUILDING_GCC_VERSION >= 4007
100536 + .affects_type_identity = true
100537 +#endif
100538 +};
100539 +
100540 +static void register_attributes(void *event_data, void *data)
100541 +{
100542 + register_attribute(&no_const_attr);
100543 + register_attribute(&do_const_attr);
100544 +}
100545 +
100546 +static void finish_type(void *event_data, void *data)
100547 +{
100548 + tree type = (tree)event_data;
100549 + constify_info cinfo = {
100550 + .has_fptr_field = false,
100551 + .has_writable_field = false,
100552 + .has_do_const_field = false,
100553 + .has_no_const_field = false
100554 + };
100555 +
100556 + if (type == NULL_TREE || type == error_mark_node)
100557 + return;
100558 +
100559 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100560 + return;
100561 +
100562 + constifiable(type, &cinfo);
100563 +
100564 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100565 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100566 + return;
100567 + if (cinfo.has_writable_field)
100568 + return;
100569 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100570 + return;
100571 + }
100572 +
100573 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100574 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100575 + deconstify_type(type);
100576 + TYPE_CONSTIFY_VISITED(type) = 1;
100577 + } else
100578 + error("'no_const' attribute used on type that is not constified");
100579 + return;
100580 + }
100581 +
100582 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100583 + constify_type(type);
100584 + return;
100585 + }
100586 +
100587 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100588 + constify_type(type);
100589 + return;
100590 + }
100591 +
100592 + deconstify_type(type);
100593 + TYPE_CONSTIFY_VISITED(type) = 1;
100594 +}
100595 +
100596 +static void check_global_variables(void)
100597 +{
100598 + struct varpool_node *node;
100599 +
100600 +#if BUILDING_GCC_VERSION <= 4007
100601 + for (node = varpool_nodes; node; node = node->next) {
100602 + tree var = node->decl;
100603 +#else
100604 + FOR_EACH_VARIABLE(node) {
100605 + tree var = node->symbol.decl;
100606 +#endif
100607 + tree type = TREE_TYPE(var);
100608 +
100609 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100610 + continue;
100611 +
100612 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100613 + continue;
100614 +
100615 + if (!TYPE_CONSTIFY_VISITED(type))
100616 + continue;
100617 +
100618 + if (DECL_EXTERNAL(var))
100619 + continue;
100620 +
100621 + if (DECL_INITIAL(var))
100622 + continue;
100623 +
100624 + // this works around a gcc bug/feature where uninitialized globals
100625 + // are moved into the .bss section regardless of any constification
100626 + DECL_INITIAL(var) = build_constructor(type, NULL);
100627 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100628 + }
100629 +}
100630 +
100631 +static unsigned int check_local_variables(void)
100632 +{
100633 + unsigned int ret = 0;
100634 + tree var;
100635 +
100636 +#if BUILDING_GCC_VERSION == 4005
100637 + tree vars;
100638 +#else
100639 + unsigned int i;
100640 +#endif
100641 +
100642 +#if BUILDING_GCC_VERSION == 4005
100643 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100644 + var = TREE_VALUE(vars);
100645 +#else
100646 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100647 +#endif
100648 + tree type = TREE_TYPE(var);
100649 +
100650 + gcc_assert(DECL_P(var));
100651 + if (is_global_var(var))
100652 + continue;
100653 +
100654 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100655 + continue;
100656 +
100657 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100658 + continue;
100659 +
100660 + if (!TYPE_CONSTIFY_VISITED(type))
100661 + continue;
100662 +
100663 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100664 + ret = 1;
100665 + }
100666 + return ret;
100667 +}
100668 +
100669 +static unsigned int check_variables(void)
100670 +{
100671 + check_global_variables();
100672 + return check_local_variables();
100673 +}
100674 +
100675 + unsigned int ret = 0;
100676 +static struct gimple_opt_pass pass_local_variable = {
100677 + {
100678 + .type = GIMPLE_PASS,
100679 + .name = "check_variables",
100680 +#if BUILDING_GCC_VERSION >= 4008
100681 + .optinfo_flags = OPTGROUP_NONE,
100682 +#endif
100683 + .gate = NULL,
100684 + .execute = check_variables,
100685 + .sub = NULL,
100686 + .next = NULL,
100687 + .static_pass_number = 0,
100688 + .tv_id = TV_NONE,
100689 + .properties_required = 0,
100690 + .properties_provided = 0,
100691 + .properties_destroyed = 0,
100692 + .todo_flags_start = 0,
100693 + .todo_flags_finish = 0
100694 + }
100695 +};
100696 +
100697 +static struct {
100698 + const char *name;
100699 + const char *asm_op;
100700 +} sections[] = {
100701 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100702 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100703 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100704 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100705 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100706 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100707 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100708 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100709 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100710 +};
100711 +
100712 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100713 +
100714 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100715 +{
100716 + size_t i;
100717 +
100718 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100719 + if (!strcmp(sections[i].name, name))
100720 + return 0;
100721 + return old_section_type_flags(decl, name, reloc);
100722 +}
100723 +
100724 +static void constify_start_unit(void *gcc_data, void *user_data)
100725 +{
100726 +// size_t i;
100727 +
100728 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100729 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100730 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100731 +
100732 + old_section_type_flags = targetm.section_type_flags;
100733 + targetm.section_type_flags = constify_section_type_flags;
100734 +}
100735 +
100736 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100737 +{
100738 + const char * const plugin_name = plugin_info->base_name;
100739 + const int argc = plugin_info->argc;
100740 + const struct plugin_argument * const argv = plugin_info->argv;
100741 + int i;
100742 + bool constify = true;
100743 +
100744 + struct register_pass_info local_variable_pass_info = {
100745 + .pass = &pass_local_variable.pass,
100746 + .reference_pass_name = "ssa",
100747 + .ref_pass_instance_number = 1,
100748 + .pos_op = PASS_POS_INSERT_BEFORE
100749 + };
100750 +
100751 + if (!plugin_default_version_check(version, &gcc_version)) {
100752 + error(G_("incompatible gcc/plugin versions"));
100753 + return 1;
100754 + }
100755 +
100756 + for (i = 0; i < argc; ++i) {
100757 + if (!(strcmp(argv[i].key, "no-constify"))) {
100758 + constify = false;
100759 + continue;
100760 + }
100761 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100762 + }
100763 +
100764 + if (strcmp(lang_hooks.name, "GNU C")) {
100765 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100766 + constify = false;
100767 + }
100768 +
100769 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100770 + if (constify) {
100771 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100772 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100773 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100774 + }
100775 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100776 +
100777 + return 0;
100778 +}
100779 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100780 new file mode 100644
100781 index 0000000..e518932
100782 --- /dev/null
100783 +++ b/tools/gcc/generate_size_overflow_hash.sh
100784 @@ -0,0 +1,94 @@
100785 +#!/bin/bash
100786 +
100787 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100788 +
100789 +header1="size_overflow_hash.h"
100790 +database="size_overflow_hash.data"
100791 +n=65536
100792 +
100793 +usage() {
100794 +cat <<EOF
100795 +usage: $0 options
100796 +OPTIONS:
100797 + -h|--help help
100798 + -o header file
100799 + -d database file
100800 + -n hash array size
100801 +EOF
100802 + return 0
100803 +}
100804 +
100805 +while true
100806 +do
100807 + case "$1" in
100808 + -h|--help) usage && exit 0;;
100809 + -n) n=$2; shift 2;;
100810 + -o) header1="$2"; shift 2;;
100811 + -d) database="$2"; shift 2;;
100812 + --) shift 1; break ;;
100813 + *) break ;;
100814 + esac
100815 +done
100816 +
100817 +create_defines() {
100818 + for i in `seq 0 31`
100819 + do
100820 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100821 + done
100822 + echo >> "$header1"
100823 +}
100824 +
100825 +create_structs() {
100826 + rm -f "$header1"
100827 +
100828 + create_defines
100829 +
100830 + cat "$database" | while read data
100831 + do
100832 + data_array=($data)
100833 + struct_hash_name="${data_array[0]}"
100834 + funcn="${data_array[1]}"
100835 + params="${data_array[2]}"
100836 + next="${data_array[4]}"
100837 +
100838 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100839 +
100840 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100841 + echo -en "\t.param\t= " >> "$header1"
100842 + line=
100843 + for param_num in ${params//-/ };
100844 + do
100845 + line="${line}PARAM"$param_num"|"
100846 + done
100847 +
100848 + echo -e "${line%?},\n};\n" >> "$header1"
100849 + done
100850 +}
100851 +
100852 +create_headers() {
100853 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100854 +}
100855 +
100856 +create_array_elements() {
100857 + index=0
100858 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100859 + do
100860 + data_array=($data)
100861 + i="${data_array[3]}"
100862 + hash="${data_array[0]}"
100863 + while [[ $index -lt $i ]]
100864 + do
100865 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100866 + index=$(($index + 1))
100867 + done
100868 + index=$(($index + 1))
100869 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100870 + done
100871 + echo '};' >> $header1
100872 +}
100873 +
100874 +create_structs
100875 +create_headers
100876 +create_array_elements
100877 +
100878 +exit 0
100879 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100880 new file mode 100644
100881 index 0000000..568b360
100882 --- /dev/null
100883 +++ b/tools/gcc/kallocstat_plugin.c
100884 @@ -0,0 +1,170 @@
100885 +/*
100886 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100887 + * Licensed under the GPL v2
100888 + *
100889 + * Note: the choice of the license means that the compilation process is
100890 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100891 + * but for the kernel it doesn't matter since it doesn't link against
100892 + * any of the gcc libraries
100893 + *
100894 + * gcc plugin to find the distribution of k*alloc sizes
100895 + *
100896 + * TODO:
100897 + *
100898 + * BUGS:
100899 + * - none known
100900 + */
100901 +#include "gcc-plugin.h"
100902 +#include "config.h"
100903 +#include "system.h"
100904 +#include "coretypes.h"
100905 +#include "tree.h"
100906 +#include "tree-pass.h"
100907 +#include "flags.h"
100908 +#include "intl.h"
100909 +#include "toplev.h"
100910 +#include "plugin.h"
100911 +//#include "expr.h" where are you...
100912 +#include "diagnostic.h"
100913 +#include "plugin-version.h"
100914 +#include "tm.h"
100915 +#include "function.h"
100916 +#include "basic-block.h"
100917 +#include "gimple.h"
100918 +#include "rtl.h"
100919 +#include "emit-rtl.h"
100920 +
100921 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100922 +
100923 +int plugin_is_GPL_compatible;
100924 +
100925 +static const char * const kalloc_functions[] = {
100926 + "__kmalloc",
100927 + "kmalloc",
100928 + "kmalloc_large",
100929 + "kmalloc_node",
100930 + "kmalloc_order",
100931 + "kmalloc_order_trace",
100932 + "kmalloc_slab",
100933 + "kzalloc",
100934 + "kzalloc_node",
100935 +};
100936 +
100937 +static struct plugin_info kallocstat_plugin_info = {
100938 + .version = "201302112000",
100939 +};
100940 +
100941 +static unsigned int execute_kallocstat(void);
100942 +
100943 +static struct gimple_opt_pass kallocstat_pass = {
100944 + .pass = {
100945 + .type = GIMPLE_PASS,
100946 + .name = "kallocstat",
100947 +#if BUILDING_GCC_VERSION >= 4008
100948 + .optinfo_flags = OPTGROUP_NONE,
100949 +#endif
100950 + .gate = NULL,
100951 + .execute = execute_kallocstat,
100952 + .sub = NULL,
100953 + .next = NULL,
100954 + .static_pass_number = 0,
100955 + .tv_id = TV_NONE,
100956 + .properties_required = 0,
100957 + .properties_provided = 0,
100958 + .properties_destroyed = 0,
100959 + .todo_flags_start = 0,
100960 + .todo_flags_finish = 0
100961 + }
100962 +};
100963 +
100964 +static bool is_kalloc(const char *fnname)
100965 +{
100966 + size_t i;
100967 +
100968 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
100969 + if (!strcmp(fnname, kalloc_functions[i]))
100970 + return true;
100971 + return false;
100972 +}
100973 +
100974 +static unsigned int execute_kallocstat(void)
100975 +{
100976 + basic_block bb;
100977 +
100978 + // 1. loop through BBs and GIMPLE statements
100979 + FOR_EACH_BB(bb) {
100980 + gimple_stmt_iterator gsi;
100981 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100982 + // gimple match:
100983 + tree fndecl, size;
100984 + gimple call_stmt;
100985 + const char *fnname;
100986 +
100987 + // is it a call
100988 + call_stmt = gsi_stmt(gsi);
100989 + if (!is_gimple_call(call_stmt))
100990 + continue;
100991 + fndecl = gimple_call_fndecl(call_stmt);
100992 + if (fndecl == NULL_TREE)
100993 + continue;
100994 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
100995 + continue;
100996 +
100997 + // is it a call to k*alloc
100998 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
100999 + if (!is_kalloc(fnname))
101000 + continue;
101001 +
101002 + // is the size arg the result of a simple const assignment
101003 + size = gimple_call_arg(call_stmt, 0);
101004 + while (true) {
101005 + gimple def_stmt;
101006 + expanded_location xloc;
101007 + size_t size_val;
101008 +
101009 + if (TREE_CODE(size) != SSA_NAME)
101010 + break;
101011 + def_stmt = SSA_NAME_DEF_STMT(size);
101012 + if (!def_stmt || !is_gimple_assign(def_stmt))
101013 + break;
101014 + if (gimple_num_ops(def_stmt) != 2)
101015 + break;
101016 + size = gimple_assign_rhs1(def_stmt);
101017 + if (!TREE_CONSTANT(size))
101018 + continue;
101019 + xloc = expand_location(gimple_location(def_stmt));
101020 + if (!xloc.file)
101021 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101022 + size_val = TREE_INT_CST_LOW(size);
101023 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101024 + break;
101025 + }
101026 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101027 +//debug_tree(gimple_call_fn(call_stmt));
101028 +//print_node(stderr, "pax", fndecl, 4);
101029 + }
101030 + }
101031 +
101032 + return 0;
101033 +}
101034 +
101035 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101036 +{
101037 + const char * const plugin_name = plugin_info->base_name;
101038 + struct register_pass_info kallocstat_pass_info = {
101039 + .pass = &kallocstat_pass.pass,
101040 + .reference_pass_name = "ssa",
101041 + .ref_pass_instance_number = 1,
101042 + .pos_op = PASS_POS_INSERT_AFTER
101043 + };
101044 +
101045 + if (!plugin_default_version_check(version, &gcc_version)) {
101046 + error(G_("incompatible gcc/plugin versions"));
101047 + return 1;
101048 + }
101049 +
101050 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101051 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101052 +
101053 + return 0;
101054 +}
101055 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101056 new file mode 100644
101057 index 0000000..698da67
101058 --- /dev/null
101059 +++ b/tools/gcc/kernexec_plugin.c
101060 @@ -0,0 +1,471 @@
101061 +/*
101062 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101063 + * Licensed under the GPL v2
101064 + *
101065 + * Note: the choice of the license means that the compilation process is
101066 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101067 + * but for the kernel it doesn't matter since it doesn't link against
101068 + * any of the gcc libraries
101069 + *
101070 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101071 + *
101072 + * TODO:
101073 + *
101074 + * BUGS:
101075 + * - none known
101076 + */
101077 +#include "gcc-plugin.h"
101078 +#include "config.h"
101079 +#include "system.h"
101080 +#include "coretypes.h"
101081 +#include "tree.h"
101082 +#include "tree-pass.h"
101083 +#include "flags.h"
101084 +#include "intl.h"
101085 +#include "toplev.h"
101086 +#include "plugin.h"
101087 +//#include "expr.h" where are you...
101088 +#include "diagnostic.h"
101089 +#include "plugin-version.h"
101090 +#include "tm.h"
101091 +#include "function.h"
101092 +#include "basic-block.h"
101093 +#include "gimple.h"
101094 +#include "rtl.h"
101095 +#include "emit-rtl.h"
101096 +#include "tree-flow.h"
101097 +
101098 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101099 +extern rtx emit_move_insn(rtx x, rtx y);
101100 +
101101 +#if BUILDING_GCC_VERSION <= 4006
101102 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101103 +#endif
101104 +
101105 +#if BUILDING_GCC_VERSION >= 4008
101106 +#define TODO_dump_func 0
101107 +#endif
101108 +
101109 +int plugin_is_GPL_compatible;
101110 +
101111 +static struct plugin_info kernexec_plugin_info = {
101112 + .version = "201308230150",
101113 + .help = "method=[bts|or]\tinstrumentation method\n"
101114 +};
101115 +
101116 +static unsigned int execute_kernexec_reload(void);
101117 +static unsigned int execute_kernexec_fptr(void);
101118 +static unsigned int execute_kernexec_retaddr(void);
101119 +static bool kernexec_cmodel_check(void);
101120 +
101121 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101122 +static void (*kernexec_instrument_retaddr)(rtx);
101123 +
101124 +static struct gimple_opt_pass kernexec_reload_pass = {
101125 + .pass = {
101126 + .type = GIMPLE_PASS,
101127 + .name = "kernexec_reload",
101128 +#if BUILDING_GCC_VERSION >= 4008
101129 + .optinfo_flags = OPTGROUP_NONE,
101130 +#endif
101131 + .gate = kernexec_cmodel_check,
101132 + .execute = execute_kernexec_reload,
101133 + .sub = NULL,
101134 + .next = NULL,
101135 + .static_pass_number = 0,
101136 + .tv_id = TV_NONE,
101137 + .properties_required = 0,
101138 + .properties_provided = 0,
101139 + .properties_destroyed = 0,
101140 + .todo_flags_start = 0,
101141 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101142 + }
101143 +};
101144 +
101145 +static struct gimple_opt_pass kernexec_fptr_pass = {
101146 + .pass = {
101147 + .type = GIMPLE_PASS,
101148 + .name = "kernexec_fptr",
101149 +#if BUILDING_GCC_VERSION >= 4008
101150 + .optinfo_flags = OPTGROUP_NONE,
101151 +#endif
101152 + .gate = kernexec_cmodel_check,
101153 + .execute = execute_kernexec_fptr,
101154 + .sub = NULL,
101155 + .next = NULL,
101156 + .static_pass_number = 0,
101157 + .tv_id = TV_NONE,
101158 + .properties_required = 0,
101159 + .properties_provided = 0,
101160 + .properties_destroyed = 0,
101161 + .todo_flags_start = 0,
101162 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101163 + }
101164 +};
101165 +
101166 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101167 + .pass = {
101168 + .type = RTL_PASS,
101169 + .name = "kernexec_retaddr",
101170 +#if BUILDING_GCC_VERSION >= 4008
101171 + .optinfo_flags = OPTGROUP_NONE,
101172 +#endif
101173 + .gate = kernexec_cmodel_check,
101174 + .execute = execute_kernexec_retaddr,
101175 + .sub = NULL,
101176 + .next = NULL,
101177 + .static_pass_number = 0,
101178 + .tv_id = TV_NONE,
101179 + .properties_required = 0,
101180 + .properties_provided = 0,
101181 + .properties_destroyed = 0,
101182 + .todo_flags_start = 0,
101183 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101184 + }
101185 +};
101186 +
101187 +static bool kernexec_cmodel_check(void)
101188 +{
101189 + tree section;
101190 +
101191 + if (ix86_cmodel != CM_KERNEL)
101192 + return false;
101193 +
101194 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101195 + if (!section || !TREE_VALUE(section))
101196 + return true;
101197 +
101198 + section = TREE_VALUE(TREE_VALUE(section));
101199 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101200 + return true;
101201 +
101202 + return false;
101203 +}
101204 +
101205 +/*
101206 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101207 + */
101208 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101209 +{
101210 + gimple asm_movabs_stmt;
101211 +
101212 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101213 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101214 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101215 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101216 + update_stmt(asm_movabs_stmt);
101217 +}
101218 +
101219 +/*
101220 + * find all asm() stmts that clobber r10 and add a reload of r10
101221 + */
101222 +static unsigned int execute_kernexec_reload(void)
101223 +{
101224 + basic_block bb;
101225 +
101226 + // 1. loop through BBs and GIMPLE statements
101227 + FOR_EACH_BB(bb) {
101228 + gimple_stmt_iterator gsi;
101229 +
101230 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101231 + // gimple match: __asm__ ("" : : : "r10");
101232 + gimple asm_stmt;
101233 + size_t nclobbers;
101234 +
101235 + // is it an asm ...
101236 + asm_stmt = gsi_stmt(gsi);
101237 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101238 + continue;
101239 +
101240 + // ... clobbering r10
101241 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101242 + while (nclobbers--) {
101243 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101244 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101245 + continue;
101246 + kernexec_reload_fptr_mask(&gsi);
101247 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101248 + break;
101249 + }
101250 + }
101251 + }
101252 +
101253 + return 0;
101254 +}
101255 +
101256 +/*
101257 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101258 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101259 + */
101260 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101261 +{
101262 + gimple assign_intptr, assign_new_fptr, call_stmt;
101263 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101264 +
101265 + call_stmt = gsi_stmt(*gsi);
101266 + old_fptr = gimple_call_fn(call_stmt);
101267 +
101268 + // create temporary unsigned long variable used for bitops and cast fptr to it
101269 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101270 +#if BUILDING_GCC_VERSION <= 4007
101271 + add_referenced_var(intptr);
101272 +#endif
101273 + intptr = make_ssa_name(intptr, NULL);
101274 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101275 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101276 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101277 + update_stmt(assign_intptr);
101278 +
101279 + // apply logical or to temporary unsigned long and bitmask
101280 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101281 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101282 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101283 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101284 + assign_intptr = gimple_build_assign(intptr, orptr);
101285 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101286 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101287 + update_stmt(assign_intptr);
101288 +
101289 + // cast temporary unsigned long back to a temporary fptr variable
101290 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101291 +#if BUILDING_GCC_VERSION <= 4007
101292 + add_referenced_var(new_fptr);
101293 +#endif
101294 + new_fptr = make_ssa_name(new_fptr, NULL);
101295 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101296 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101297 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101298 + update_stmt(assign_new_fptr);
101299 +
101300 + // replace call stmt fn with the new fptr
101301 + gimple_call_set_fn(call_stmt, new_fptr);
101302 + update_stmt(call_stmt);
101303 +}
101304 +
101305 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101306 +{
101307 + gimple asm_or_stmt, call_stmt;
101308 + tree old_fptr, new_fptr, input, output;
101309 +#if BUILDING_GCC_VERSION <= 4007
101310 + VEC(tree, gc) *inputs = NULL;
101311 + VEC(tree, gc) *outputs = NULL;
101312 +#else
101313 + vec<tree, va_gc> *inputs = NULL;
101314 + vec<tree, va_gc> *outputs = NULL;
101315 +#endif
101316 +
101317 + call_stmt = gsi_stmt(*gsi);
101318 + old_fptr = gimple_call_fn(call_stmt);
101319 +
101320 + // create temporary fptr variable
101321 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101322 +#if BUILDING_GCC_VERSION <= 4007
101323 + add_referenced_var(new_fptr);
101324 +#endif
101325 + new_fptr = make_ssa_name(new_fptr, NULL);
101326 +
101327 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101328 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101329 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101330 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101331 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101332 +#if BUILDING_GCC_VERSION <= 4007
101333 + VEC_safe_push(tree, gc, inputs, input);
101334 + VEC_safe_push(tree, gc, outputs, output);
101335 +#else
101336 + vec_safe_push(inputs, input);
101337 + vec_safe_push(outputs, output);
101338 +#endif
101339 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101340 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101341 + gimple_asm_set_volatile(asm_or_stmt, true);
101342 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101343 + update_stmt(asm_or_stmt);
101344 +
101345 + // replace call stmt fn with the new fptr
101346 + gimple_call_set_fn(call_stmt, new_fptr);
101347 + update_stmt(call_stmt);
101348 +}
101349 +
101350 +/*
101351 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101352 + */
101353 +static unsigned int execute_kernexec_fptr(void)
101354 +{
101355 + basic_block bb;
101356 +
101357 + // 1. loop through BBs and GIMPLE statements
101358 + FOR_EACH_BB(bb) {
101359 + gimple_stmt_iterator gsi;
101360 +
101361 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101362 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101363 + tree fn;
101364 + gimple call_stmt;
101365 +
101366 + // is it a call ...
101367 + call_stmt = gsi_stmt(gsi);
101368 + if (!is_gimple_call(call_stmt))
101369 + continue;
101370 + fn = gimple_call_fn(call_stmt);
101371 + if (TREE_CODE(fn) == ADDR_EXPR)
101372 + continue;
101373 + if (TREE_CODE(fn) != SSA_NAME)
101374 + gcc_unreachable();
101375 +
101376 + // ... through a function pointer
101377 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101378 + fn = SSA_NAME_VAR(fn);
101379 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101380 + debug_tree(fn);
101381 + gcc_unreachable();
101382 + }
101383 + }
101384 + fn = TREE_TYPE(fn);
101385 + if (TREE_CODE(fn) != POINTER_TYPE)
101386 + continue;
101387 + fn = TREE_TYPE(fn);
101388 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101389 + continue;
101390 +
101391 + kernexec_instrument_fptr(&gsi);
101392 +
101393 +//debug_tree(gimple_call_fn(call_stmt));
101394 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101395 + }
101396 + }
101397 +
101398 + return 0;
101399 +}
101400 +
101401 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101402 +static void kernexec_instrument_retaddr_bts(rtx insn)
101403 +{
101404 + rtx btsq;
101405 + rtvec argvec, constraintvec, labelvec;
101406 + int line;
101407 +
101408 + // create asm volatile("btsq $63,(%%rsp)":::)
101409 + argvec = rtvec_alloc(0);
101410 + constraintvec = rtvec_alloc(0);
101411 + labelvec = rtvec_alloc(0);
101412 + line = expand_location(RTL_LOCATION(insn)).line;
101413 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101414 + MEM_VOLATILE_P(btsq) = 1;
101415 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101416 + emit_insn_before(btsq, insn);
101417 +}
101418 +
101419 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101420 +static void kernexec_instrument_retaddr_or(rtx insn)
101421 +{
101422 + rtx orq;
101423 + rtvec argvec, constraintvec, labelvec;
101424 + int line;
101425 +
101426 + // create asm volatile("orq %%r10,(%%rsp)":::)
101427 + argvec = rtvec_alloc(0);
101428 + constraintvec = rtvec_alloc(0);
101429 + labelvec = rtvec_alloc(0);
101430 + line = expand_location(RTL_LOCATION(insn)).line;
101431 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101432 + MEM_VOLATILE_P(orq) = 1;
101433 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101434 + emit_insn_before(orq, insn);
101435 +}
101436 +
101437 +/*
101438 + * find all asm level function returns and forcibly set the highest bit of the return address
101439 + */
101440 +static unsigned int execute_kernexec_retaddr(void)
101441 +{
101442 + rtx insn;
101443 +
101444 + // 1. find function returns
101445 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101446 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101447 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101448 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101449 + rtx body;
101450 +
101451 + // is it a retn
101452 + if (!JUMP_P(insn))
101453 + continue;
101454 + body = PATTERN(insn);
101455 + if (GET_CODE(body) == PARALLEL)
101456 + body = XVECEXP(body, 0, 0);
101457 + if (!ANY_RETURN_P(body))
101458 + continue;
101459 + kernexec_instrument_retaddr(insn);
101460 + }
101461 +
101462 +// print_simple_rtl(stderr, get_insns());
101463 +// print_rtl(stderr, get_insns());
101464 +
101465 + return 0;
101466 +}
101467 +
101468 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101469 +{
101470 + const char * const plugin_name = plugin_info->base_name;
101471 + const int argc = plugin_info->argc;
101472 + const struct plugin_argument * const argv = plugin_info->argv;
101473 + int i;
101474 + struct register_pass_info kernexec_reload_pass_info = {
101475 + .pass = &kernexec_reload_pass.pass,
101476 + .reference_pass_name = "ssa",
101477 + .ref_pass_instance_number = 1,
101478 + .pos_op = PASS_POS_INSERT_AFTER
101479 + };
101480 + struct register_pass_info kernexec_fptr_pass_info = {
101481 + .pass = &kernexec_fptr_pass.pass,
101482 + .reference_pass_name = "ssa",
101483 + .ref_pass_instance_number = 1,
101484 + .pos_op = PASS_POS_INSERT_AFTER
101485 + };
101486 + struct register_pass_info kernexec_retaddr_pass_info = {
101487 + .pass = &kernexec_retaddr_pass.pass,
101488 + .reference_pass_name = "pro_and_epilogue",
101489 + .ref_pass_instance_number = 1,
101490 + .pos_op = PASS_POS_INSERT_AFTER
101491 + };
101492 +
101493 + if (!plugin_default_version_check(version, &gcc_version)) {
101494 + error(G_("incompatible gcc/plugin versions"));
101495 + return 1;
101496 + }
101497 +
101498 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101499 +
101500 + if (TARGET_64BIT == 0)
101501 + return 0;
101502 +
101503 + for (i = 0; i < argc; ++i) {
101504 + if (!strcmp(argv[i].key, "method")) {
101505 + if (!argv[i].value) {
101506 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101507 + continue;
101508 + }
101509 + if (!strcmp(argv[i].value, "bts")) {
101510 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101511 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101512 + } else if (!strcmp(argv[i].value, "or")) {
101513 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101514 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101515 + fix_register("r10", 1, 1);
101516 + } else
101517 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101518 + continue;
101519 + }
101520 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101521 + }
101522 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101523 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101524 +
101525 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101526 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101527 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101528 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101529 +
101530 + return 0;
101531 +}
101532 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101533 new file mode 100644
101534 index 0000000..cd6c242
101535 --- /dev/null
101536 +++ b/tools/gcc/latent_entropy_plugin.c
101537 @@ -0,0 +1,321 @@
101538 +/*
101539 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101540 + * Licensed under the GPL v2
101541 + *
101542 + * Note: the choice of the license means that the compilation process is
101543 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101544 + * but for the kernel it doesn't matter since it doesn't link against
101545 + * any of the gcc libraries
101546 + *
101547 + * gcc plugin to help generate a little bit of entropy from program state,
101548 + * used during boot in the kernel
101549 + *
101550 + * TODO:
101551 + * - add ipa pass to identify not explicitly marked candidate functions
101552 + * - mix in more program state (function arguments/return values, loop variables, etc)
101553 + * - more instrumentation control via attribute parameters
101554 + *
101555 + * BUGS:
101556 + * - LTO needs -flto-partition=none for now
101557 + */
101558 +#include "gcc-plugin.h"
101559 +#include "config.h"
101560 +#include "system.h"
101561 +#include "coretypes.h"
101562 +#include "tree.h"
101563 +#include "tree-pass.h"
101564 +#include "flags.h"
101565 +#include "intl.h"
101566 +#include "toplev.h"
101567 +#include "plugin.h"
101568 +//#include "expr.h" where are you...
101569 +#include "diagnostic.h"
101570 +#include "plugin-version.h"
101571 +#include "tm.h"
101572 +#include "function.h"
101573 +#include "basic-block.h"
101574 +#include "gimple.h"
101575 +#include "rtl.h"
101576 +#include "emit-rtl.h"
101577 +#include "tree-flow.h"
101578 +#include "langhooks.h"
101579 +
101580 +#if BUILDING_GCC_VERSION >= 4008
101581 +#define TODO_dump_func 0
101582 +#endif
101583 +
101584 +int plugin_is_GPL_compatible;
101585 +
101586 +static tree latent_entropy_decl;
101587 +
101588 +static struct plugin_info latent_entropy_plugin_info = {
101589 + .version = "201308230230",
101590 + .help = NULL
101591 +};
101592 +
101593 +static unsigned int execute_latent_entropy(void);
101594 +static bool gate_latent_entropy(void);
101595 +
101596 +static struct gimple_opt_pass latent_entropy_pass = {
101597 + .pass = {
101598 + .type = GIMPLE_PASS,
101599 + .name = "latent_entropy",
101600 +#if BUILDING_GCC_VERSION >= 4008
101601 + .optinfo_flags = OPTGROUP_NONE,
101602 +#endif
101603 + .gate = gate_latent_entropy,
101604 + .execute = execute_latent_entropy,
101605 + .sub = NULL,
101606 + .next = NULL,
101607 + .static_pass_number = 0,
101608 + .tv_id = TV_NONE,
101609 + .properties_required = PROP_gimple_leh | PROP_cfg,
101610 + .properties_provided = 0,
101611 + .properties_destroyed = 0,
101612 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101613 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101614 + }
101615 +};
101616 +
101617 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101618 +{
101619 + if (TREE_CODE(*node) != FUNCTION_DECL) {
101620 + *no_add_attrs = true;
101621 + error("%qE attribute only applies to functions", name);
101622 + }
101623 + return NULL_TREE;
101624 +}
101625 +
101626 +static struct attribute_spec latent_entropy_attr = {
101627 + .name = "latent_entropy",
101628 + .min_length = 0,
101629 + .max_length = 0,
101630 + .decl_required = true,
101631 + .type_required = false,
101632 + .function_type_required = false,
101633 + .handler = handle_latent_entropy_attribute,
101634 +#if BUILDING_GCC_VERSION >= 4007
101635 + .affects_type_identity = false
101636 +#endif
101637 +};
101638 +
101639 +static void register_attributes(void *event_data, void *data)
101640 +{
101641 + register_attribute(&latent_entropy_attr);
101642 +}
101643 +
101644 +static bool gate_latent_entropy(void)
101645 +{
101646 + tree latent_entropy_attr;
101647 +
101648 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101649 + return latent_entropy_attr != NULL_TREE;
101650 +}
101651 +
101652 +static unsigned HOST_WIDE_INT seed;
101653 +static unsigned HOST_WIDE_INT get_random_const(void)
101654 +{
101655 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101656 + return seed;
101657 +}
101658 +
101659 +static enum tree_code get_op(tree *rhs)
101660 +{
101661 + static enum tree_code op;
101662 + unsigned HOST_WIDE_INT random_const;
101663 +
101664 + random_const = get_random_const();
101665 +
101666 + switch (op) {
101667 + case BIT_XOR_EXPR:
101668 + op = PLUS_EXPR;
101669 + break;
101670 +
101671 + case PLUS_EXPR:
101672 + if (rhs) {
101673 + op = LROTATE_EXPR;
101674 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101675 + break;
101676 + }
101677 +
101678 + case LROTATE_EXPR:
101679 + default:
101680 + op = BIT_XOR_EXPR;
101681 + break;
101682 + }
101683 + if (rhs)
101684 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101685 + return op;
101686 +}
101687 +
101688 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101689 +{
101690 + gimple_stmt_iterator gsi;
101691 + gimple assign;
101692 + tree addxorrol, rhs;
101693 + enum tree_code op;
101694 +
101695 + op = get_op(&rhs);
101696 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101697 + assign = gimple_build_assign(local_entropy, addxorrol);
101698 + gsi = gsi_after_labels(bb);
101699 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101700 + update_stmt(assign);
101701 +//debug_bb(bb);
101702 +}
101703 +
101704 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101705 +{
101706 + gimple_stmt_iterator gsi;
101707 + gimple assign;
101708 + tree addxorrol, temp;
101709 +
101710 + // 1. create temporary copy of latent_entropy
101711 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101712 +#if BUILDING_GCC_VERSION <= 4007
101713 + add_referenced_var(temp);
101714 +#endif
101715 +
101716 + // 2. read...
101717 + temp = make_ssa_name(temp, NULL);
101718 + assign = gimple_build_assign(temp, latent_entropy_decl);
101719 + SSA_NAME_DEF_STMT(temp) = assign;
101720 +#if BUILDING_GCC_VERSION <= 4007
101721 + add_referenced_var(latent_entropy_decl);
101722 +#endif
101723 + gsi = gsi_after_labels(bb);
101724 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101725 + update_stmt(assign);
101726 +
101727 + // 3. ...modify...
101728 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101729 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101730 + assign = gimple_build_assign(temp, addxorrol);
101731 + SSA_NAME_DEF_STMT(temp) = assign;
101732 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101733 + update_stmt(assign);
101734 +
101735 + // 4. ...write latent_entropy
101736 + assign = gimple_build_assign(latent_entropy_decl, temp);
101737 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101738 + update_stmt(assign);
101739 +}
101740 +
101741 +static unsigned int execute_latent_entropy(void)
101742 +{
101743 + basic_block bb;
101744 + gimple assign;
101745 + gimple_stmt_iterator gsi;
101746 + tree local_entropy;
101747 +
101748 + if (!latent_entropy_decl) {
101749 + struct varpool_node *node;
101750 +
101751 +#if BUILDING_GCC_VERSION <= 4007
101752 + for (node = varpool_nodes; node; node = node->next) {
101753 + tree var = node->decl;
101754 +#else
101755 + FOR_EACH_VARIABLE(node) {
101756 + tree var = node->symbol.decl;
101757 +#endif
101758 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101759 + continue;
101760 + latent_entropy_decl = var;
101761 +// debug_tree(var);
101762 + break;
101763 + }
101764 + if (!latent_entropy_decl) {
101765 +// debug_tree(current_function_decl);
101766 + return 0;
101767 + }
101768 + }
101769 +
101770 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101771 +
101772 + // 1. create local entropy variable
101773 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101774 +#if BUILDING_GCC_VERSION <= 4007
101775 + add_referenced_var(local_entropy);
101776 + mark_sym_for_renaming(local_entropy);
101777 +#endif
101778 +
101779 + // 2. initialize local entropy variable
101780 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101781 + if (dom_info_available_p(CDI_DOMINATORS))
101782 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101783 + gsi = gsi_start_bb(bb);
101784 +
101785 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101786 +// gimple_set_location(assign, loc);
101787 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101788 + update_stmt(assign);
101789 +//debug_bb(bb);
101790 + bb = bb->next_bb;
101791 +
101792 + // 3. instrument each BB with an operation on the local entropy variable
101793 + while (bb != EXIT_BLOCK_PTR) {
101794 + perturb_local_entropy(bb, local_entropy);
101795 +//debug_bb(bb);
101796 + bb = bb->next_bb;
101797 + };
101798 +
101799 + // 4. mix local entropy into the global entropy variable
101800 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101801 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101802 + return 0;
101803 +}
101804 +
101805 +static void start_unit_callback(void *gcc_data, void *user_data)
101806 +{
101807 + tree latent_entropy_type;
101808 +
101809 +#if BUILDING_GCC_VERSION >= 4007
101810 + seed = get_random_seed(false);
101811 +#else
101812 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101813 + seed *= seed;
101814 +#endif
101815 +
101816 + if (in_lto_p)
101817 + return;
101818 +
101819 + // extern volatile u64 latent_entropy
101820 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101821 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101822 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101823 +
101824 + TREE_STATIC(latent_entropy_decl) = 1;
101825 + TREE_PUBLIC(latent_entropy_decl) = 1;
101826 + TREE_USED(latent_entropy_decl) = 1;
101827 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101828 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101829 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101830 + DECL_INITIAL(latent_entropy_decl) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101831 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101832 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101833 +// varpool_finalize_decl(latent_entropy_decl);
101834 +// varpool_mark_needed_node(latent_entropy_decl);
101835 +}
101836 +
101837 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101838 +{
101839 + const char * const plugin_name = plugin_info->base_name;
101840 + struct register_pass_info latent_entropy_pass_info = {
101841 + .pass = &latent_entropy_pass.pass,
101842 + .reference_pass_name = "optimized",
101843 + .ref_pass_instance_number = 1,
101844 + .pos_op = PASS_POS_INSERT_BEFORE
101845 + };
101846 +
101847 + if (!plugin_default_version_check(version, &gcc_version)) {
101848 + error(G_("incompatible gcc/plugin versions"));
101849 + return 1;
101850 + }
101851 +
101852 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101853 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101854 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101855 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101856 +
101857 + return 0;
101858 +}
101859 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101860 new file mode 100644
101861 index 0000000..b04803b
101862 --- /dev/null
101863 +++ b/tools/gcc/size_overflow_hash.data
101864 @@ -0,0 +1,6350 @@
101865 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101866 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101867 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101868 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101869 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101870 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101871 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101872 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101873 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101874 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101875 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101876 +load_msg_95 load_msg 2 95 NULL
101877 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101878 +init_q_132 init_q 4 132 NULL
101879 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101880 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101881 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101882 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101883 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101884 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101885 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101886 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101887 +br_port_info_size_268 br_port_info_size 0 268 NULL
101888 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101889 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101890 +SYSC_connect_304 SYSC_connect 3 304 NULL
101891 +syslog_print_307 syslog_print 2 307 NULL
101892 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101893 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101894 +next_node_allowed_318 next_node_allowed 1 318 NULL
101895 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101896 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101897 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101898 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101899 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101900 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101901 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101902 +pidlist_resize_496 pidlist_resize 2 496 NULL
101903 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101904 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101905 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101906 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101907 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101908 +dle_count_543 dle_count 0 543 NULL
101909 +devres_alloc_551 devres_alloc 2 551 NULL
101910 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101911 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101912 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101913 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101914 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101915 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101916 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101917 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101918 +isp1760_register_628 isp1760_register 1-2 628 NULL
101919 +clone_split_bio_633 clone_split_bio 6 633 NULL
101920 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101921 +remap_to_cache_640 remap_to_cache 3 640 NULL
101922 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101923 +unlink_queued_645 unlink_queued 3-4 645 NULL
101924 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101925 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101926 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101927 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101928 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101929 +disk_max_parts_719 disk_max_parts 0 719 NULL
101930 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101931 +dvb_video_write_754 dvb_video_write 3 754 NULL
101932 +if_writecmd_815 if_writecmd 2 815 NULL
101933 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101934 +read_fifo_826 read_fifo 3 826 NULL
101935 +um_idi_read_850 um_idi_read 3 850 NULL
101936 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101937 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101938 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101939 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101940 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101941 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
101942 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
101943 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
101944 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
101945 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
101946 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
101947 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
101948 +_do_truncate_1019 _do_truncate 2 1019 NULL
101949 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
101950 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
101951 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
101952 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
101953 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
101954 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
101955 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
101956 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
101957 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
101958 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
101959 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
101960 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
101961 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
101962 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
101963 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
101964 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
101965 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
101966 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
101967 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
101968 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
101969 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
101970 +nested_get_page_1252 nested_get_page 2 1252 NULL
101971 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
101972 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
101973 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
101974 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
101975 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
101976 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
101977 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
101978 +ffs_1322 ffs 0 1322 NULL
101979 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
101980 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
101981 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
101982 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
101983 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
101984 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
101985 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
101986 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
101987 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
101988 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
101989 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
101990 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
101991 +zone_page_state_1393 zone_page_state 0 1393 NULL
101992 +file_read_actor_1401 file_read_actor 4 1401 NULL
101993 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
101994 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
101995 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
101996 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
101997 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
101998 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
101999 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102000 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102001 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
102002 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102003 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102004 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102005 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
102006 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102007 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102008 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102009 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
102010 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102011 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102012 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
102013 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
102014 +rmap_add_1677 rmap_add 3 1677 NULL
102015 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102016 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
102017 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102018 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102019 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102020 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
102021 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
102022 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102023 +cosa_write_1774 cosa_write 3 1774 NULL
102024 +update_macheader_1775 update_macheader 7 1775 NULL
102025 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
102026 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102027 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
102028 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
102029 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102030 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102031 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102032 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
102033 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102034 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
102035 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102036 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102037 +read_swap_header_1957 read_swap_header 0 1957 NULL
102038 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102039 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102040 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
102041 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102042 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102043 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102044 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102045 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102046 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102047 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
102048 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
102049 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102050 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102051 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
102052 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102053 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102054 +audit_expand_2098 audit_expand 2 2098 NULL
102055 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102056 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102057 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102058 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
102059 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
102060 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102061 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102062 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102063 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
102064 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102065 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
102066 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102067 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
102068 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102069 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102070 +vhci_write_2224 vhci_write 3 2224 NULL
102071 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
102072 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
102073 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102074 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102075 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102076 +do_update_counters_2259 do_update_counters 4 2259 NULL
102077 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102078 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102079 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
102080 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102081 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
102082 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
102083 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102084 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102085 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102086 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
102087 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
102088 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102089 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
102090 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102091 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
102092 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102093 +raid1_size_2419 raid1_size 0-2 2419 NULL
102094 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
102095 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
102096 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
102097 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102098 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
102099 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102100 +update_pmkid_2481 update_pmkid 4 2481 NULL
102101 +wiphy_new_2482 wiphy_new 2 2482 NULL
102102 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102103 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102104 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102105 +dm_write_2513 dm_write 3 2513 NULL
102106 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102107 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102108 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102109 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
102110 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102111 +slot_bytes_2609 slot_bytes 0 2609 NULL
102112 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102113 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102114 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
102115 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102116 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
102117 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
102118 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
102119 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102120 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102121 +__next_cpu_2782 __next_cpu 1 2782 NULL
102122 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102123 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102124 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
102125 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102126 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102127 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102128 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102129 +mq_map_2871 mq_map 2 2871 NULL
102130 +nla_padlen_2883 nla_padlen 1 2883 NULL
102131 +cmm_write_2896 cmm_write 3 2896 NULL
102132 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102133 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102134 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102135 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102136 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102137 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
102138 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102139 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102140 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102141 +depth_write_3021 depth_write 3 3021 NULL
102142 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102143 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102144 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
102145 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102146 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102147 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102148 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
102149 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102150 +free_coherent_3082 free_coherent 4-2 3082 NULL
102151 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102152 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102153 +rb_alloc_3102 rb_alloc 1 3102 NULL
102154 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
102155 +print_time_3132 print_time 0 3132 NULL
102156 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102157 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102158 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102159 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102160 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102161 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102162 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102163 +alloc_context_3194 alloc_context 1 3194 NULL
102164 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
102165 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102166 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102167 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102168 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102169 +key_key_read_3241 key_key_read 3 3241 NULL
102170 +number_3243 number 0 3243 NULL
102171 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
102172 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102173 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
102174 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102175 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102176 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
102177 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102178 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102179 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102180 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102181 +scnprintf_3360 scnprintf 0-2 3360 NULL
102182 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102183 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102184 +send_stream_3397 send_stream 4 3397 NULL
102185 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102186 +msix_map_region_3411 msix_map_region 3 3411 NULL
102187 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102188 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102189 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102190 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102191 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102192 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
102193 +map_single_3449 map_single 0-2 3449 NULL
102194 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102195 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
102196 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
102197 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102198 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102199 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
102200 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
102201 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
102202 +SyS_readv_3539 SyS_readv 3 3539 NULL
102203 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102204 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
102205 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102206 +evtchn_read_3569 evtchn_read 3 3569 NULL
102207 +vc_resize_3585 vc_resize 2-3 3585 NULL
102208 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
102209 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102210 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102211 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102212 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102213 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
102214 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
102215 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102216 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102217 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102218 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
102219 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
102220 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102221 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102222 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102223 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102224 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102225 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
102226 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102227 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102228 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102229 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102230 +get_fd_set_3866 get_fd_set 1 3866 NULL
102231 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102232 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
102233 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102234 +nvram_write_3894 nvram_write 3 3894 NULL
102235 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102236 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102237 +vcs_write_3910 vcs_write 3 3910 NULL
102238 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102239 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
102240 +do_add_counters_3992 do_add_counters 3 3992 NULL
102241 +userspace_status_4004 userspace_status 4 4004 NULL
102242 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102243 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102244 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102245 +mm_populate_4016 mm_populate 1 4016 NULL
102246 +blk_end_request_4024 blk_end_request 3 4024 NULL
102247 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102248 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
102249 +read_file_queues_4078 read_file_queues 3 4078 NULL
102250 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102251 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102252 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
102253 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
102254 +tm6000_read_4151 tm6000_read 3 4151 NULL
102255 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102256 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102257 +get_alua_req_4166 get_alua_req 3 4166 NULL
102258 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102259 +read_file_bool_4180 read_file_bool 3 4180 NULL
102260 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102261 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102262 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102263 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102264 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102265 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102266 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102267 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102268 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102269 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102270 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
102271 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
102272 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102273 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
102274 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102275 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102276 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102277 +memparse_4444 memparse 0 4444 NULL
102278 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102279 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
102280 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
102281 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102282 +set_link_security_4502 set_link_security 4 4502 NULL
102283 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102284 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
102285 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
102286 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102287 +tty_register_device_4544 tty_register_device 2 4544 NULL
102288 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102289 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102290 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102291 +bch_alloc_4593 bch_alloc 1 4593 NULL
102292 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102293 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102294 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102295 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102296 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102297 +kone_receive_4690 kone_receive 4 4690 NULL
102298 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
102299 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102300 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102301 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
102302 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102303 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102304 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102305 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
102306 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
102307 +create_subvol_4791 create_subvol 4 4791 NULL
102308 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102309 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
102310 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102311 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102312 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
102313 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102314 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102315 +sys_ipc_4889 sys_ipc 3 4889 NULL
102316 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
102317 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
102318 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102319 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
102320 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102321 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102322 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102323 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102324 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
102325 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
102326 +do_mincore_5018 do_mincore 0-1 5018 NULL
102327 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
102328 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
102329 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102330 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102331 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102332 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
102333 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102334 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
102335 +sound_write_5102 sound_write 3 5102 NULL
102336 +clear_dirty_5105 clear_dirty 3 5105 NULL
102337 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102338 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
102339 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102340 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102341 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102342 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
102343 +skb_network_header_5203 skb_network_header 0 5203 NULL
102344 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
102345 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
102346 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102347 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102348 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
102349 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
102350 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
102351 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
102352 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102353 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102354 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102355 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102356 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102357 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102358 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102359 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
102360 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
102361 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102362 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102363 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
102364 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102365 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102366 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102367 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102368 +tty_write_5494 tty_write 3 5494 NULL
102369 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102370 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102371 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102372 +spidev_message_5518 spidev_message 3 5518 NULL
102373 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102374 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102375 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
102376 +le_readq_5557 le_readq 0 5557 NULL
102377 +inw_5558 inw 0 5558 NULL
102378 +fir16_create_5574 fir16_create 3 5574 NULL
102379 +bioset_create_5580 bioset_create 1 5580 NULL
102380 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
102381 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
102382 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102383 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102384 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102385 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102386 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102387 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
102388 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
102389 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102390 +get_arg_5694 get_arg 3 5694 NULL
102391 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102392 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102393 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102394 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102395 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102396 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102397 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102398 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102399 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102400 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102401 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102402 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102403 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102404 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102405 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102406 +setup_req_5848 setup_req 3 5848 NULL
102407 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102408 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102409 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102410 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102411 +port_show_regs_5904 port_show_regs 3 5904 NULL
102412 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102413 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102414 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102415 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102416 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102417 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102418 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102419 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102420 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102421 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102422 +native_pte_val_5978 native_pte_val 0 5978 NULL
102423 +SyS_semop_5980 SyS_semop 3 5980 NULL
102424 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102425 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102426 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102427 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102428 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102429 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102430 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102431 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102432 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102433 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102434 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102435 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102436 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102437 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102438 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102439 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102440 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102441 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102442 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102443 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102444 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102445 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102446 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102447 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102448 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102449 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102450 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102451 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102452 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102453 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102454 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102455 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102456 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102457 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102458 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102459 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102460 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102461 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102462 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102463 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102464 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102465 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102466 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102467 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102468 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102469 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102470 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102471 +mei_read_6507 mei_read 3 6507 NULL
102472 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102473 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102474 +wdm_read_6549 wdm_read 3 6549 NULL
102475 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102476 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102477 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102478 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102479 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102480 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102481 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102482 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102483 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102484 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102485 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102486 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102487 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102488 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102489 +mpeg_read_6708 mpeg_read 3 6708 NULL
102490 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102491 +video_proc_write_6724 video_proc_write 3 6724 NULL
102492 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102493 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102494 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102495 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102496 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102497 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102498 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102499 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102500 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102501 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102502 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102503 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102504 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102505 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102506 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102507 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102508 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102509 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102510 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102511 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102512 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102513 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102514 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102515 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102516 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102517 +request_key_async_6990 request_key_async 4 6990 NULL
102518 +tpl_write_6998 tpl_write 3 6998 NULL
102519 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102520 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102521 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102522 +wimax_msg_7030 wimax_msg 4 7030 NULL
102523 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102524 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102525 +event_enable_read_7074 event_enable_read 3 7074 NULL
102526 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102527 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102528 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102529 +check_header_7108 check_header 0 7108 NULL
102530 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102531 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102532 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102533 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102534 +get_param_h_7247 get_param_h 0 7247 NULL
102535 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102536 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102537 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102538 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102539 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102540 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102541 +mgmt_control_7349 mgmt_control 3 7349 NULL
102542 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102543 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102544 +hweight_long_7388 hweight_long 0-1 7388 NULL
102545 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102546 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102547 +readb_7401 readb 0 7401 NULL
102548 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102549 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102550 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102551 +numa_emulation_7466 numa_emulation 2 7466 NULL
102552 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102553 +garp_request_join_7471 garp_request_join 4 7471 NULL
102554 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102555 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102556 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102557 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102558 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102559 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102560 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102561 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102562 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102563 +groups_alloc_7614 groups_alloc 1 7614 NULL
102564 +sg_virt_7616 sg_virt 0 7616 NULL
102565 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102566 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102567 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102568 +dev_write_7708 dev_write 3 7708 NULL
102569 +unmap_region_7709 unmap_region 1 7709 NULL
102570 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102571 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102572 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102573 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102574 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102575 +ioread32be_7773 ioread32be 0 7773 NULL
102576 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102577 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102578 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102579 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102580 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102581 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102582 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102583 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102584 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102585 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102586 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102587 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102588 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102589 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102590 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102591 +sys_mbind_7990 sys_mbind 5 7990 NULL
102592 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102593 +vcs_read_8017 vcs_read 3 8017 NULL
102594 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102595 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102596 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102597 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102598 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102599 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102600 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102601 +venus_lookup_8121 venus_lookup 4 8121 NULL
102602 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102603 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102604 +ore_truncate_8181 ore_truncate 3 8181 NULL
102605 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102606 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102607 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102608 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102609 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102610 +play_iframe_8219 play_iframe 3 8219 NULL
102611 +create_log_8225 create_log 2 8225 NULL nohasharray
102612 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102613 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102614 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102615 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102616 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102617 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102618 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102619 +init_cdev_8274 init_cdev 1 8274 NULL
102620 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102621 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102622 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102623 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102624 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102625 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102626 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102627 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102628 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102629 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102630 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102631 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102632 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102633 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102634 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102635 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102636 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102637 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102638 +dev_config_8506 dev_config 3 8506 NULL
102639 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102640 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102641 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102642 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102643 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102644 +user_on_off_8552 user_on_off 2 8552 NULL
102645 +profile_remove_8556 profile_remove 3 8556 NULL
102646 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102647 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102648 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102649 +tower_write_8580 tower_write 3 8580 NULL
102650 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102651 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102652 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102653 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102654 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102655 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102656 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102657 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102658 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102659 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102660 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102661 +arcfb_write_8702 arcfb_write 3 8702 NULL
102662 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102663 +init_header_8703 init_header 0 8703 &i_size_read_8703
102664 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102665 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102666 +f_dupfd_8730 f_dupfd 1 8730 NULL
102667 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102668 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102669 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102670 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102671 +sys_prctl_8766 sys_prctl 4 8766 NULL
102672 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102673 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102674 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102675 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102676 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102677 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102678 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102679 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102680 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102681 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102682 +clear_bitset_8840 clear_bitset 2 8840 NULL
102683 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102684 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102685 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102686 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102687 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102688 +layout_commit_8926 layout_commit 3 8926 NULL
102689 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102690 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102691 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102692 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102693 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102694 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102695 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102696 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102697 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102698 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102699 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102700 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102701 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102702 +nla_put_9042 nla_put 3 9042 NULL
102703 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102704 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102705 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102706 +string_9080 string 0 9080 NULL
102707 +create_queues_9088 create_queues 2-3 9088 NULL
102708 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102709 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102710 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102711 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102712 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102713 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102714 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102715 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102716 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102717 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102718 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102719 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102720 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102721 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102722 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102723 +get_pfn_9207 get_pfn 1 9207 NULL
102724 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102725 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102726 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102727 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102728 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102729 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102730 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102731 +flakey_status_9274 flakey_status 5 9274 NULL
102732 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102733 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102734 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102735 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102736 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102737 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102738 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102739 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102740 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102741 +read_9397 read 3 9397 NULL
102742 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102743 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102744 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102745 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102746 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102747 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102748 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102749 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102750 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102751 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102752 +lp_write_9511 lp_write 3 9511 NULL
102753 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102754 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102755 +read_file_dma_9530 read_file_dma 3 9530 NULL
102756 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102757 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102758 +fw_node_create_9559 fw_node_create 2 9559 NULL
102759 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102760 +kobj_map_9566 kobj_map 2-3 9566 NULL
102761 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102762 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102763 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102764 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102765 +do_sync_9604 do_sync 1 9604 NULL
102766 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102767 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102768 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102769 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102770 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102771 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102772 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102773 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102774 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102775 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102776 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102777 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102778 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102779 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102780 +fnb_9703 fnb 2-3 9703 NULL
102781 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102782 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102783 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102784 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102785 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102786 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102787 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102788 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102789 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102790 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102791 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102792 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102793 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102794 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102795 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102796 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102797 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102798 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102799 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102800 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102801 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102802 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102803 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102804 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102805 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102806 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102807 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102808 +read_file_misc_9948 read_file_misc 3 9948 NULL
102809 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102810 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102811 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102812 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102813 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102814 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102815 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102816 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102817 +handle_request_10024 handle_request 9 10024 NULL
102818 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102819 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102820 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102821 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102822 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102823 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102824 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102825 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102826 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102827 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102828 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102829 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102830 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102831 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102832 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102833 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102834 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102835 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102836 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102837 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102838 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102839 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102840 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102841 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102842 +read_emulate_10310 read_emulate 2-4 10310 NULL
102843 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102844 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102845 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102846 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102847 +get_dump_page_10338 get_dump_page 1 10338 NULL
102848 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102849 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102850 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102851 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102852 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102853 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102854 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102855 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102856 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102857 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102858 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102859 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102860 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102861 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102862 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102863 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102864 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102865 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102866 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102867 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102868 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102869 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102870 +otp_read_10594 otp_read 2-4-5 10594 NULL
102871 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102872 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102873 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102874 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102875 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102876 +parport_write_10669 parport_write 0 10669 NULL
102877 +inl_10708 inl 0 10708 NULL nohasharray
102878 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102879 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102880 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102881 +spi_sync_10731 spi_sync 0 10731 NULL
102882 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102883 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102884 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102885 +sys_syslog_10746 sys_syslog 3 10746 NULL
102886 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102887 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102888 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102889 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102890 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102891 +sys_bind_10799 sys_bind 3 10799 NULL
102892 +compat_put_int_10828 compat_put_int 1 10828 NULL
102893 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102894 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102895 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102896 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102897 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102898 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102899 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102900 +get_scq_10897 get_scq 2 10897 NULL
102901 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102902 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102903 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102904 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102905 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102906 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102907 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102908 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102909 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102910 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102911 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102912 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102913 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102914 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102915 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102916 +count_argc_11083 count_argc 0 11083 NULL
102917 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102918 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102919 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102920 +page_offset_11120 page_offset 0 11120 NULL
102921 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102922 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102923 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102924 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102925 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102926 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102927 +__swab16p_11220 __swab16p 0 11220 NULL
102928 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102929 +mmap_region_11247 mmap_region 0-2 11247 NULL
102930 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102931 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102932 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102933 +cru_detect_11272 cru_detect 1 11272 NULL
102934 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102935 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102936 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102937 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102938 +next_segment_11330 next_segment 0-2-1 11330 NULL
102939 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102940 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102941 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
102942 +sel_write_create_11353 sel_write_create 3 11353 NULL
102943 +handle_unit_11355 handle_unit 0-1 11355 NULL
102944 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
102945 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
102946 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
102947 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
102948 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
102949 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
102950 +str_to_user_11411 str_to_user 2 11411 NULL
102951 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
102952 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
102953 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
102954 +trace_options_read_11419 trace_options_read 3 11419 NULL
102955 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
102956 +prepare_image_11424 prepare_image 0 11424 NULL
102957 +vring_size_11426 vring_size 0-1-2 11426 NULL
102958 +bttv_read_11432 bttv_read 3 11432 NULL
102959 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
102960 +swp_offset_11475 swp_offset 0 11475 NULL
102961 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
102962 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
102963 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
102964 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
102965 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
102966 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
102967 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
102968 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
102969 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
102970 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
102971 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
102972 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
102973 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
102974 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
102975 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
102976 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
102977 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
102978 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
102979 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
102980 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
102981 +split_11691 split 2 11691 NULL
102982 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
102983 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
102984 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
102985 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
102986 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
102987 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
102988 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
102989 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
102990 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
102991 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
102992 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
102993 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
102994 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
102995 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
102996 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
102997 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
102998 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
102999 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
103000 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103001 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103002 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103003 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
103004 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103005 +atmel_read16_11981 atmel_read16 0 11981 NULL
103006 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103007 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103008 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103009 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103010 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103011 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103012 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103013 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103014 +set_powered_12129 set_powered 4 12129 NULL
103015 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
103016 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103017 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103018 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
103019 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103020 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103021 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103022 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103023 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103024 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
103025 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103026 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103027 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103028 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103029 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
103030 +scaled_div_12201 scaled_div 1-2 12201 NULL
103031 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
103032 +receive_copy_12216 receive_copy 3 12216 NULL
103033 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103034 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103035 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103036 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
103037 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103038 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
103039 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103040 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103041 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103042 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
103043 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
103044 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
103045 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103046 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
103047 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103048 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103049 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103050 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103051 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103052 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
103053 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103054 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103055 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103056 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
103057 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103058 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
103059 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103060 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
103061 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103062 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103063 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103064 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103065 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103066 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
103067 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103068 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
103069 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103070 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
103071 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103072 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
103073 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103074 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103075 +wb_create_12651 wb_create 1 12651 NULL
103076 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103077 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103078 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103079 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103080 +ivtv_write_12721 ivtv_write 3 12721 NULL
103081 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103082 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103083 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
103084 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103085 +listxattr_12769 listxattr 3 12769 NULL
103086 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103087 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
103088 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
103089 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
103090 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103091 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103092 +readq_12825 readq 0 12825 NULL
103093 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103094 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
103095 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
103096 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103097 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103098 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103099 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103100 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103101 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103102 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103103 +bm_status_write_12964 bm_status_write 3 12964 NULL
103104 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
103105 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103106 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
103107 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103108 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103109 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103110 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103111 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103112 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
103113 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103114 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103115 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103116 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
103117 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
103118 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
103119 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103120 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103121 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103122 +blk_update_request_13146 blk_update_request 3 13146 NULL
103123 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103124 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103125 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103126 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103127 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103128 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
103129 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103130 +comedi_read_13199 comedi_read 3 13199 NULL
103131 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103132 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103133 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103134 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103135 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103136 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
103137 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
103138 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103139 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
103140 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103141 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103142 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
103143 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103144 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103145 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103146 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
103147 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
103148 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103149 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
103150 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103151 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103152 +cache_ctr_13364 cache_ctr 2 13364 NULL
103153 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
103154 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103155 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103156 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
103157 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
103158 +sky2_receive_13407 sky2_receive 2 13407 NULL
103159 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103160 +keyring_read_13438 keyring_read 3 13438 NULL
103161 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
103162 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
103163 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103164 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
103165 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
103166 +core_status_13515 core_status 4 13515 NULL
103167 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103168 +bm_init_13529 bm_init 2 13529 NULL
103169 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
103170 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
103171 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103172 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103173 +sys_madvise_13569 sys_madvise 1 13569 NULL
103174 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103175 +cache_write_13589 cache_write 3 13589 NULL
103176 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
103177 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
103178 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
103179 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
103180 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103181 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103182 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103183 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
103184 +packet_snd_13634 packet_snd 3 13634 NULL
103185 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103186 +cache_downcall_13666 cache_downcall 3 13666 NULL
103187 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103188 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103189 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103190 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103191 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103192 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103193 +random_read_13815 random_read 3 13815 NULL
103194 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103195 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103196 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
103197 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
103198 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
103199 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
103200 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103201 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103202 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103203 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103204 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103205 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
103206 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103207 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103208 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103209 +com90xx_found_13974 com90xx_found 3 13974 NULL
103210 +qcam_read_13977 qcam_read 3 13977 NULL
103211 +dsp_read_13980 dsp_read 2 13980 NULL
103212 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103213 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103214 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103215 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103216 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
103217 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103218 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103219 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103220 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103221 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103222 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
103223 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103224 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103225 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
103226 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
103227 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
103228 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103229 +em_canid_change_14150 em_canid_change 3 14150 NULL
103230 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103231 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103232 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103233 +alloc_async_14208 alloc_async 1 14208 NULL
103234 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
103235 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103236 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
103237 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103238 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
103239 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
103240 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
103241 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
103242 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
103243 +rr_status_14293 rr_status 5 14293 NULL
103244 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103245 +oo_objects_14319 oo_objects 0 14319 NULL
103246 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103247 +scsi2int_14358 scsi2int 0 14358 NULL
103248 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103249 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103250 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103251 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103252 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103253 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103254 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103255 +block_size_14443 block_size 0 14443 NULL
103256 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
103257 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103258 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103259 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
103260 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103261 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
103262 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
103263 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103264 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103265 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
103266 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103267 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103268 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103269 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103270 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103271 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103272 +dbJoin_14644 dbJoin 0 14644 NULL
103273 +profile_replace_14652 profile_replace 3 14652 NULL
103274 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103275 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103276 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
103277 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103278 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103279 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103280 +get_bio_block_14714 get_bio_block 0 14714 NULL
103281 +vfd_write_14717 vfd_write 3 14717 NULL
103282 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103283 +raid1_resize_14740 raid1_resize 2 14740 NULL
103284 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103285 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103286 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
103287 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103288 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103289 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103290 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103291 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103292 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
103293 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103294 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
103295 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103296 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
103297 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
103298 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103299 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
103300 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103301 +unifi_read_14899 unifi_read 3 14899 NULL
103302 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103303 +krealloc_14908 krealloc 2 14908 NULL
103304 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
103305 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103306 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
103307 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103308 +queue_cnt_14951 queue_cnt 0 14951 NULL
103309 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103310 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103311 +setkey_14987 setkey 3 14987 NULL nohasharray
103312 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103313 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103314 +vmap_15025 vmap 2 15025 NULL
103315 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103316 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
103317 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103318 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103319 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103320 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
103321 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
103322 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103323 +start_port_15124 start_port 0 15124 NULL
103324 +memchr_15126 memchr 0 15126 NULL
103325 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103326 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103327 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103328 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103329 +reserve_resources_15194 reserve_resources 3 15194 NULL
103330 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103331 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103332 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103333 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
103334 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
103335 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
103336 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103337 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103338 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
103339 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
103340 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
103341 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103342 +ioread16_15342 ioread16 0 15342 NULL
103343 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
103344 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103345 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103346 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103347 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103348 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103349 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103350 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103351 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103352 +get_modalias_15406 get_modalias 2 15406 NULL
103353 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103354 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
103355 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
103356 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103357 +memweight_15450 memweight 2 15450 NULL
103358 +vmalloc_15464 vmalloc 1 15464 NULL
103359 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103360 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
103361 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
103362 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
103363 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
103364 +persistent_status_15574 persistent_status 4 15574 NULL
103365 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
103366 +vme_user_write_15587 vme_user_write 3 15587 NULL
103367 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
103368 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
103369 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
103370 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
103371 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
103372 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
103373 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
103374 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
103375 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
103376 +fs_path_add_15648 fs_path_add 3 15648 NULL
103377 +xsd_read_15653 xsd_read 3 15653 NULL
103378 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
103379 +unix_bind_15668 unix_bind 3 15668 NULL
103380 +dm_read_15674 dm_read 3 15674 NULL
103381 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
103382 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
103383 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
103384 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
103385 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
103386 +do_test_15766 do_test 1 15766 NULL
103387 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
103388 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
103389 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103390 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103391 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103392 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103393 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103394 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103395 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103396 +table_size_15851 table_size 0-1-2 15851 NULL
103397 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103398 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103399 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103400 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103401 +native_read_msr_15905 native_read_msr 0 15905 NULL
103402 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103403 +power_read_15939 power_read 3 15939 NULL
103404 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103405 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103406 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103407 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103408 +frame_alloc_15981 frame_alloc 4 15981 NULL
103409 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103410 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103411 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103412 +got_frame_16028 got_frame 2 16028 NULL
103413 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103414 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103415 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103416 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103417 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103418 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103419 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103420 +fsm_init_16134 fsm_init 2 16134 NULL
103421 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103422 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103423 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103424 +mapping_level_16188 mapping_level 2 16188 NULL
103425 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103426 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103427 +create_table_16213 create_table 2 16213 NULL
103428 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103429 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103430 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103431 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103432 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103433 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103434 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103435 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103436 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103437 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103438 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103439 +account_16283 account 0-2-4 16283 NULL nohasharray
103440 +mirror_status_16283 mirror_status 5 16283 &account_16283
103441 +retry_instruction_16285 retry_instruction 2 16285 NULL
103442 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103443 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103444 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103445 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103446 +wb_map_16301 wb_map 2 16301 NULL
103447 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103448 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103449 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103450 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103451 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103452 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103453 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103454 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103455 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103456 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103457 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103458 +raid10_resize_16537 raid10_resize 2 16537 NULL
103459 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103460 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103461 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103462 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103463 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103464 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103465 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103466 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103467 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103468 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103469 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103470 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103471 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103472 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103473 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103474 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103475 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103476 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103477 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103478 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103479 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103480 +st_write_16874 st_write 3 16874 NULL
103481 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103482 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103483 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103484 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103485 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103486 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103487 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103488 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103489 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103490 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103491 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103492 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103493 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103494 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103495 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103496 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103497 +mac_address_string_17091 mac_address_string 0 17091 NULL
103498 +entry_length_17093 entry_length 0 17093 NULL
103499 +sys_preadv_17100 sys_preadv 3 17100 NULL
103500 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103501 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103502 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103503 +sep_read_17161 sep_read 3 17161 NULL
103504 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103505 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103506 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103507 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103508 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103509 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103510 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103511 +to_oblock_17254 to_oblock 0-1 17254 NULL
103512 +unpack_value_17259 unpack_value 1 17259 NULL
103513 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103514 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103515 +alloc_ep_17269 alloc_ep 1 17269 NULL
103516 +pg_read_17276 pg_read 3 17276 NULL
103517 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103518 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103519 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103520 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103521 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103522 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103523 +skb_pad_17302 skb_pad 2 17302 NULL
103524 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103525 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103526 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103527 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103528 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103529 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103530 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103531 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103532 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103533 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103534 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103535 +compat_cmd_17465 compat_cmd 2 17465 NULL
103536 +probe_bios_17467 probe_bios 1 17467 NULL
103537 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103538 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103539 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103540 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103541 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103542 +copy_from_user_17559 copy_from_user 3 17559 NULL
103543 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103544 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103545 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103546 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103547 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103548 +osst_execute_17607 osst_execute 7-6 17607 NULL
103549 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103550 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103551 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103552 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103553 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103554 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103555 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103556 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103557 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103558 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103559 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103560 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103561 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103562 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103563 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103564 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103565 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103566 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103567 +perf_clock_17787 perf_clock 0 17787 NULL
103568 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103569 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103570 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103571 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103572 +count_leafs_17842 count_leafs 0 17842 NULL
103573 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103574 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103575 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103576 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103577 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103578 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103579 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103580 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103581 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103582 +recover_head_17904 recover_head 3 17904 NULL
103583 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103584 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103585 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103586 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103587 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103588 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103589 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103590 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103591 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103592 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103593 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103594 +fill_read_18019 fill_read 0 18019 NULL
103595 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103596 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103597 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103598 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103599 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103600 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103601 +packet_came_18072 packet_came 3 18072 NULL
103602 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103603 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103604 +get_vm_area_18080 get_vm_area 1 18080 NULL
103605 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103606 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103607 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103608 +svc_getnl_18120 svc_getnl 0 18120 NULL
103609 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103610 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103611 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103612 +_has_tag_18169 _has_tag 2 18169 NULL
103613 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103614 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103615 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103616 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103617 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103618 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103619 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103620 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103621 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103622 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103623 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103624 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103625 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103626 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103627 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103628 +um_idi_write_18293 um_idi_write 3 18293 NULL
103629 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103630 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103631 +vga_r_18310 vga_r 0 18310 NULL
103632 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103633 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103634 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103635 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103636 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103637 +ep_io_18367 ep_io 0 18367 NULL
103638 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103639 +ci_role_write_18388 ci_role_write 3 18388 NULL
103640 +__video_register_device_18399 __video_register_device 3 18399 NULL
103641 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103642 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103643 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103644 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103645 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103646 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103647 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103648 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103649 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103650 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103651 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103652 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103653 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103654 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103655 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103656 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103657 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103658 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103659 +debug_output_18575 debug_output 3 18575 NULL
103660 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103661 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103662 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103663 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103664 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103665 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103666 +from_buffer_18625 from_buffer 3 18625 NULL
103667 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103668 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103669 +unmap_page_18665 unmap_page 2-3 18665 NULL
103670 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103671 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103672 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103673 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103674 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103675 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103676 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103677 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103678 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103679 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103680 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103681 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103682 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103683 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103684 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103685 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103686 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103687 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103688 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103689 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103690 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103691 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103692 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103693 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103694 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103695 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103696 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103697 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103698 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103699 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103700 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103701 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103702 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103703 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103704 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103705 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103706 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103707 +huge_page_size_19008 huge_page_size 0 19008 NULL
103708 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103709 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103710 +revalidate_19043 revalidate 2 19043 NULL
103711 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103712 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103713 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103714 +msix_map_region_19072 msix_map_region 2 19072 NULL
103715 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103716 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103717 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103718 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103719 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103720 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103721 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103722 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103723 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103724 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103725 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103726 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103727 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103728 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103729 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103730 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103731 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103732 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103733 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103734 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103735 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103736 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103737 +qc_capture_19298 qc_capture 3 19298 NULL
103738 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103739 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103740 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103741 +debug_read_19322 debug_read 3 19322 NULL
103742 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103743 +closure_sub_19359 closure_sub 2 19359 NULL
103744 +read_zero_19366 read_zero 3 19366 NULL
103745 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103746 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103747 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103748 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103749 +__phys_addr_19434 __phys_addr 0 19434 NULL
103750 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103751 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103752 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103753 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103754 +sky2_read16_19475 sky2_read16 0 19475 NULL
103755 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103756 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103757 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103758 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103759 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103760 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103761 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103762 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103763 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103764 +nfsd_read_19568 nfsd_read 5 19568 NULL
103765 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103766 +bm_status_read_19583 bm_status_read 3 19583 NULL
103767 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103768 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103769 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103770 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103771 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103772 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103773 +bio_detain_19690 bio_detain 2 19690 NULL
103774 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103775 +read_reg_19723 read_reg 0 19723 NULL
103776 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103777 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103778 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103779 +p9_client_read_19750 p9_client_read 5 19750 NULL
103780 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103781 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103782 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103783 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103784 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103785 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103786 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103787 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103788 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103789 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103790 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103791 +__nla_put_19857 __nla_put 3 19857 NULL
103792 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103793 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103794 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103795 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103796 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103797 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103798 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103799 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103800 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103801 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103802 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103803 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103804 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103805 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103806 +team_options_register_20091 team_options_register 3 20091 NULL
103807 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103808 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103809 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103810 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103811 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103812 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103813 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103814 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103815 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103816 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103817 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103818 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103819 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103820 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103821 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103822 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103823 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103824 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103825 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103826 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103827 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103828 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103829 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103830 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103831 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103832 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103833 +read_buf_20469 read_buf 2 20469 NULL
103834 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103835 +fast_user_write_20494 fast_user_write 5 20494 NULL
103836 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103837 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103838 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103839 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103840 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103841 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103842 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103843 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103844 +venus_create_20555 venus_create 4 20555 NULL
103845 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103846 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103847 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103848 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103849 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103850 +lirc_write_20604 lirc_write 3 20604 NULL
103851 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103852 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103853 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103854 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103855 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103856 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103857 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103858 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103859 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103860 +cpumask_size_20683 cpumask_size 0 20683 NULL
103861 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103862 +gru_vtop_20689 gru_vtop 2 20689 NULL
103863 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103864 +__maestro_read_20700 __maestro_read 0 20700 NULL
103865 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103866 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103867 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103868 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103869 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103870 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103871 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103872 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103873 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103874 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103875 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103876 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103877 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103878 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103879 +sys_sendto_20809 sys_sendto 6 20809 NULL
103880 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103881 +strndup_user_20819 strndup_user 2 20819 NULL
103882 +calc_layout_20829 calc_layout 3 20829 NULL
103883 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103884 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103885 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103886 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103887 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103888 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103889 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103890 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103891 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103892 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103893 +htable_bits_20933 htable_bits 0 20933 NULL
103894 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103895 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103896 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103897 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103898 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103899 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103900 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103901 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103902 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103903 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103904 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103905 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103906 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103907 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103908 +multipath_status_21094 multipath_status 5 21094 NULL
103909 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103910 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103911 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103912 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103913 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103914 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103915 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103916 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103917 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103918 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103919 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103920 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103921 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103922 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103923 +input_ff_create_21240 input_ff_create 2 21240 NULL
103924 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103925 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103926 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103927 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103928 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103929 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103930 +add_res_range_21310 add_res_range 4 21310 NULL
103931 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103932 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103933 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103934 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103935 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103936 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103937 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103938 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103939 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103940 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103941 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
103942 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
103943 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
103944 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
103945 +concat_writev_21451 concat_writev 3 21451 NULL
103946 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
103947 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
103948 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
103949 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
103950 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
103951 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
103952 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
103953 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
103954 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
103955 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
103956 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
103957 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
103958 +validate_nnode_21638 validate_nnode 0 21638 NULL
103959 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
103960 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
103961 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
103962 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
103963 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
103964 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
103965 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
103966 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
103967 +vm_brk_21739 vm_brk 1 21739 NULL
103968 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
103969 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
103970 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
103971 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
103972 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
103973 +min_odd_21802 min_odd 0 21802 NULL
103974 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
103975 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
103976 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
103977 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
103978 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
103979 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
103980 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
103981 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
103982 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
103983 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
103984 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
103985 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
103986 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
103987 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
103988 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
103989 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
103990 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
103991 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
103992 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
103993 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
103994 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
103995 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
103996 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
103997 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
103998 +write_opcode_22082 write_opcode 2 22082 NULL
103999 +mem_rw_22085 mem_rw 3 22085 NULL
104000 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
104001 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
104002 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104003 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
104004 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
104005 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
104006 +compat_insn_22142 compat_insn 2 22142 NULL
104007 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104008 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
104009 +fls_22210 fls 0 22210 NULL
104010 +mem_write_22232 mem_write 3 22232 NULL
104011 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104012 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104013 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104014 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104015 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104016 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104017 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104018 +extend_brk_22301 extend_brk 0 22301 NULL
104019 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104020 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
104021 +get_segment_base_22324 get_segment_base 0 22324 NULL
104022 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
104023 +atomic_read_22342 atomic_read 0 22342 NULL
104024 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104025 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104026 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104027 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104028 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104029 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104030 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
104031 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
104032 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
104033 +zoran_write_22404 zoran_write 3 22404 NULL
104034 +queue_reply_22416 queue_reply 3 22416 NULL
104035 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104036 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104037 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104038 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104039 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
104040 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
104041 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
104042 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
104043 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
104044 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
104045 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
104046 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
104047 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
104048 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
104049 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
104050 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
104051 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
104052 +snapshot_read_22601 snapshot_read 3 22601 NULL
104053 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
104054 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
104055 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
104056 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
104057 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
104058 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
104059 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
104060 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
104061 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
104062 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
104063 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
104064 +map_22700 map 2 22700 NULL
104065 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
104066 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
104067 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
104068 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
104069 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
104070 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
104071 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
104072 +print_frame_22769 print_frame 0 22769 NULL
104073 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
104074 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
104075 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
104076 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
104077 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
104078 +create_attr_set_22861 create_attr_set 1 22861 NULL
104079 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
104080 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
104081 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
104082 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
104083 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
104084 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
104085 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
104086 +vme_get_size_22964 vme_get_size 0 22964 NULL
104087 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
104088 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
104089 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
104090 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
104091 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
104092 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
104093 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
104094 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
104095 +st_status_23032 st_status 5 23032 NULL
104096 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
104097 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
104098 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
104099 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
104100 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
104101 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
104102 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
104103 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
104104 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
104105 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
104106 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
104107 +fls_long_23096 fls_long 0 23096 NULL
104108 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
104109 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
104110 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
104111 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
104112 +__clear_user_23118 __clear_user 0 23118 NULL
104113 +dm_write_async_23120 dm_write_async 3 23120 NULL
104114 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
104115 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
104116 +read_file_ani_23161 read_file_ani 3 23161 NULL
104117 +ioremap_23172 ioremap 1-2 23172 NULL
104118 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
104119 +usblp_write_23178 usblp_write 3 23178 NULL
104120 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
104121 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
104122 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
104123 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
104124 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
104125 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
104126 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
104127 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
104128 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
104129 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
104130 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
104131 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
104132 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
104133 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
104134 +doc_probe_23285 doc_probe 1 23285 NULL
104135 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
104136 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
104137 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
104138 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
104139 +page_readlink_23346 page_readlink 3 23346 NULL
104140 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
104141 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
104142 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
104143 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
104144 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
104145 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
104146 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
104147 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
104148 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
104149 +event_filter_read_23494 event_filter_read 3 23494 NULL
104150 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
104151 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
104152 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
104153 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
104154 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
104155 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
104156 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
104157 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
104158 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
104159 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
104160 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
104161 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
104162 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
104163 +sInW_23663 sInW 0 23663 NULL
104164 +SyS_connect_23669 SyS_connect 3 23669 NULL
104165 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
104166 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
104167 +cx18_read_23699 cx18_read 3 23699 NULL
104168 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
104169 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
104170 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
104171 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
104172 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
104173 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
104174 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
104175 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
104176 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
104177 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
104178 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
104179 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
104180 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
104181 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
104182 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
104183 +p54_init_common_23850 p54_init_common 1 23850 NULL
104184 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
104185 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
104186 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
104187 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
104188 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
104189 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
104190 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
104191 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
104192 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
104193 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
104194 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
104195 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
104196 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
104197 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
104198 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
104199 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
104200 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
104201 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
104202 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
104203 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
104204 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
104205 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
104206 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
104207 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
104208 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
104209 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
104210 +mpu401_read_24126 mpu401_read 3 24126 NULL
104211 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
104212 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
104213 +set_discard_24162 set_discard 2 24162 NULL
104214 +adu_read_24177 adu_read 3 24177 NULL
104215 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
104216 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
104217 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
104218 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
104219 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
104220 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
104221 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
104222 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
104223 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
104224 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
104225 +thin_status_24278 thin_status 5 24278 NULL
104226 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
104227 +msg_size_24288 msg_size 0 24288 NULL
104228 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
104229 +map_page_24298 map_page 3-4 24298 NULL
104230 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
104231 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
104232 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
104233 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
104234 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
104235 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
104236 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
104237 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
104238 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
104239 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
104240 +igetword_24373 igetword 0 24373 NULL
104241 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
104242 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
104243 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
104244 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
104245 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
104246 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
104247 +smk_user_access_24440 smk_user_access 3 24440 NULL
104248 +page_address_24444 page_address 0 24444 NULL
104249 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
104250 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
104251 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
104252 +pd_video_read_24510 pd_video_read 3 24510 NULL
104253 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
104254 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
104255 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
104256 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
104257 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
104258 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
104259 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
104260 +count_preds_24600 count_preds 0 24600 NULL
104261 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
104262 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
104263 +context_alloc_24645 context_alloc 3 24645 NULL
104264 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
104265 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
104266 +read_fs_24717 read_fs 0 24717 NULL
104267 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
104268 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
104269 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
104270 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
104271 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
104272 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
104273 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
104274 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
104275 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
104276 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
104277 +cache_read_24790 cache_read 3 24790 NULL
104278 +unpack_str_24798 unpack_str 0 24798 NULL
104279 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
104280 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
104281 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
104282 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
104283 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
104284 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
104285 +setup_buffering_24872 setup_buffering 3 24872 NULL
104286 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
104287 +queues_read_24877 queues_read 3 24877 NULL nohasharray
104288 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
104289 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
104290 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
104291 +next_token_24929 next_token 0 24929 NULL
104292 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
104293 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
104294 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
104295 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
104296 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
104297 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
104298 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
104299 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
104300 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
104301 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
104302 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
104303 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
104304 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
104305 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
104306 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
104307 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
104308 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
104309 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
104310 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
104311 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
104312 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
104313 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
104314 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
104315 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
104316 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
104317 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
104318 +stripe_status_25259 stripe_status 5 25259 NULL
104319 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
104320 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
104321 +vfs_writev_25278 vfs_writev 3 25278 NULL
104322 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
104323 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
104324 +help_25316 help 5 25316 NULL nohasharray
104325 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
104326 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
104327 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
104328 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
104329 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
104330 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
104331 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
104332 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
104333 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
104334 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
104335 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
104336 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
104337 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
104338 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
104339 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
104340 +sb_permission_25523 sb_permission 0 25523 NULL
104341 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
104342 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
104343 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
104344 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
104345 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
104346 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
104347 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
104348 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
104349 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
104350 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
104351 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
104352 +__direct_map_25647 __direct_map 5-6 25647 NULL
104353 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
104354 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
104355 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
104356 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
104357 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
104358 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
104359 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
104360 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
104361 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
104362 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
104363 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
104364 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
104365 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
104366 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
104367 +sg_read_25799 sg_read 3 25799 NULL
104368 +system_enable_read_25815 system_enable_read 3 25815 NULL
104369 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
104370 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
104371 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
104372 +parport_read_25855 parport_read 0 25855 NULL
104373 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
104374 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
104375 +key_attr_size_25865 key_attr_size 0 25865 NULL
104376 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
104377 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
104378 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
104379 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
104380 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
104381 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
104382 +rcname_read_25919 rcname_read 3 25919 NULL
104383 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
104384 +key_flags_read_25931 key_flags_read 3 25931 NULL
104385 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
104386 +flush_25957 flush 2 25957 NULL
104387 +video_register_device_25971 video_register_device 3 25971 NULL
104388 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
104389 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104390 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104391 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104392 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104393 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104394 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104395 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104396 +tun_do_read_26047 tun_do_read 5 26047 NULL
104397 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104398 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104399 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104400 +skb_cow_26138 skb_cow 2 26138 NULL
104401 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104402 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104403 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104404 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104405 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104406 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104407 +disk_devt_26180 disk_devt 0 26180 NULL
104408 +get_registers_26187 get_registers 3 26187 NULL
104409 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104410 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104411 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104412 +mce_write_26201 mce_write 3 26201 NULL
104413 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104414 +bio_split_26235 bio_split 2 26235 NULL
104415 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104416 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104417 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104418 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104419 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104420 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104421 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104422 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104423 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104424 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104425 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104426 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104427 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104428 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104429 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104430 +read_vmcore_26501 read_vmcore 3 26501 NULL
104431 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104432 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104433 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104434 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104435 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104436 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104437 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104438 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104439 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104440 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104441 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104442 +pack_value_26625 pack_value 1 26625 NULL
104443 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104444 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104445 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104446 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104447 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104448 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104449 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104450 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104451 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104452 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104453 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104454 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104455 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104456 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104457 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104458 +smk_write_load_26829 smk_write_load 3 26829 NULL
104459 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104460 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104461 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104462 +scnprint_id_26842 scnprint_id 3 26842 NULL
104463 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104464 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104465 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104466 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104467 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104468 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104469 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104470 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104471 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104472 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104473 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104474 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104475 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104476 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104477 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104478 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104479 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104480 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104481 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104482 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104483 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104484 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104485 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104486 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104487 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104488 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104489 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104490 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104491 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104492 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104493 +pms_capture_27142 pms_capture 4 27142 NULL
104494 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104495 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104496 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104497 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104498 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104499 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104500 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104501 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104502 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104503 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104504 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104505 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104506 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104507 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104508 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104509 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104510 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104511 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104512 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104513 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104514 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104515 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104516 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104517 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104518 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104519 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104520 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104521 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104522 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104523 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104524 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104525 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104526 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104527 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104528 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104529 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104530 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104531 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104532 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104533 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104534 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104535 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104536 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104537 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104538 +qword_get_27670 qword_get 0 27670 NULL
104539 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104540 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104541 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104542 +evm_write_key_27715 evm_write_key 3 27715 NULL
104543 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104544 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104545 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104546 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104547 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104548 +kcalloc_27770 kcalloc 1-2 27770 NULL
104549 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104550 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104551 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104552 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104553 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104554 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104555 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104556 +read_profile_27859 read_profile 3 27859 NULL
104557 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104558 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104559 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104560 +gluebi_write_27905 gluebi_write 3 27905 NULL
104561 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104562 +bm_find_next_27929 bm_find_next 2 27929 NULL
104563 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104564 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104565 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104566 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104567 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104568 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104569 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104570 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104571 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104572 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104573 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104574 +pool_status_28055 pool_status 5 28055 NULL
104575 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104576 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104577 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104578 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104579 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104580 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104581 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104582 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104583 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104584 +video_read_28148 video_read 3 28148 NULL
104585 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104586 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104587 +vread_28173 vread 0 28173 NULL
104588 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104589 +d_path_28198 d_path 0 28198 NULL
104590 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104591 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104592 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104593 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104594 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104595 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104596 +usemap_size_28281 usemap_size 0 28281 NULL
104597 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104598 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104599 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104600 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104601 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104602 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104603 +snapshot_write_28351 snapshot_write 3 28351 NULL
104604 +sys_writev_28384 sys_writev 3 28384 NULL
104605 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104606 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104607 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104608 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104609 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104610 +__split_large_page_28429 __split_large_page 2 28429 NULL
104611 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104612 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104613 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104614 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104615 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104616 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104617 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104618 +max_response_pages_28492 max_response_pages 0 28492 NULL
104619 +clear_discard_28494 clear_discard 2 28494 NULL
104620 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104621 +__next_node_28521 __next_node 1 28521 NULL
104622 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104623 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104624 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104625 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104626 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104627 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104628 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104629 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104630 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104631 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104632 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104633 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104634 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104635 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104636 +_set_range_28627 _set_range 3 28627 NULL
104637 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104638 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104639 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104640 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104641 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104642 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104643 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104644 +spi_execute_28736 spi_execute 5 28736 NULL
104645 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104646 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104647 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104648 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104649 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104650 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104651 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104652 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104653 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104654 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104655 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104656 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104657 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104658 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104659 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104660 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104661 +to_cblock_28899 to_cblock 0-1 28899 NULL
104662 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104663 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104664 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104665 +push_rx_28939 push_rx 3 28939 NULL
104666 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104667 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104668 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104669 +bin_uuid_28999 bin_uuid 3 28999 NULL
104670 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104671 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104672 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104673 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104674 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104675 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104676 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104677 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104678 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104679 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104680 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104681 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104682 +snprintf_29125 snprintf 0 29125 NULL
104683 +iov_shorten_29130 iov_shorten 0 29130 NULL
104684 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104685 +reshape_ring_29147 reshape_ring 2 29147 NULL
104686 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104687 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104688 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104689 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104690 +__mm_populate_29204 __mm_populate 1 29204 NULL
104691 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104692 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104693 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104694 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104695 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104696 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104697 +recover_peb_29238 recover_peb 6-7 29238 NULL
104698 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104699 +block_div_29268 block_div 0-1-2 29268 NULL
104700 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104701 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104702 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104703 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104704 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104705 +tun_put_user_29337 tun_put_user 5 29337 NULL
104706 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104707 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104708 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104709 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104710 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104711 +mempool_create_29437 mempool_create 1 29437 NULL
104712 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104713 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104714 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104715 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104716 +do_register_entry_29478 do_register_entry 4 29478 NULL
104717 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104718 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104719 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104720 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104721 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104722 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104723 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104724 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104725 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104726 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104727 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104728 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104729 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104730 +slots_per_page_29601 slots_per_page 0 29601 NULL
104731 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104732 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104733 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104734 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104735 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104736 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104737 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104738 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104739 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104740 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104741 +probes_write_29711 probes_write 3 29711 NULL
104742 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104743 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104744 +std_nic_write_29752 std_nic_write 3 29752 NULL
104745 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104746 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104747 +dbAlloc_29794 dbAlloc 0 29794 NULL
104748 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104749 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104750 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104751 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104752 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104753 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104754 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104755 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104756 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104757 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104758 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104759 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104760 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104761 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104762 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104763 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104764 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104765 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104766 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104767 +drp_wmove_30043 drp_wmove 4 30043 NULL
104768 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104769 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104770 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104771 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104772 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104773 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104774 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104775 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104776 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104777 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104778 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104779 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104780 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104781 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104782 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104783 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104784 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104785 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104786 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104787 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104788 +compat_readv_30273 compat_readv 3 30273 NULL
104789 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104790 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104791 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104792 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104793 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104794 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104795 +resource_from_user_30341 resource_from_user 3 30341 NULL
104796 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104797 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104798 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104799 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104800 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104801 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104802 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104803 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104804 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104805 +mq_create_30425 mq_create 1 30425 NULL
104806 +enable_write_30456 enable_write 3 30456 NULL
104807 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104808 +urandom_read_30462 urandom_read 3 30462 NULL
104809 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104810 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104811 +write_head_30481 write_head 4 30481 NULL
104812 +adu_write_30487 adu_write 3 30487 NULL
104813 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104814 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104815 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104816 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104817 +set_le_30581 set_le 4 30581 NULL
104818 +from_cblock_30582 from_cblock 0-1 30582 NULL
104819 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104820 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104821 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104822 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104823 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104824 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104825 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104826 +agp_remap_30665 agp_remap 2 30665 NULL
104827 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104828 +il_free_pages_30692 il_free_pages 2 30692 NULL
104829 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104830 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104831 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104832 +snapshot_status_30744 snapshot_status 5 30744 NULL
104833 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104834 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104835 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104836 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104837 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104838 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104839 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104840 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104841 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104842 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104843 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104844 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104845 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104846 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104847 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104848 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104849 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104850 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104851 +sys_mincore_31079 sys_mincore 1 31079 NULL
104852 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104853 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104854 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104855 +depth_read_31112 depth_read 3 31112 NULL
104856 +ssb_read16_31139 ssb_read16 0 31139 NULL
104857 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104858 +size_inside_page_31141 size_inside_page 0 31141 NULL
104859 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104860 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104861 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104862 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104863 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104864 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104865 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104866 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104867 +__read_reg_31216 __read_reg 0 31216 NULL
104868 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104869 +cyy_readb_31240 cyy_readb 0 31240 NULL
104870 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104871 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104872 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104873 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104874 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104875 +command_file_write_31318 command_file_write 3 31318 NULL
104876 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104877 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104878 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104879 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104880 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104881 +inb_31388 inb 0 31388 NULL
104882 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104883 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104884 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104885 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104886 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104887 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104888 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104889 +do_fcntl_31468 do_fcntl 3 31468 NULL
104890 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104891 +alg_setkey_31485 alg_setkey 3 31485 NULL
104892 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104893 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104894 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104895 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104896 +hidraw_write_31536 hidraw_write 3 31536 NULL
104897 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104898 +usbvision_read_31555 usbvision_read 3 31555 NULL
104899 +normalize_31566 normalize 0-1-2 31566 NULL
104900 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104901 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104902 +osst_write_31581 osst_write 3 31581 NULL
104903 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104904 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104905 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104906 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104907 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104908 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104909 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104910 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104911 +__lgread_31668 __lgread 4 31668 NULL
104912 +symbol_string_31670 symbol_string 0 31670 NULL
104913 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104914 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104915 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104916 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104917 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104918 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104919 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104920 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104921 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104922 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104923 +muldiv64_31743 muldiv64 2-3 31743 NULL
104924 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104925 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104926 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104927 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104928 +get_count_order_31800 get_count_order 0 31800 NULL
104929 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104930 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104931 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104932 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104933 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104934 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104935 +xattr_permission_31907 xattr_permission 0 31907 NULL
104936 +new_dir_31919 new_dir 3 31919 NULL
104937 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104938 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104939 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104940 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104941 +vb2_write_31948 vb2_write 3 31948 NULL
104942 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
104943 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
104944 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
104945 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
104946 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
104947 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
104948 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
104949 +calc_hmac_32010 calc_hmac 3 32010 NULL
104950 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
104951 +aead_len_32021 aead_len 0 32021 NULL
104952 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
104953 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
104954 +stk_read_32038 stk_read 3 32038 NULL
104955 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
104956 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
104957 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
104958 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
104959 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
104960 +bio_alloc_32095 bio_alloc 2 32095 NULL
104961 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
104962 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
104963 +disk_status_32120 disk_status 4 32120 NULL
104964 +venus_link_32165 venus_link 5 32165 NULL
104965 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
104966 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
104967 +load_header_32183 load_header 0 32183 NULL
104968 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
104969 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
104970 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
104971 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
104972 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
104973 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
104974 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
104975 +hex_string_32310 hex_string 0 32310 NULL
104976 +SyS_select_32319 SyS_select 1 32319 NULL
104977 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
104978 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
104979 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
104980 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
104981 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
104982 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
104983 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
104984 +local_clock_32385 local_clock 0 32385 NULL
104985 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
104986 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
104987 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
104988 +log_text_32428 log_text 0 32428 NULL
104989 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
104990 +hid_input_report_32458 hid_input_report 4 32458 NULL
104991 +cache_status_32462 cache_status 5 32462 NULL
104992 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
104993 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
104994 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
104995 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
104996 +disconnect_32521 disconnect 4 32521 NULL
104997 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
104998 +ilo_read_32531 ilo_read 3 32531 NULL
104999 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
105000 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
105001 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
105002 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
105003 +__first_node_32558 __first_node 0 32558 NULL
105004 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
105005 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
105006 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
105007 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
105008 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
105009 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
105010 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
105011 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
105012 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
105013 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
105014 +kvmalloc_32646 kvmalloc 1 32646 NULL
105015 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
105016 +generic_readlink_32654 generic_readlink 3 32654 NULL
105017 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
105018 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
105019 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
105020 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
105021 +get_arg_page_32746 get_arg_page 2 32746 NULL
105022 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
105023 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
105024 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
105025 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
105026 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
105027 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
105028 +vga_rseq_32848 vga_rseq 0 32848 NULL
105029 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
105030 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
105031 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
105032 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
105033 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
105034 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
105035 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
105036 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
105037 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
105038 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
105039 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
105040 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
105041 +compat_filldir_32999 compat_filldir 3 32999 NULL
105042 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
105043 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
105044 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
105045 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
105046 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
105047 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
105048 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
105049 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
105050 +alloc_tio_33077 alloc_tio 3 33077 NULL
105051 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
105052 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
105053 +write_node_33121 write_node 4 33121 NULL
105054 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
105055 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
105056 +__len_within_target_33132 __len_within_target 0 33132 NULL
105057 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
105058 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
105059 +pp_read_33210 pp_read 3 33210 NULL
105060 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
105061 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
105062 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
105063 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
105064 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
105065 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
105066 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
105067 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
105068 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
105069 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
105070 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
105071 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
105072 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
105073 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
105074 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
105075 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
105076 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
105077 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
105078 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
105079 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
105080 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
105081 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
105082 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
105083 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
105084 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
105085 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
105086 +create_entry_33479 create_entry 2 33479 NULL
105087 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
105088 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
105089 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
105090 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
105091 +res_counter_read_33499 res_counter_read 4 33499 NULL
105092 +fb_read_33506 fb_read 3 33506 NULL
105093 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
105094 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
105095 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
105096 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
105097 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
105098 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
105099 +dup_array_33551 dup_array 3 33551 NULL
105100 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
105101 +count_subheaders_33591 count_subheaders 0 33591 NULL
105102 +scsi_execute_33596 scsi_execute 5 33596 NULL
105103 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
105104 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
105105 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
105106 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
105107 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
105108 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
105109 +inw_p_33668 inw_p 0 33668 NULL
105110 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
105111 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
105112 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
105113 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
105114 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
105115 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
105116 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
105117 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
105118 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
105119 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
105120 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
105121 +Read_hfc_33755 Read_hfc 0 33755 NULL
105122 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
105123 +hashtab_create_33769 hashtab_create 3 33769 NULL
105124 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
105125 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
105126 +find_next_offset_33804 find_next_offset 3 33804 NULL
105127 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
105128 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
105129 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
105130 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
105131 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
105132 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
105133 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
105134 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
105135 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
105136 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
105137 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
105138 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
105139 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
105140 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
105141 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
105142 +ppp_write_34034 ppp_write 3 34034 NULL
105143 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
105144 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
105145 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
105146 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
105147 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
105148 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
105149 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
105150 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
105151 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
105152 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
105153 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
105154 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
105155 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
105156 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
105157 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
105158 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
105159 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
105160 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
105161 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
105162 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
105163 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
105164 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
105165 +__insert_34349 __insert 2-3 34349 NULL
105166 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
105167 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
105168 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
105169 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
105170 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
105171 +ea_read_34378 ea_read 0 34378 NULL
105172 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
105173 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
105174 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
105175 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
105176 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
105177 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
105178 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
105179 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
105180 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
105181 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
105182 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
105183 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
105184 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
105185 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
105186 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
105187 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
105188 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
105189 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
105190 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
105191 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
105192 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
105193 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
105194 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
105195 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
105196 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
105197 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
105198 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
105199 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
105200 +port_print_34704 port_print 3 34704 NULL
105201 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
105202 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
105203 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
105204 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
105205 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
105206 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
105207 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
105208 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
105209 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
105210 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
105211 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
105212 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
105213 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
105214 +msg_print_text_34889 msg_print_text 0 34889 NULL
105215 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
105216 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
105217 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
105218 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
105219 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
105220 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
105221 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
105222 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
105223 +Realloc_34961 Realloc 2 34961 NULL
105224 +mq_lookup_34990 mq_lookup 2 34990 NULL
105225 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
105226 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
105227 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
105228 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
105229 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
105230 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
105231 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
105232 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
105233 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
105234 +store_ifalias_35088 store_ifalias 4 35088 NULL
105235 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
105236 +capi_write_35104 capi_write 3 35104 NULL nohasharray
105237 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
105238 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
105239 +pointer_35138 pointer 0 35138 NULL
105240 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
105241 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
105242 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
105243 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
105244 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
105245 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
105246 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
105247 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
105248 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
105249 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
105250 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
105251 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
105252 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
105253 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
105254 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
105255 +set_fd_set_35249 set_fd_set 1 35249 NULL
105256 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
105257 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
105258 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
105259 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
105260 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
105261 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
105262 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
105263 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
105264 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
105265 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
105266 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
105267 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
105268 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
105269 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
105270 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
105271 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
105272 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
105273 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
105274 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
105275 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
105276 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
105277 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
105278 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
105279 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
105280 +async_setkey_35521 async_setkey 3 35521 NULL
105281 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
105282 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
105283 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
105284 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
105285 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
105286 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
105287 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
105288 +ReadZReg_35604 ReadZReg 0 35604 NULL
105289 +kernel_readv_35617 kernel_readv 3 35617 NULL
105290 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
105291 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
105292 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
105293 +store_debug_level_35652 store_debug_level 3 35652 NULL
105294 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
105295 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
105296 +dm_table_create_35687 dm_table_create 3 35687 NULL
105297 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
105298 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
105299 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
105300 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
105301 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
105302 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
105303 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
105304 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
105305 +fls64_35862 fls64 0 35862 NULL
105306 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
105307 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
105308 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
105309 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
105310 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
105311 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
105312 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
105313 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
105314 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
105315 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
105316 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
105317 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
105318 +acl_alloc_35979 acl_alloc 1 35979 NULL
105319 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
105320 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
105321 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
105322 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
105323 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
105324 +account_shadowed_36048 account_shadowed 2 36048 NULL
105325 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
105326 +write_emulate_36065 write_emulate 2-4 36065 NULL
105327 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
105328 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
105329 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
105330 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
105331 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
105332 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
105333 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
105334 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
105335 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
105336 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
105337 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
105338 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
105339 +twl_set_36154 twl_set 2 36154 NULL
105340 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
105341 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
105342 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
105343 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
105344 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
105345 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
105346 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
105347 +is_dirty_36223 is_dirty 2 36223 NULL
105348 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
105349 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
105350 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
105351 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
105352 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
105353 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
105354 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
105355 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
105356 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
105357 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
105358 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
105359 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
105360 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
105361 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
105362 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
105363 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
105364 +lc_create_36332 lc_create 4 36332 NULL
105365 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
105366 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
105367 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
105368 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
105369 +to_sector_36361 to_sector 0-1 36361 NULL
105370 +tunables_read_36385 tunables_read 3 36385 NULL
105371 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
105372 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
105373 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
105374 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
105375 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
105376 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
105377 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
105378 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
105379 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
105380 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
105381 +get_param_l_36518 get_param_l 0 36518 NULL
105382 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
105383 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
105384 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
105385 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
105386 +get_entry_len_36549 get_entry_len 0 36549 NULL
105387 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
105388 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
105389 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105390 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105391 +__erst_read_36579 __erst_read 0 36579 NULL
105392 +put_cmsg_36589 put_cmsg 4 36589 NULL
105393 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105394 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105395 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105396 +format_decode_36638 format_decode 0 36638 NULL
105397 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105398 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105399 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105400 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105401 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105402 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105403 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105404 +sched_clock_36717 sched_clock 0 36717 NULL
105405 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105406 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105407 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105408 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105409 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105410 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105411 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105412 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105413 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105414 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105415 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105416 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105417 +cm_write_36858 cm_write 3 36858 NULL
105418 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105419 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105420 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105421 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105422 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105423 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105424 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105425 +build_key_36931 build_key 1 36931 NULL
105426 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105427 +write_leb_36957 write_leb 5 36957 NULL
105428 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105429 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105430 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105431 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105432 +setxattr_37006 setxattr 4 37006 NULL
105433 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105434 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105435 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105436 +parse_command_37079 parse_command 2 37079 NULL
105437 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105438 +tun_get_user_37094 tun_get_user 5 37094 NULL
105439 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105440 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105441 +msg_word_37164 msg_word 0 37164 NULL
105442 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105443 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105444 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105445 +__do_replace_37227 __do_replace 5 37227 NULL
105446 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105447 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105448 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105449 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105450 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105451 +c101_run_37279 c101_run 2 37279 NULL
105452 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105453 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105454 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105455 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105456 +send_msg_37323 send_msg 4 37323 NULL
105457 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105458 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105459 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105460 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105461 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105462 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105463 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105464 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105465 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105466 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105467 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105468 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105469 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105470 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105471 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105472 +__remove_37457 __remove 2 37457 NULL
105473 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105474 +get_est_timing_37484 get_est_timing 0 37484 NULL
105475 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105476 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105477 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105478 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105479 +hdr_size_37536 hdr_size 0 37536 NULL
105480 +a2p_37544 a2p 0-1 37544 NULL
105481 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105482 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105483 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105484 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105485 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105486 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105487 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105488 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105489 +check_pt_base_37635 check_pt_base 3 37635 NULL
105490 +alloc_fd_37637 alloc_fd 1 37637 NULL
105491 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105492 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105493 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105494 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105495 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105496 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105497 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105498 +nametbl_header_37698 nametbl_header 2 37698 NULL
105499 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105500 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105501 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105502 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105503 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105504 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105505 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105506 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105507 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105508 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105509 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105510 +deny_write_access_37813 deny_write_access 0 37813 NULL
105511 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105512 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105513 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105514 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105515 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105516 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105517 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105518 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105519 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105520 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105521 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105522 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105523 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105524 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105525 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105526 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105527 +vfs_readv_38011 vfs_readv 3 38011 NULL
105528 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105529 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105530 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105531 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105532 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105533 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105534 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105535 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105536 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105537 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105538 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105539 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105540 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105541 +ep0_read_38095 ep0_read 3 38095 NULL
105542 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105543 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105544 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105545 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105546 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105547 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105548 +cdev_add_38176 cdev_add 2-3 38176 NULL
105549 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105550 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105551 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105552 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105553 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105554 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105555 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105556 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105557 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105558 +from_dblock_38256 from_dblock 0-1 38256 NULL
105559 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105560 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105561 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105562 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105563 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105564 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105565 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105566 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105567 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105568 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105569 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105570 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105571 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105572 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105573 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105574 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105575 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105576 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105577 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105578 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105579 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105580 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105581 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105582 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105583 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105584 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105585 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105586 +dev_names_read_38509 dev_names_read 3 38509 NULL
105587 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105588 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105589 +set_queue_count_38519 set_queue_count 0 38519 NULL
105590 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105591 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105592 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105593 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105594 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105595 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105596 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105597 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105598 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105599 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105600 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105601 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105602 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105603 +cma_create_area_38642 cma_create_area 2 38642 NULL
105604 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105605 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105606 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105607 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105608 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105609 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105610 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105611 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105612 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105613 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105614 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105615 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105616 +udf_readpages_38761 udf_readpages 4 38761 NULL
105617 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105618 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105619 +err_decode_38804 err_decode 2 38804 NULL
105620 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105621 +sys_select_38827 sys_select 1 38827 NULL
105622 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105623 +direct_entry_38836 direct_entry 3 38836 NULL
105624 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105625 +interfaces_38859 interfaces 2 38859 NULL
105626 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105627 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105628 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105629 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105630 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105631 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105632 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105633 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105634 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105635 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105636 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105637 +udf_new_block_38999 udf_new_block 4 38999 NULL
105638 +get_nodes_39012 get_nodes 3 39012 NULL
105639 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105640 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105641 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105642 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105643 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105644 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105645 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105646 +ea_foreach_39133 ea_foreach 0 39133 NULL
105647 +generic_permission_39150 generic_permission 0 39150 NULL
105648 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105649 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105650 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105651 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105652 +init_list_set_39188 init_list_set 2-3 39188 NULL
105653 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105654 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105655 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105656 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105657 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105658 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105659 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105660 +drm_order_39244 drm_order 0 39244 NULL
105661 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105662 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105663 +__skb_cow_39254 __skb_cow 2 39254 NULL
105664 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105665 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105666 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105667 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105668 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105669 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105670 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105671 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105672 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105673 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105674 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105675 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105676 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105677 +__send_to_port_39386 __send_to_port 3 39386 NULL
105678 +user_power_read_39414 user_power_read 3 39414 NULL
105679 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105680 +sys_semop_39457 sys_semop 3 39457 NULL
105681 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105682 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105683 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105684 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105685 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105686 +int_proc_write_39542 int_proc_write 3 39542 NULL
105687 +pp_write_39554 pp_write 3 39554 NULL
105688 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105689 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105690 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105691 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105692 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105693 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105694 +ext_depth_39607 ext_depth 0 39607 NULL
105695 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105696 +sdio_readb_39618 sdio_readb 0 39618 NULL
105697 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105698 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105699 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105700 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105701 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105702 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105703 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105704 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105705 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105706 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105707 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105708 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105709 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105710 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105711 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105712 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105713 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105714 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105715 +pkt_add_39897 pkt_add 3 39897 NULL
105716 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105717 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105718 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105719 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105720 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105721 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105722 +__spi_async_39932 __spi_async 0 39932 NULL
105723 +__get_order_39935 __get_order 0 39935 NULL
105724 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105725 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105726 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105727 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105728 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105729 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105730 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105731 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105732 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105733 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105734 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105735 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105736 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105737 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105738 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105739 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105740 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105741 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105742 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105743 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105744 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105745 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105746 +pt_write_40159 pt_write 3 40159 NULL
105747 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105748 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105749 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105750 +allocate_probes_40204 allocate_probes 1 40204 NULL
105751 +compat_put_long_40214 compat_put_long 1 40214 NULL
105752 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105753 +osst_read_40237 osst_read 3 40237 NULL
105754 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105755 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105756 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105757 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105758 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105759 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105760 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105761 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105762 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105763 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105764 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105765 +mmio_read_40348 mmio_read 4 40348 NULL
105766 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105767 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105768 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105769 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105770 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105771 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105772 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105773 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105774 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105775 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105776 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105777 +tty_write_room_40495 tty_write_room 0 40495 NULL
105778 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105779 +sg_phys_40507 sg_phys 0 40507 NULL
105780 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105781 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105782 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105783 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105784 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105785 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105786 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105787 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105788 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105789 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105790 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105791 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105792 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105793 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105794 +fops_read_40672 fops_read 3 40672 NULL
105795 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105796 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105797 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105798 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105799 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105800 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105801 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105802 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105803 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105804 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105805 +card_send_command_40757 card_send_command 3 40757 NULL
105806 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105807 +pg_write_40766 pg_write 3 40766 NULL
105808 +show_list_40775 show_list 3 40775 NULL
105809 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105810 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105811 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105812 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105813 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105814 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105815 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105816 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105817 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105818 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105819 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105820 +read_file_queue_40895 read_file_queue 3 40895 NULL
105821 +waiters_read_40902 waiters_read 3 40902 NULL
105822 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105823 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105824 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105825 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105826 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105827 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105828 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105829 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105830 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105831 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105832 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105833 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105834 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105835 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105836 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105837 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105838 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105839 +dma_attach_41094 dma_attach 5-6 41094 NULL
105840 +provide_user_output_41105 provide_user_output 3 41105 NULL
105841 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105842 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105843 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105844 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105845 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105846 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105847 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105848 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105849 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105850 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105851 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105852 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105853 +erst_read_41260 erst_read 0 41260 NULL
105854 +__fprog_create_41263 __fprog_create 2 41263 NULL
105855 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105856 +alloc_context_41283 alloc_context 1 41283 NULL
105857 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105858 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105859 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105860 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105861 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105862 +kmp_init_41373 kmp_init 2 41373 NULL
105863 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105864 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105865 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105866 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105867 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105868 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105869 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105870 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105871 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105872 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105873 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105874 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105875 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105876 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105877 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105878 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105879 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105880 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105881 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105882 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105883 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105884 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105885 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105886 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105887 +vga_io_r_41609 vga_io_r 0 41609 NULL
105888 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105889 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105890 +a2mp_send_41615 a2mp_send 4 41615 NULL
105891 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105892 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105893 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105894 +get_std_timing_41654 get_std_timing 0 41654 NULL
105895 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105896 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105897 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105898 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105899 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105900 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105901 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105902 +fillonedir_41746 fillonedir 3 41746 NULL
105903 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105904 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105905 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105906 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105907 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105908 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105909 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105910 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105911 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105912 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105913 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105914 +get_packet_41914 get_packet 3 41914 NULL
105915 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105916 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105917 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105918 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105919 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105920 +read_gssp_41947 read_gssp 3 41947 NULL
105921 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105922 +portnames_read_41958 portnames_read 3 41958 NULL
105923 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105924 +dst_mtu_41969 dst_mtu 0 41969 NULL
105925 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105926 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105927 +lguest_map_42008 lguest_map 1-2 42008 NULL
105928 +pool_allocate_42012 pool_allocate 3 42012 NULL
105929 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105930 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105931 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105932 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105933 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105934 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105935 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105936 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105937 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105938 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105939 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105940 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105941 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
105942 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
105943 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
105944 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
105945 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
105946 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
105947 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
105948 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
105949 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
105950 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
105951 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
105952 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
105953 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
105954 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
105955 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
105956 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
105957 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
105958 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
105959 +free_cblock_42318 free_cblock 2 42318 NULL
105960 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
105961 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
105962 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
105963 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
105964 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
105965 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
105966 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
105967 +krng_get_random_42420 krng_get_random 3 42420 NULL
105968 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
105969 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
105970 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
105971 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
105972 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
105973 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
105974 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
105975 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
105976 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
105977 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
105978 +bypass_write_42498 bypass_write 3 42498 NULL
105979 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
105980 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
105981 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
105982 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
105983 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
105984 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
105985 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
105986 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
105987 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
105988 +map_state_42602 map_state 1 42602 NULL nohasharray
105989 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
105990 +nd_get_link_42603 nd_get_link 0 42603 NULL
105991 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
105992 +resp_write_42628 resp_write 2 42628 NULL
105993 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
105994 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
105995 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
105996 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
105997 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
105998 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
105999 +vb2_read_42703 vb2_read 3 42703 NULL
106000 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
106001 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
106002 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
106003 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
106004 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
106005 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
106006 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
106007 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
106008 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
106009 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
106010 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
106011 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
106012 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
106013 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
106014 +set_arg_42824 set_arg 3 42824 NULL
106015 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
106016 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
106017 +prandom_u32_42853 prandom_u32 0 42853 NULL
106018 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
106019 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
106020 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
106021 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
106022 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
106023 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
106024 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
106025 +hd_end_request_42904 hd_end_request 2 42904 NULL
106026 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
106027 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
106028 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
106029 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
106030 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
106031 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
106032 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
106033 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
106034 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
106035 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
106036 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
106037 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
106038 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
106039 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
106040 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
106041 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
106042 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
106043 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
106044 +uuid_string_43154 uuid_string 0 43154 NULL
106045 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
106046 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
106047 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
106048 +process_measurement_43190 process_measurement 0 43190 NULL
106049 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
106050 +uio_write_43202 uio_write 3 43202 NULL
106051 +iso_callback_43208 iso_callback 3 43208 NULL
106052 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
106053 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
106054 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
106055 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
106056 +fixup_leb_43256 fixup_leb 3 43256 NULL
106057 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
106058 +evtchn_write_43278 evtchn_write 3 43278 NULL
106059 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
106060 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
106061 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
106062 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
106063 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
106064 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
106065 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
106066 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
106067 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
106068 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
106069 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
106070 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
106071 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
106072 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
106073 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
106074 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
106075 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
106076 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
106077 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
106078 +do_readlink_43518 do_readlink 2 43518 NULL
106079 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
106080 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
106081 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
106082 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
106083 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
106084 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
106085 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
106086 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
106087 +proc_read_43614 proc_read 3 43614 NULL
106088 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
106089 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
106090 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
106091 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
106092 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
106093 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
106094 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
106095 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
106096 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
106097 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
106098 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
106099 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
106100 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
106101 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
106102 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
106103 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
106104 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
106105 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
106106 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
106107 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
106108 +read_flush_43851 read_flush 3 43851 NULL
106109 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
106110 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
106111 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
106112 +SendString_43928 SendString 3 43928 NULL
106113 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
106114 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
106115 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
106116 +nla_reserve_43984 nla_reserve 3 43984 NULL
106117 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
106118 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
106119 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
106120 +emit_flags_44006 emit_flags 4-3 44006 NULL
106121 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
106122 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
106123 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
106124 +load_discard_44083 load_discard 3 44083 NULL
106125 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
106126 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
106127 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
106128 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
106129 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
106130 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
106131 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
106132 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
106133 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
106134 +__set_free_44211 __set_free 2 44211 NULL
106135 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
106136 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
106137 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
106138 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
106139 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
106140 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
106141 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
106142 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
106143 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
106144 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
106145 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
106146 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
106147 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
106148 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
106149 +__is_discarded_44359 __is_discarded 2 44359 NULL
106150 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
106151 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
106152 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
106153 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
106154 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
106155 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
106156 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
106157 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
106158 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
106159 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
106160 +bio_advance_44496 bio_advance 2 44496 NULL
106161 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
106162 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
106163 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
106164 +spidev_write_44510 spidev_write 3 44510 NULL
106165 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
106166 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
106167 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
106168 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
106169 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
106170 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
106171 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
106172 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
106173 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
106174 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
106175 +mpi_resize_44674 mpi_resize 2 44674 NULL
106176 +ts_read_44687 ts_read 3 44687 NULL
106177 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
106178 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
106179 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
106180 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
106181 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
106182 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
106183 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
106184 +set_brk_44749 set_brk 1 44749 NULL
106185 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
106186 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
106187 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
106188 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
106189 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
106190 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
106191 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
106192 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
106193 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
106194 +sisusb_write_44834 sisusb_write 3 44834 NULL
106195 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
106196 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
106197 +cubic_root_44848 cubic_root 1 44848 NULL
106198 +copydesc_user_44855 copydesc_user 3 44855 NULL
106199 +skb_availroom_44883 skb_availroom 0 44883 NULL
106200 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
106201 +do_tty_write_44896 do_tty_write 5 44896 NULL
106202 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
106203 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
106204 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
106205 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
106206 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
106207 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
106208 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
106209 +sel_write_user_45060 sel_write_user 3 45060 NULL
106210 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
106211 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
106212 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
106213 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
106214 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
106215 +usbdev_read_45114 usbdev_read 3 45114 NULL
106216 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
106217 +send_to_tty_45141 send_to_tty 3 45141 NULL
106218 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
106219 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
106220 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
106221 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
106222 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
106223 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
106224 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
106225 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
106226 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
106227 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
106228 +add_child_45201 add_child 4 45201 NULL
106229 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
106230 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
106231 +__dirty_45228 __dirty 2 45228 NULL
106232 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
106233 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
106234 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
106235 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
106236 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
106237 +pte_val_45313 pte_val 0 45313 NULL
106238 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
106239 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
106240 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
106241 +keymap_store_45406 keymap_store 4 45406 NULL
106242 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
106243 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
106244 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
106245 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
106246 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
106247 +__node_remap_45458 __node_remap 4 45458 NULL
106248 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
106249 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
106250 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
106251 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
106252 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
106253 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
106254 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
106255 +copy_macs_45534 copy_macs 4 45534 NULL
106256 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
106257 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
106258 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
106259 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
106260 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
106261 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
106262 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
106263 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
106264 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
106265 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
106266 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
106267 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
106268 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
106269 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
106270 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
106271 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
106272 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
106273 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
106274 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
106275 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
106276 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
106277 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
106278 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
106279 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
106280 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
106281 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
106282 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
106283 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
106284 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
106285 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
106286 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
106287 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
106288 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
106289 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
106290 +isdn_write_45863 isdn_write 3 45863 NULL
106291 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
106292 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
106293 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
106294 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
106295 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
106296 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
106297 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
106298 +alloc_mr_45935 alloc_mr 1 45935 NULL
106299 +split_large_page_45941 split_large_page 2 45941 NULL
106300 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
106301 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
106302 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
106303 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
106304 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
106305 +get_free_entries_46030 get_free_entries 1 46030 NULL
106306 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
106307 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
106308 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
106309 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
106310 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
106311 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
106312 +slhc_toss_46066 slhc_toss 0 46066 NULL
106313 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
106314 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
106315 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
106316 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
106317 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
106318 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
106319 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
106320 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
106321 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
106322 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
106323 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
106324 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
106325 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
106326 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
106327 +add_conn_list_46197 add_conn_list 3 46197 NULL
106328 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
106329 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
106330 +dsp_write_46218 dsp_write 2 46218 NULL
106331 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
106332 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
106333 +ReadReg_46277 ReadReg 0 46277 NULL
106334 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
106335 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
106336 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
106337 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
106338 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
106339 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
106340 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
106341 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
106342 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
106343 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
106344 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
106345 +filldir64_46469 filldir64 3 46469 NULL
106346 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
106347 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
106348 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
106349 +kmsg_read_46514 kmsg_read 3 46514 NULL
106350 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
106351 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
106352 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
106353 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
106354 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
106355 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
106356 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
106357 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
106358 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
106359 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
106360 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
106361 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
106362 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
106363 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
106364 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
106365 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
106366 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
106367 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
106368 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
106369 +prepare_copy_46725 prepare_copy 2 46725 NULL
106370 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
106371 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
106372 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
106373 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
106374 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
106375 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
106376 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
106377 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
106378 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
106379 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
106380 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
106381 +spi_async_46857 spi_async 0 46857 NULL
106382 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
106383 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
106384 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
106385 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
106386 +rvmalloc_46873 rvmalloc 1 46873 NULL
106387 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
106388 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
106389 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106390 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106391 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106392 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106393 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106394 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106395 +fb_write_46924 fb_write 3 46924 NULL
106396 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106397 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106398 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106399 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106400 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106401 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106402 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106403 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106404 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106405 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106406 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106407 +__map_single_47020 __map_single 3-4-7 47020 NULL
106408 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106409 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106410 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106411 +fs_path_len_47060 fs_path_len 0 47060 NULL
106412 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106413 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106414 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106415 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106416 +mousedev_read_47123 mousedev_read 3 47123 NULL
106417 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106418 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106419 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106420 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106421 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106422 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106423 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106424 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106425 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106426 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106427 +l2headersize_47238 l2headersize 0 47238 NULL
106428 +options_write_47243 options_write 3 47243 NULL
106429 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106430 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106431 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106432 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106433 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106434 +vsnprintf_47291 vsnprintf 0 47291 NULL
106435 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106436 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106437 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106438 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106439 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106440 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106441 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106442 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106443 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106444 +nametbl_list_47391 nametbl_list 2 47391 NULL
106445 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106446 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106447 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106448 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106449 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106450 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106451 +vzalloc_47421 vzalloc 1 47421 NULL
106452 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106453 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106454 +__load_mapping_47460 __load_mapping 2 47460 NULL
106455 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106456 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106457 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106458 +core_sys_select_47494 core_sys_select 1 47494 NULL
106459 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106460 +unlink_simple_47506 unlink_simple 3 47506 NULL
106461 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106462 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106463 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106464 +oz_events_read_47535 oz_events_read 3 47535 NULL
106465 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106466 +read_ldt_47570 read_ldt 2 47570 NULL
106467 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106468 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106469 +pci_iomap_47575 pci_iomap 3 47575 NULL
106470 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106471 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106472 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106473 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106474 +uea_request_47613 uea_request 4 47613 NULL
106475 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106476 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106477 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106478 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106479 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106480 +save_microcode_47717 save_microcode 3 47717 NULL
106481 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106482 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106483 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106484 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106485 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106486 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106487 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106488 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106489 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106490 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106491 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106492 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106493 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106494 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106495 +vhci_read_47878 vhci_read 3 47878 NULL
106496 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106497 +load_mapping_47904 load_mapping 3 47904 NULL
106498 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106499 +comedi_write_47926 comedi_write 3 47926 NULL
106500 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106501 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106502 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106503 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106504 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106505 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106506 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106507 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106508 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106509 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106510 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106511 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106512 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106513 +disc_write_48070 disc_write 3 48070 NULL
106514 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106515 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106516 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106517 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106518 +set_discoverable_48141 set_discoverable 4 48141 NULL
106519 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106520 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106521 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106522 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106523 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106524 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106525 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106526 +init_ipath_48187 init_ipath 1 48187 NULL
106527 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106528 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106529 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106530 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106531 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106532 +read_file_recv_48232 read_file_recv 3 48232 NULL
106533 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106534 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106535 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106536 +send_set_info_48288 send_set_info 7 48288 NULL
106537 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106538 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106539 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106540 +hash_setkey_48310 hash_setkey 3 48310 NULL
106541 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106542 +skb_add_data_48363 skb_add_data 3 48363 NULL
106543 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106544 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106545 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106546 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106547 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106548 +print_filtered_48442 print_filtered 2-0 48442 NULL
106549 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106550 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106551 +send_control_msg_48498 send_control_msg 6 48498 NULL
106552 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106553 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106554 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106555 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106556 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106557 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106558 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106559 +named_distribute_48544 named_distribute 4 48544 NULL
106560 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106561 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106562 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106563 +mtd_read_48655 mtd_read 0 48655 NULL
106564 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106565 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106566 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106567 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106568 +altera_drscan_48698 altera_drscan 2 48698 NULL
106569 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106570 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106571 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106572 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106573 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106574 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106575 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106576 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106577 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106578 +azx_get_position_48841 azx_get_position 0 48841 NULL
106579 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106580 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106581 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106582 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106583 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106584 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106585 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106586 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106587 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106588 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106589 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106590 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106591 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106592 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106593 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106594 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106595 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106596 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106597 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106598 +transient_status_49027 transient_status 4 49027 NULL
106599 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106600 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106601 +ubi_read_49061 ubi_read 0 49061 NULL
106602 +scsi_register_49094 scsi_register 2 49094 NULL
106603 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106604 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106605 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106606 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106607 +pt_read_49136 pt_read 3 49136 NULL
106608 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106609 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106610 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106611 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106612 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106613 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106614 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106615 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106616 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106617 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106618 +resp_write_same_49217 resp_write_same 2 49217 NULL
106619 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106620 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106621 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106622 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106623 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106624 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106625 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106626 +uio_read_49300 uio_read 3 49300 NULL
106627 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106628 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106629 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106630 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106631 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106632 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106633 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106634 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106635 +px_raw_event_49371 px_raw_event 4 49371 NULL
106636 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106637 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106638 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106639 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106640 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106641 +md_domain_init_49432 md_domain_init 2 49432 NULL
106642 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106643 +get_lru_size_49441 get_lru_size 0 49441 NULL
106644 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106645 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106646 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106647 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106648 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106649 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106650 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106651 +smk_write_access_49561 smk_write_access 3 49561 NULL
106652 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106653 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106654 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106655 +tap_write_49595 tap_write 3 49595 NULL
106656 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106657 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106658 +heap_init_49617 heap_init 2 49617 NULL
106659 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106660 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106661 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106662 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106663 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106664 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106665 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106666 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106667 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106668 +check_frame_49741 check_frame 0 49741 NULL
106669 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106670 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106671 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106672 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106673 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106674 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106675 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106676 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106677 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106678 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106679 +add_uuid_49831 add_uuid 4 49831 NULL
106680 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106681 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106682 +twl4030_write_49846 twl4030_write 2 49846 NULL
106683 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106684 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106685 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106686 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106687 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106688 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106689 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106690 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106691 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106692 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106693 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106694 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106695 +__module_alloc_50004 __module_alloc 1 50004 NULL
106696 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106697 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106698 +isdn_read_50021 isdn_read 3 50021 NULL
106699 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106700 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106701 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106702 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106703 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106704 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106705 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106706 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106707 +read_file_slot_50111 read_file_slot 3 50111 NULL
106708 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106709 +copy_items_50140 copy_items 6 50140 NULL
106710 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106711 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106712 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106713 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106714 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106715 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106716 +odev_update_50169 odev_update 2 50169 NULL
106717 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106718 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106719 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106720 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106721 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106722 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106723 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106724 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106725 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106726 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106727 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106728 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106729 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106730 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106731 +do_launder_page_50329 do_launder_page 0 50329 NULL
106732 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106733 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106734 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106735 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106736 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106737 +tpm_read_50344 tpm_read 3 50344 NULL
106738 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106739 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106740 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106741 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106742 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106743 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106744 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106745 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106746 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106747 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106748 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106749 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106750 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106751 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106752 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106753 +force_mapping_50464 force_mapping 2 50464 NULL
106754 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106755 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106756 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106757 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106758 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106759 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106760 +fat_readpages_50582 fat_readpages 4 50582 NULL
106761 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106762 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106763 +sge_rx_50594 sge_rx 3 50594 NULL
106764 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106765 +__ffs_50625 __ffs 0 50625 NULL
106766 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106767 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106768 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106769 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106770 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106771 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106772 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106773 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106774 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106775 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106776 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106777 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106778 +skb_padto_50759 skb_padto 2 50759 NULL
106779 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106780 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106781 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106782 +tpm_write_50798 tpm_write 3 50798 NULL
106783 +write_flush_50803 write_flush 3 50803 NULL
106784 +dvb_play_50814 dvb_play 3 50814 NULL
106785 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106786 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106787 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106788 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106789 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106790 +self_check_write_50856 self_check_write 5 50856 NULL
106791 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106792 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106793 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106794 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106795 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106796 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106797 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106798 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106799 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106800 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106801 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106802 +timeout_write_50991 timeout_write 3 50991 NULL
106803 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106804 +proc_write_51003 proc_write 3 51003 NULL
106805 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106806 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106807 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106808 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106809 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106810 +dump_midi_51040 dump_midi 3 51040 NULL
106811 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106812 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106813 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106814 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106815 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106816 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106817 +ti_recv_51110 ti_recv 3 51110 NULL
106818 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106819 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106820 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106821 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106822 +set_dirty_51144 set_dirty 3 51144 NULL
106823 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106824 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106825 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106826 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106827 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106828 +tipc_send_51238 tipc_send 4 51238 NULL
106829 +drm_property_create_51239 drm_property_create 4 51239 NULL
106830 +st_read_51251 st_read 3 51251 NULL
106831 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106832 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106833 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106834 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106835 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106836 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106837 +get_cell_51316 get_cell 2 51316 NULL
106838 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106839 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106840 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106841 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106842 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106843 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106844 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106845 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106846 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106847 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106848 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106849 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106850 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106851 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106852 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106853 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106854 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106855 +vaddr_51480 vaddr 0 51480 NULL
106856 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106857 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106858 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106859 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106860 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106861 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106862 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106863 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106864 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106865 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106866 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106867 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106868 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106869 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106870 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106871 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106872 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106873 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106874 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106875 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106876 +sel_write_access_51704 sel_write_access 3 51704 NULL
106877 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106878 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106879 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106880 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106881 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106882 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106883 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106884 +if_write_51756 if_write 3 51756 NULL
106885 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106886 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106887 +to_ratio_51809 to_ratio 2-1 51809 NULL
106888 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106889 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106890 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106891 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106892 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106893 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106894 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106895 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106896 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106897 +user_read_51881 user_read 3 51881 NULL
106898 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106899 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106900 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106901 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106902 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106903 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106904 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106905 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106906 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106907 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106908 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106909 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106910 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106911 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106912 +rdmalt_52022 rdmalt 0 52022 NULL
106913 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106914 +override_release_52032 override_release 2 52032 NULL
106915 +end_port_52042 end_port 0 52042 NULL
106916 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106917 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106918 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106919 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106920 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106921 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106922 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106923 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106924 +retry_count_read_52129 retry_count_read 3 52129 NULL
106925 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106926 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106927 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106928 +htable_size_52148 htable_size 0-1 52148 NULL
106929 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106930 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106931 +alix_present_52165 alix_present 1 52165 NULL
106932 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106933 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106934 +print_prefix_52176 print_prefix 0 52176 NULL
106935 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106936 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106937 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106938 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106939 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106940 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106941 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
106942 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
106943 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
106944 +atomic64_read_52300 atomic64_read 0 52300 NULL
106945 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
106946 +read_file_reset_52310 read_file_reset 3 52310 NULL
106947 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
106948 +hwflags_read_52318 hwflags_read 3 52318 NULL
106949 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
106950 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
106951 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
106952 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
106953 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
106954 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
106955 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
106956 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
106957 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
106958 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
106959 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
106960 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
106961 +delay_status_52431 delay_status 5 52431 NULL
106962 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
106963 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
106964 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
106965 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
106966 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
106967 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
106968 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
106969 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
106970 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
106971 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
106972 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
106973 +from_oblock_52546 from_oblock 0-1 52546 NULL
106974 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
106975 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
106976 +emit_code_52583 emit_code 0-3 52583 NULL
106977 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
106978 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
106979 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
106980 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
106981 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
106982 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
106983 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
106984 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
106985 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
106986 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
106987 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
106988 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
106989 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
106990 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
106991 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
106992 +twlreg_write_52880 twlreg_write 3 52880 NULL
106993 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
106994 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
106995 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
106996 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
106997 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
106998 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
106999 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
107000 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
107001 +send_packet_52960 send_packet 4 52960 NULL
107002 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
107003 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
107004 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
107005 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
107006 +num_node_state_52989 num_node_state 0 52989 NULL
107007 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
107008 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
107009 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
107010 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
107011 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
107012 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
107013 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
107014 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
107015 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
107016 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
107017 +verity_status_53120 verity_status 5 53120 NULL
107018 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
107019 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
107020 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
107021 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
107022 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
107023 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
107024 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
107025 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
107026 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
107027 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
107028 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
107029 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
107030 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
107031 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
107032 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
107033 +vm_mmap_53339 vm_mmap 0 53339 NULL
107034 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
107035 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
107036 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
107037 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
107038 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
107039 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
107040 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
107041 +n2_run_53459 n2_run 3 53459 NULL
107042 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
107043 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
107044 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
107045 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
107046 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
107047 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
107048 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
107049 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
107050 +check_acl_53512 check_acl 0 53512 NULL
107051 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
107052 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
107053 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
107054 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
107055 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
107056 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
107057 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
107058 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
107059 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
107060 +_preload_range_53676 _preload_range 2-3 53676 NULL
107061 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
107062 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
107063 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
107064 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
107065 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
107066 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
107067 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
107068 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
107069 +wdm_write_53735 wdm_write 3 53735 NULL
107070 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
107071 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
107072 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
107073 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
107074 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
107075 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
107076 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
107077 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
107078 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
107079 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
107080 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
107081 +pms_read_53873 pms_read 3 53873 NULL
107082 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
107083 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
107084 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
107085 +proc_file_read_53905 proc_file_read 3 53905 NULL
107086 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
107087 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
107088 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
107089 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
107090 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
107091 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
107092 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
107093 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
107094 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
107095 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
107096 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
107097 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
107098 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
107099 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
107100 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
107101 +_malloc_54077 _malloc 1 54077 NULL
107102 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
107103 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
107104 +create_xattr_54106 create_xattr 5 54106 NULL
107105 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
107106 +strn_len_54122 strn_len 0 54122 NULL
107107 +isku_receive_54130 isku_receive 4 54130 NULL
107108 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
107109 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
107110 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
107111 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
107112 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
107113 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
107114 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
107115 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
107116 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
107117 +reada_add_block_54247 reada_add_block 2 54247 NULL
107118 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
107119 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
107120 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
107121 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
107122 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
107123 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
107124 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
107125 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
107126 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
107127 +sprintf_54306 sprintf 0 54306 NULL
107128 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
107129 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
107130 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
107131 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
107132 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
107133 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
107134 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
107135 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
107136 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
107137 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
107138 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
107139 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
107140 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
107141 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
107142 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
107143 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
107144 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
107145 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
107146 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
107147 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
107148 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
107149 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
107150 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
107151 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
107152 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
107153 +viacam_read_54526 viacam_read 3 54526 NULL
107154 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
107155 +setsockopt_54539 setsockopt 5 54539 NULL
107156 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
107157 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
107158 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
107159 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
107160 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
107161 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
107162 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
107163 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
107164 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
107165 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
107166 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
107167 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
107168 +evm_read_key_54674 evm_read_key 3 54674 NULL
107169 +resource_string_54699 resource_string 0 54699 NULL
107170 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
107171 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
107172 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
107173 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
107174 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
107175 +kzalloc_54740 kzalloc 1 54740 NULL
107176 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
107177 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
107178 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
107179 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
107180 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
107181 +domain_init_54797 domain_init 2 54797 NULL
107182 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
107183 +get_dev_size_54807 get_dev_size 0 54807 NULL
107184 +nfsd_write_54809 nfsd_write 6 54809 NULL
107185 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
107186 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
107187 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
107188 +write_rio_54837 write_rio 3 54837 NULL
107189 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
107190 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
107191 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
107192 +printer_read_54851 printer_read 3 54851 NULL
107193 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
107194 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
107195 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
107196 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
107197 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
107198 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
107199 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
107200 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
107201 +add_port_54941 add_port 2 54941 NULL
107202 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
107203 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
107204 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
107205 +c4_add_card_54968 c4_add_card 3 54968 NULL
107206 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
107207 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
107208 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
107209 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
107210 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
107211 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
107212 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
107213 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
107214 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
107215 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
107216 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
107217 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
107218 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
107219 +corrupt_data_55120 corrupt_data 0 55120 NULL
107220 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
107221 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
107222 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
107223 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
107224 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
107225 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
107226 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
107227 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
107228 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
107229 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
107230 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
107231 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
107232 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
107233 +dump_command_55220 dump_command 1 55220 NULL
107234 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
107235 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
107236 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
107237 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
107238 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
107239 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
107240 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
107241 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
107242 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
107243 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
107244 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
107245 +do_shmat_55336 do_shmat 5 55336 NULL
107246 +vme_user_read_55338 vme_user_read 3 55338 NULL
107247 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
107248 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
107249 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
107250 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
107251 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
107252 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
107253 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
107254 +alloc_skb_55439 alloc_skb 1 55439 NULL
107255 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
107256 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
107257 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
107258 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
107259 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
107260 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
107261 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
107262 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
107263 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
107264 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
107265 +ea_get_55522 ea_get 0 55522 NULL
107266 +buffer_size_55534 buffer_size 0 55534 NULL
107267 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
107268 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
107269 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
107270 +add_partition_55588 add_partition 2 55588 NULL
107271 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
107272 +free_pages_55603 free_pages 1 55603 NULL
107273 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
107274 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
107275 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
107276 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
107277 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
107278 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
107279 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
107280 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
107281 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
107282 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
107283 +read_oldmem_55658 read_oldmem 3 55658 NULL
107284 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
107285 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
107286 +get_info_55681 get_info 3 55681 NULL
107287 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
107288 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
107289 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
107290 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
107291 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
107292 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
107293 +set_local_name_55757 set_local_name 4 55757 NULL
107294 +strlen_55778 strlen 0 55778 NULL
107295 +set_spte_55783 set_spte 5-4 55783 NULL
107296 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
107297 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
107298 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
107299 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
107300 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
107301 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
107302 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
107303 +hsc_write_55875 hsc_write 3 55875 NULL
107304 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
107305 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
107306 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
107307 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
107308 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
107309 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
107310 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
107311 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
107312 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
107313 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
107314 +__set_discard_56081 __set_discard 2 56081 NULL
107315 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
107316 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
107317 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
107318 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
107319 +map_addr_56144 map_addr 7 56144 NULL
107320 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
107321 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
107322 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
107323 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
107324 +skb_headroom_56200 skb_headroom 0 56200 NULL
107325 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
107326 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
107327 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
107328 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
107329 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
107330 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
107331 +fd_copyin_56247 fd_copyin 3 56247 NULL
107332 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
107333 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
107334 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
107335 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
107336 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
107337 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
107338 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
107339 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
107340 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
107341 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
107342 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
107343 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
107344 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
107345 +dev_read_56369 dev_read 3 56369 NULL
107346 +write_gssp_56404 write_gssp 3 56404 NULL
107347 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
107348 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
107349 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
107350 +store_msg_56417 store_msg 3 56417 NULL
107351 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
107352 +fl_create_56435 fl_create 5 56435 NULL
107353 +gnttab_map_56439 gnttab_map 2 56439 NULL
107354 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
107355 +set_connectable_56458 set_connectable 4 56458 NULL
107356 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
107357 +putused_user_56467 putused_user 3 56467 NULL
107358 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
107359 +global_rt_period_56476 global_rt_period 0 56476 NULL
107360 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
107361 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
107362 +init_map_ip_56508 init_map_ip 5 56508 NULL
107363 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
107364 +ip_options_get_56538 ip_options_get 4 56538 NULL
107365 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
107366 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
107367 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
107368 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
107369 +event_filter_write_56609 event_filter_write 3 56609 NULL
107370 +gather_array_56641 gather_array 3 56641 NULL
107371 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
107372 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
107373 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
107374 +build_map_info_56696 build_map_info 2 56696 NULL
107375 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
107376 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
107377 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
107378 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
107379 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
107380 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
107381 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
107382 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
107383 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
107384 +hash_lookup_56792 hash_lookup 2 56792 NULL
107385 +do_syslog_56807 do_syslog 3 56807 NULL
107386 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
107387 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
107388 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
107389 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107390 +wb_lookup_56858 wb_lookup 2 56858 NULL
107391 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107392 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107393 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107394 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107395 +strcspn_56913 strcspn 0 56913 NULL
107396 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107397 +check_header_56930 check_header 2 56930 NULL
107398 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107399 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107400 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107401 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107402 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107403 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107404 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107405 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107406 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107407 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107408 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107409 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107410 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107411 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107412 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107413 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107414 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107415 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107416 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107417 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107418 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107419 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107420 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107421 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107422 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107423 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107424 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107425 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107426 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107427 +flush_space_57241 flush_space 3 57241 NULL
107428 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107429 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107430 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107431 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107432 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107433 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107434 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107435 +fw_file_size_57307 fw_file_size 0 57307 NULL
107436 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107437 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107438 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107439 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107440 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107441 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107442 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107443 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107444 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107445 +read_file_blob_57406 read_file_blob 3 57406 NULL
107446 +enclosure_register_57412 enclosure_register 3 57412 NULL
107447 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107448 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107449 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107450 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107451 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107452 +ReadReg_57453 ReadReg 0 57453 NULL
107453 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107454 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107455 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107456 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107457 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107458 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107459 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107460 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107461 +skb_headlen_57501 skb_headlen 0 57501 NULL
107462 +copy_in_user_57502 copy_in_user 3 57502 NULL
107463 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107464 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107465 +init_tag_map_57515 init_tag_map 3 57515 NULL
107466 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107467 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107468 +inode_permission_57531 inode_permission 0 57531 NULL
107469 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107470 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107471 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107472 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107473 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107474 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107475 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107476 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107477 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107478 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107479 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107480 +mem_read_57631 mem_read 3 57631 NULL
107481 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107482 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107483 +r3964_write_57662 r3964_write 4 57662 NULL
107484 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107485 +__lgwrite_57669 __lgwrite 4 57669 NULL
107486 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107487 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107488 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107489 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107490 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107491 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107492 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107493 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107494 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107495 +ld2_57794 ld2 0 57794 NULL
107496 +ivtv_read_57796 ivtv_read 3 57796 NULL
107497 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107498 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107499 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107500 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107501 +copy_to_user_57835 copy_to_user 3 57835 NULL
107502 +flash_read_57843 flash_read 3 57843 NULL
107503 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107504 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107505 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107506 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107507 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107508 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107509 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107510 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107511 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107512 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107513 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107514 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107515 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107516 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107517 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107518 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107519 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107520 +mce_async_out_58056 mce_async_out 3 58056 NULL
107521 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107522 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107523 +cm4040_write_58079 cm4040_write 3 58079 NULL
107524 +udi_log_event_58105 udi_log_event 3 58105 NULL
107525 +savemem_58129 savemem 3 58129 NULL
107526 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107527 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107528 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107529 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107530 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107531 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107532 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107533 +read_file_debug_58256 read_file_debug 3 58256 NULL
107534 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107535 +profile_load_58267 profile_load 3 58267 NULL
107536 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107537 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107538 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107539 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107540 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107541 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107542 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107543 +next_pidmap_58347 next_pidmap 2 58347 NULL
107544 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107545 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107546 +save_hint_58359 save_hint 2 58359 NULL
107547 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107548 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107549 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107550 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107551 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107552 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107553 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107554 +capabilities_read_58457 capabilities_read 3 58457 NULL
107555 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107556 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107557 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107558 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107559 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107560 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107561 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107562 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107563 +__clear_discard_58546 __clear_discard 2 58546 NULL
107564 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107565 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107566 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107567 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107568 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107569 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107570 +xip_file_read_58592 xip_file_read 3 58592 NULL
107571 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107572 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107573 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107574 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107575 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107576 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107577 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107578 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107579 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107580 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107581 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107582 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107583 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107584 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107585 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107586 +acpi_map_58725 acpi_map 1-2 58725 NULL
107587 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107588 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107589 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107590 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107591 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107592 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107593 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107594 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107595 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107596 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107597 +ep_read_58813 ep_read 3 58813 NULL
107598 +command_write_58841 command_write 3 58841 NULL
107599 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107600 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107601 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107602 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107603 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107604 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107605 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107606 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107607 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107608 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107609 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107610 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107611 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107612 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107613 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107614 +ep_write_59008 ep_write 3 59008 NULL
107615 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107616 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107617 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107618 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107619 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107620 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107621 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107622 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107623 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107624 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107625 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107626 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107627 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107628 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107629 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107630 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107631 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107632 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107633 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107634 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107635 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107636 +dt3155_read_59226 dt3155_read 3 59226 NULL
107637 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107638 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107639 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107640 +nla_len_59258 nla_len 0 59258 NULL
107641 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107642 +fd_copyout_59323 fd_copyout 3 59323 NULL
107643 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107644 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107645 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107646 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107647 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107648 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107649 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107650 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107651 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107652 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107653 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107654 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107655 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107656 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107657 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107658 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107659 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107660 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107661 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107662 +tunables_write_59563 tunables_write 3 59563 NULL
107663 +memdup_user_59590 memdup_user 2 59590 NULL
107664 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107665 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107666 +mtrr_write_59622 mtrr_write 3 59622 NULL
107667 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107668 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107669 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107670 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107671 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107672 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107673 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107674 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107675 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107676 +sriov_enable_59689 sriov_enable 2 59689 NULL
107677 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107678 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107679 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107680 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107681 +strnlen_59746 strnlen 0 59746 NULL
107682 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107683 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107684 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107685 +venus_remove_59781 venus_remove 4 59781 NULL
107686 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107687 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107688 +ipw_write_59807 ipw_write 3 59807 NULL
107689 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107690 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107691 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107692 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107693 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107694 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107695 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107696 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107697 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107698 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107699 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107700 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107701 +lookup_node_59953 lookup_node 2 59953 NULL
107702 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107703 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107704 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107705 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107706 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107707 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107708 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107709 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107710 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107711 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107712 +register_device_60015 register_device 2-3 60015 NULL
107713 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107714 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107715 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107716 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107717 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107718 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107719 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107720 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107721 +compat_writev_60063 compat_writev 3 60063 NULL
107722 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107723 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107724 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107725 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107726 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107727 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107728 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107729 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107730 +init_state_60165 init_state 2 60165 NULL
107731 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107732 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107733 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107734 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107735 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107736 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107737 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107738 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107739 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107740 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107741 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107742 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107743 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107744 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107745 +printer_write_60276 printer_write 3 60276 NULL
107746 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107747 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107748 +getDataLength_60301 getDataLength 0 60301 NULL
107749 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107750 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107751 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107752 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107753 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107754 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107755 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107756 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107757 +driver_names_read_60399 driver_names_read 3 60399 NULL
107758 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107759 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107760 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107761 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107762 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107763 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107764 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107765 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107766 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107767 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107768 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107769 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107770 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107771 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107772 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107773 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107774 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107775 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107776 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107777 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107778 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107779 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107780 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107781 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107782 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107783 +init_data_container_60709 init_data_container 1 60709 NULL
107784 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107785 +raid_status_60755 raid_status 5 60755 NULL
107786 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107787 +opticon_write_60775 opticon_write 4 60775 NULL
107788 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107789 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107790 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107791 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107792 +generic_writepages_60871 generic_writepages 0 60871 NULL
107793 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107794 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107795 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107796 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107797 +sys_mlock_60932 sys_mlock 1 60932 NULL
107798 +pti_char_write_60960 pti_char_write 3 60960 NULL
107799 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107800 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107801 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107802 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107803 +symtab_init_61050 symtab_init 2 61050 NULL
107804 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107805 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107806 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107807 +get_derived_key_61100 get_derived_key 4 61100 NULL
107808 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107809 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107810 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107811 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107812 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107813 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107814 +__vmalloc_61168 __vmalloc 1 61168 NULL
107815 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107816 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107817 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107818 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107819 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107820 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107821 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107822 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107823 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107824 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107825 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107826 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107827 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107828 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107829 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107830 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107831 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107832 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107833 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107834 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107835 +change_xattr_61390 change_xattr 5 61390 NULL
107836 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107837 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107838 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107839 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107840 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107841 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107842 +erst_errno_61526 erst_errno 0 61526 NULL
107843 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107844 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107845 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107846 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107847 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107848 +seq_open_private_61589 seq_open_private 3 61589 NULL
107849 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107850 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107851 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107852 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107853 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107854 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107855 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107856 +resize_stripes_61650 resize_stripes 2 61650 NULL
107857 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107858 +insert_one_name_61668 insert_one_name 7 61668 NULL
107859 +lock_loop_61681 lock_loop 1 61681 NULL
107860 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107861 +filter_read_61692 filter_read 3 61692 NULL
107862 +iov_length_61716 iov_length 0 61716 NULL
107863 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107864 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107865 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107866 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107867 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107868 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107869 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107870 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107871 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107872 +get_fw_name_61874 get_fw_name 3 61874 NULL
107873 +free_init_pages_61875 free_init_pages 2 61875 NULL
107874 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107875 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107876 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107877 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107878 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107879 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107880 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107881 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107882 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107883 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107884 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107885 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107886 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107887 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107888 +cow_file_range_61979 cow_file_range 3 61979 NULL
107889 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107890 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107891 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107892 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107893 +SYSC_select_62024 SYSC_select 1 62024 NULL
107894 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107895 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107896 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107897 +do_pselect_62061 do_pselect 1 62061 NULL
107898 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107899 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107900 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107901 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107902 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107903 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107904 +ql_status_62135 ql_status 5 62135 NULL
107905 +video_usercopy_62151 video_usercopy 2 62151 NULL
107906 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107907 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107908 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107909 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107910 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107911 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107912 +allocate_partition_62245 allocate_partition 4 62245 NULL
107913 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107914 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107915 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107916 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107917 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107918 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107919 +subseq_list_62332 subseq_list 3-0 62332 NULL
107920 +flash_write_62354 flash_write 3 62354 NULL
107921 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107922 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107923 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107924 +altera_irscan_62396 altera_irscan 2 62396 NULL
107925 +set_ssp_62411 set_ssp 4 62411 NULL
107926 +unmap_single_62423 unmap_single 2 62423 NULL
107927 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107928 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107929 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107930 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107931 +remove_mapping_62491 remove_mapping 2 62491 NULL
107932 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107933 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107934 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107935 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107936 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107937 +debugfs_read_62535 debugfs_read 3 62535 NULL
107938 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107939 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107940 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107941 +get_subdir_62581 get_subdir 3 62581 NULL
107942 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
107943 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
107944 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
107945 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
107946 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
107947 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
107948 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
107949 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
107950 +write_62671 write 3 62671 NULL
107951 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
107952 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
107953 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
107954 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
107955 +rdm_62719 rdm 0 62719 NULL
107956 +key_replays_read_62746 key_replays_read 3 62746 NULL
107957 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
107958 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
107959 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
107960 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
107961 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
107962 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
107963 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
107964 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
107965 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
107966 +set_swbp_62853 set_swbp 3 62853 NULL
107967 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
107968 +aoechr_write_62883 aoechr_write 3 62883 NULL
107969 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
107970 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
107971 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
107972 +getdqbuf_62908 getdqbuf 1 62908 NULL
107973 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
107974 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
107975 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
107976 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
107977 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
107978 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
107979 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
107980 +unlink1_63059 unlink1 3 63059 NULL
107981 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
107982 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
107983 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
107984 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
107985 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
107986 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
107987 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
107988 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
107989 +vme_master_read_63221 vme_master_read 0 63221 NULL
107990 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
107991 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
107992 +ptp_read_63251 ptp_read 4 63251 NULL
107993 +raid5_resize_63306 raid5_resize 2 63306 NULL
107994 +proc_info_read_63344 proc_info_read 3 63344 NULL
107995 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
107996 +idmouse_read_63374 idmouse_read 3 63374 NULL
107997 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
107998 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
107999 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
108000 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
108001 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
108002 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
108003 +kone_send_63435 kone_send 4 63435 NULL
108004 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
108005 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
108006 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
108007 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
108008 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
108009 +read_kcore_63488 read_kcore 3 63488 NULL
108010 +save_hint_63497 save_hint 2 63497 NULL
108011 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
108012 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
108013 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
108014 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
108015 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
108016 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
108017 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
108018 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
108019 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
108020 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
108021 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
108022 +module_alloc_63630 module_alloc 1 63630 NULL
108023 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
108024 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
108025 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
108026 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
108027 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
108028 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
108029 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
108030 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
108031 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
108032 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
108033 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
108034 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
108035 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
108036 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
108037 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
108038 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
108039 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
108040 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
108041 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
108042 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
108043 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
108044 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
108045 +prepare_copy_63826 prepare_copy 2 63826 NULL
108046 +sel_write_load_63830 sel_write_load 3 63830 NULL
108047 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
108048 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
108049 +divas_write_63901 divas_write 3 63901 NULL
108050 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
108051 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
108052 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
108053 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
108054 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
108055 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
108056 +__team_options_register_63941 __team_options_register 3 63941 NULL
108057 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
108058 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
108059 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
108060 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
108061 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
108062 +kmemdup_64015 kmemdup 2 64015 NULL
108063 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
108064 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
108065 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
108066 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
108067 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
108068 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
108069 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
108070 +get_u8_64076 get_u8 0 64076 NULL
108071 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
108072 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
108073 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
108074 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
108075 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
108076 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
108077 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
108078 +init_bch_64130 init_bch 1-2 64130 NULL
108079 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
108080 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
108081 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
108082 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
108083 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
108084 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
108085 +read_pulse_64227 read_pulse 0-3 64227 NULL
108086 +header_len_64232 header_len 0 64232 NULL
108087 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
108088 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
108089 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
108090 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
108091 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
108092 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
108093 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
108094 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
108095 +ffz_64324 ffz 0 64324 NULL
108096 +map_region_64328 map_region 1 64328 NULL
108097 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
108098 +ts_write_64336 ts_write 3 64336 NULL
108099 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
108100 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
108101 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
108102 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
108103 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
108104 +ilo_write_64378 ilo_write 3 64378 NULL
108105 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
108106 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
108107 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
108108 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
108109 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
108110 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
108111 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
108112 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
108113 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
108114 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
108115 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
108116 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
108117 +cap_capable_64462 cap_capable 0 64462 NULL
108118 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
108119 +single_open_size_64483 single_open_size 4 64483 NULL
108120 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
108121 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
108122 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
108123 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
108124 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
108125 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
108126 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
108127 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
108128 +SyS_bind_64544 SyS_bind 3 64544 NULL
108129 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
108130 +__spi_sync_64561 __spi_sync 0 64561 NULL
108131 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
108132 +fanotify_write_64623 fanotify_write 3 64623 NULL
108133 +to_dblock_64655 to_dblock 0-1 64655 NULL
108134 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
108135 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
108136 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
108137 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
108138 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
108139 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
108140 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
108141 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
108142 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
108143 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
108144 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
108145 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
108146 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
108147 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
108148 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
108149 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
108150 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
108151 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
108152 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
108153 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
108154 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
108155 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
108156 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
108157 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
108158 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
108159 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
108160 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
108161 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
108162 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
108163 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
108164 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
108165 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
108166 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
108167 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
108168 +pskb_pull_65005 pskb_pull 2 65005 NULL
108169 +unifi_write_65012 unifi_write 3 65012 NULL
108170 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
108171 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
108172 +insert_dent_65034 insert_dent 7 65034 NULL
108173 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
108174 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
108175 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
108176 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
108177 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
108178 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
108179 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
108180 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
108181 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
108182 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
108183 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
108184 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
108185 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
108186 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
108187 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
108188 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
108189 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
108190 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
108191 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
108192 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
108193 +get_var_len_65304 get_var_len 0 65304 NULL
108194 +unpack_array_65318 unpack_array 0 65318 NULL
108195 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
108196 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
108197 +init_list_set_65351 init_list_set 2-3 65351 NULL
108198 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
108199 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
108200 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
108201 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
108202 +strchr_65372 strchr 0 65372 NULL nohasharray
108203 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
108204 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
108205 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
108206 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
108207 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
108208 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
108209 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
108210 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
108211 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
108212 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
108213 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
108214 +alloc_dr_65495 alloc_dr 2 65495 NULL
108215 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
108216 new file mode 100644
108217 index 0000000..03d0c84
108218 --- /dev/null
108219 +++ b/tools/gcc/size_overflow_plugin.c
108220 @@ -0,0 +1,2113 @@
108221 +/*
108222 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
108223 + * Licensed under the GPL v2, or (at your option) v3
108224 + *
108225 + * Homepage:
108226 + * http://www.grsecurity.net/~ephox/overflow_plugin/
108227 + *
108228 + * Documentation:
108229 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
108230 + *
108231 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
108232 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
108233 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
108234 + *
108235 + * Usage:
108236 + * $ 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
108237 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
108238 + */
108239 +
108240 +#include "gcc-plugin.h"
108241 +#include "config.h"
108242 +#include "system.h"
108243 +#include "coretypes.h"
108244 +#include "tree.h"
108245 +#include "tree-pass.h"
108246 +#include "intl.h"
108247 +#include "plugin-version.h"
108248 +#include "tm.h"
108249 +#include "toplev.h"
108250 +#include "function.h"
108251 +#include "tree-flow.h"
108252 +#include "plugin.h"
108253 +#include "gimple.h"
108254 +#include "diagnostic.h"
108255 +#include "cfgloop.h"
108256 +
108257 +#if BUILDING_GCC_VERSION >= 4008
108258 +#define TODO_dump_func 0
108259 +#endif
108260 +
108261 +struct size_overflow_hash {
108262 + const struct size_overflow_hash * const next;
108263 + const char * const name;
108264 + const unsigned int param;
108265 +};
108266 +
108267 +#include "size_overflow_hash.h"
108268 +
108269 +enum mark {
108270 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
108271 +};
108272 +
108273 +enum err_code_conditions {
108274 + CAST_ONLY, FROM_CONST
108275 +};
108276 +
108277 +static unsigned int call_count = 0;
108278 +
108279 +#define __unused __attribute__((__unused__))
108280 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108281 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
108282 +#define BEFORE_STMT true
108283 +#define AFTER_STMT false
108284 +#define CREATE_NEW_VAR NULL_TREE
108285 +#define CODES_LIMIT 32
108286 +#define MAX_PARAM 31
108287 +#define MY_STMT GF_PLF_1
108288 +#define NO_CAST_CHECK GF_PLF_2
108289 +#define FROM_ARG true
108290 +#define FROM_RET false
108291 +
108292 +#if BUILDING_GCC_VERSION == 4005
108293 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
108294 +#endif
108295 +
108296 +int plugin_is_GPL_compatible;
108297 +void debug_gimple_stmt(gimple gs);
108298 +
108299 +static tree expand(struct pointer_set_t *visited, tree lhs);
108300 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
108301 +static tree report_size_overflow_decl;
108302 +static const_tree const_char_ptr_type_node;
108303 +static unsigned int handle_function(void);
108304 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
108305 +static tree get_size_overflow_type(gimple stmt, const_tree node);
108306 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
108307 +static void print_missing_msg(tree func, unsigned int argnum);
108308 +
108309 +static struct plugin_info size_overflow_plugin_info = {
108310 + .version = "20130822beta",
108311 + .help = "no-size-overflow\tturn off size overflow checking\n",
108312 +};
108313 +
108314 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108315 +{
108316 + unsigned int arg_count;
108317 + enum tree_code code = TREE_CODE(*node);
108318 +
108319 + switch (code) {
108320 + case FUNCTION_DECL:
108321 + arg_count = type_num_arguments(TREE_TYPE(*node));
108322 + break;
108323 + case FUNCTION_TYPE:
108324 + case METHOD_TYPE:
108325 + arg_count = type_num_arguments(*node);
108326 + break;
108327 + default:
108328 + *no_add_attrs = true;
108329 + error("%s: %qE attribute only applies to functions", __func__, name);
108330 + return NULL_TREE;
108331 + }
108332 +
108333 + for (; args; args = TREE_CHAIN(args)) {
108334 + tree position = TREE_VALUE(args);
108335 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108336 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108337 + *no_add_attrs = true;
108338 + }
108339 + }
108340 + return NULL_TREE;
108341 +}
108342 +
108343 +static const char* get_asm_name(tree node)
108344 +{
108345 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
108346 +}
108347 +
108348 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108349 +{
108350 + unsigned int arg_count, arg_num;
108351 + enum tree_code code = TREE_CODE(*node);
108352 +
108353 + switch (code) {
108354 + case FUNCTION_DECL:
108355 + arg_count = type_num_arguments(TREE_TYPE(*node));
108356 + break;
108357 + case FUNCTION_TYPE:
108358 + case METHOD_TYPE:
108359 + arg_count = type_num_arguments(*node);
108360 + break;
108361 + case FIELD_DECL:
108362 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
108363 + if (arg_num != 0) {
108364 + *no_add_attrs = true;
108365 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
108366 + }
108367 + return NULL_TREE;
108368 + default:
108369 + *no_add_attrs = true;
108370 + error("%qE attribute only applies to functions", name);
108371 + return NULL_TREE;
108372 + }
108373 +
108374 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
108375 + return NULL_TREE;
108376 +
108377 + for (; args; args = TREE_CHAIN(args)) {
108378 + tree position = TREE_VALUE(args);
108379 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108380 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108381 + *no_add_attrs = true;
108382 + }
108383 + }
108384 + return NULL_TREE;
108385 +}
108386 +
108387 +static struct attribute_spec size_overflow_attr = {
108388 + .name = "size_overflow",
108389 + .min_length = 1,
108390 + .max_length = -1,
108391 + .decl_required = true,
108392 + .type_required = false,
108393 + .function_type_required = false,
108394 + .handler = handle_size_overflow_attribute,
108395 +#if BUILDING_GCC_VERSION >= 4007
108396 + .affects_type_identity = false
108397 +#endif
108398 +};
108399 +
108400 +static struct attribute_spec intentional_overflow_attr = {
108401 + .name = "intentional_overflow",
108402 + .min_length = 1,
108403 + .max_length = -1,
108404 + .decl_required = true,
108405 + .type_required = false,
108406 + .function_type_required = false,
108407 + .handler = handle_intentional_overflow_attribute,
108408 +#if BUILDING_GCC_VERSION >= 4007
108409 + .affects_type_identity = false
108410 +#endif
108411 +};
108412 +
108413 +static void register_attributes(void __unused *event_data, void __unused *data)
108414 +{
108415 + register_attribute(&size_overflow_attr);
108416 + register_attribute(&intentional_overflow_attr);
108417 +}
108418 +
108419 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108420 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108421 +{
108422 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108423 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108424 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108425 +
108426 + unsigned int m = 0x57559429;
108427 + unsigned int n = 0x5052acdb;
108428 + const unsigned int *key4 = (const unsigned int *)key;
108429 + unsigned int h = len;
108430 + unsigned int k = len + seed + n;
108431 + unsigned long long p;
108432 +
108433 + while (len >= 8) {
108434 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108435 + len -= 8;
108436 + }
108437 + if (len >= 4) {
108438 + cwmixb(key4[0]) key4 += 1;
108439 + len -= 4;
108440 + }
108441 + if (len)
108442 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108443 + cwmixb(h ^ (k + n));
108444 + return k ^ h;
108445 +
108446 +#undef cwfold
108447 +#undef cwmixa
108448 +#undef cwmixb
108449 +}
108450 +
108451 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108452 +{
108453 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108454 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108455 + return fn ^ codes;
108456 +}
108457 +
108458 +static inline tree get_original_function_decl(tree fndecl)
108459 +{
108460 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108461 + return DECL_ABSTRACT_ORIGIN(fndecl);
108462 + return fndecl;
108463 +}
108464 +
108465 +static inline gimple get_def_stmt(const_tree node)
108466 +{
108467 + gcc_assert(node != NULL_TREE);
108468 + if (TREE_CODE(node) != SSA_NAME)
108469 + return NULL;
108470 + return SSA_NAME_DEF_STMT(node);
108471 +}
108472 +
108473 +static unsigned char get_tree_code(const_tree type)
108474 +{
108475 + switch (TREE_CODE(type)) {
108476 + case ARRAY_TYPE:
108477 + return 0;
108478 + case BOOLEAN_TYPE:
108479 + return 1;
108480 + case ENUMERAL_TYPE:
108481 + return 2;
108482 + case FUNCTION_TYPE:
108483 + return 3;
108484 + case INTEGER_TYPE:
108485 + return 4;
108486 + case POINTER_TYPE:
108487 + return 5;
108488 + case RECORD_TYPE:
108489 + return 6;
108490 + case UNION_TYPE:
108491 + return 7;
108492 + case VOID_TYPE:
108493 + return 8;
108494 + case REAL_TYPE:
108495 + return 9;
108496 + case VECTOR_TYPE:
108497 + return 10;
108498 + case REFERENCE_TYPE:
108499 + return 11;
108500 + case OFFSET_TYPE:
108501 + return 12;
108502 + case COMPLEX_TYPE:
108503 + return 13;
108504 + default:
108505 + debug_tree((tree)type);
108506 + gcc_unreachable();
108507 + }
108508 +}
108509 +
108510 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108511 +{
108512 + gcc_assert(type != NULL_TREE);
108513 +
108514 + while (type && len < CODES_LIMIT) {
108515 + tree_codes[len] = get_tree_code(type);
108516 + len++;
108517 + type = TREE_TYPE(type);
108518 + }
108519 + return len;
108520 +}
108521 +
108522 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108523 +{
108524 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108525 + enum tree_code code = TREE_CODE(type);
108526 + size_t len = 0;
108527 +
108528 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108529 +
108530 + arg = TYPE_ARG_TYPES(type);
108531 + // skip builtins __builtin_constant_p
108532 + if (!arg && DECL_BUILT_IN(fndecl))
108533 + return 0;
108534 +
108535 + if (TREE_CODE_CLASS(code) == tcc_type)
108536 + result = type;
108537 + else
108538 + result = DECL_RESULT(fndecl);
108539 +
108540 + gcc_assert(result != NULL_TREE);
108541 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108542 +
108543 + if (arg == NULL_TREE) {
108544 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108545 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108546 + if (arg_field == NULL_TREE)
108547 + return 0;
108548 + arg = TREE_TYPE(arg_field);
108549 + len = add_type_codes(arg, tree_codes, len);
108550 + gcc_assert(len != 0);
108551 + return len;
108552 + }
108553 +
108554 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108555 + while (arg && len < CODES_LIMIT) {
108556 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108557 + arg = TREE_CHAIN(arg);
108558 + }
108559 +
108560 + gcc_assert(len != 0);
108561 + return len;
108562 +}
108563 +
108564 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108565 +{
108566 + unsigned int hash;
108567 + const struct size_overflow_hash *entry;
108568 + unsigned char tree_codes[CODES_LIMIT];
108569 + size_t len;
108570 + const char *func_name;
108571 +
108572 + fndecl = get_original_function_decl(fndecl);
108573 + len = get_function_decl(fndecl, tree_codes);
108574 + if (len == 0)
108575 + return NULL;
108576 +
108577 + func_name = get_asm_name(fndecl);
108578 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108579 +
108580 + entry = size_overflow_hash[hash];
108581 + while (entry) {
108582 + if (!strcmp(entry->name, func_name))
108583 + return entry;
108584 + entry = entry->next;
108585 + }
108586 +
108587 + return NULL;
108588 +}
108589 +
108590 +static bool is_bool(const_tree node)
108591 +{
108592 + const_tree type;
108593 +
108594 + if (node == NULL_TREE)
108595 + return false;
108596 +
108597 + type = TREE_TYPE(node);
108598 + if (!INTEGRAL_TYPE_P(type))
108599 + return false;
108600 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108601 + return true;
108602 + if (TYPE_PRECISION(type) == 1)
108603 + return true;
108604 + return false;
108605 +}
108606 +
108607 +static bool skip_types(const_tree var)
108608 +{
108609 + tree type;
108610 +
108611 + if (is_gimple_constant(var))
108612 + return true;
108613 +
108614 + switch (TREE_CODE(var)) {
108615 + case ADDR_EXPR:
108616 +#if BUILDING_GCC_VERSION >= 4006
108617 + case MEM_REF:
108618 +#endif
108619 + case ARRAY_REF:
108620 + case BIT_FIELD_REF:
108621 + case INDIRECT_REF:
108622 + case TARGET_MEM_REF:
108623 + return true;
108624 + case PARM_DECL:
108625 + case VAR_DECL:
108626 + case COMPONENT_REF:
108627 + return false;
108628 + default:
108629 + break;
108630 + }
108631 +
108632 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108633 +
108634 + type = TREE_TYPE(var);
108635 + switch (TREE_CODE(type)) {
108636 + case INTEGER_TYPE:
108637 + case ENUMERAL_TYPE:
108638 + return false;
108639 + case BOOLEAN_TYPE:
108640 + return is_bool(var);
108641 + default:
108642 + break;
108643 + }
108644 +
108645 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108646 +
108647 + type = TREE_TYPE(type);
108648 + gcc_assert(type != NULL_TREE);
108649 + switch (TREE_CODE(type)) {
108650 + case RECORD_TYPE:
108651 + case POINTER_TYPE:
108652 + case ARRAY_TYPE:
108653 + return true;
108654 + case VOID_TYPE:
108655 + case INTEGER_TYPE:
108656 + case UNION_TYPE:
108657 + return false;
108658 + default:
108659 + break;
108660 + }
108661 +
108662 + debug_tree((tree)var);
108663 + gcc_unreachable();
108664 +}
108665 +
108666 +static unsigned int find_arg_number(const_tree arg, tree func)
108667 +{
108668 + tree var;
108669 + unsigned int argnum = 1;
108670 +
108671 + if (TREE_CODE(arg) == SSA_NAME)
108672 + arg = SSA_NAME_VAR(arg);
108673 +
108674 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108675 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108676 + continue;
108677 + if (!skip_types(var))
108678 + return argnum;
108679 + }
108680 +
108681 + return 0;
108682 +}
108683 +
108684 +static tree create_new_var(tree type)
108685 +{
108686 + tree new_var = create_tmp_var(type, "cicus");
108687 +
108688 +#if BUILDING_GCC_VERSION <= 4007
108689 + add_referenced_var(new_var);
108690 +#endif
108691 + return new_var;
108692 +}
108693 +
108694 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108695 +{
108696 + gimple assign;
108697 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108698 + tree type = TREE_TYPE(rhs1);
108699 + tree lhs = create_new_var(type);
108700 +
108701 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108702 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108703 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108704 +
108705 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108706 + update_stmt(assign);
108707 + gimple_set_plf(assign, MY_STMT, true);
108708 + return assign;
108709 +}
108710 +
108711 +static tree cast_a_tree(tree type, tree var)
108712 +{
108713 + gcc_assert(type != NULL_TREE);
108714 + gcc_assert(var != NULL_TREE);
108715 + gcc_assert(fold_convertible_p(type, var));
108716 +
108717 + return fold_convert(type, var);
108718 +}
108719 +
108720 +static tree get_lhs(const_gimple stmt)
108721 +{
108722 + switch (gimple_code(stmt)) {
108723 + case GIMPLE_ASSIGN:
108724 + return gimple_get_lhs(stmt);
108725 + case GIMPLE_PHI:
108726 + return gimple_phi_result(stmt);
108727 + case GIMPLE_CALL:
108728 + return gimple_call_lhs(stmt);
108729 + default:
108730 + return NULL_TREE;
108731 + }
108732 +}
108733 +
108734 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108735 +{
108736 + const_gimple def_stmt = get_def_stmt(rhs);
108737 +
108738 + if (force)
108739 + return false;
108740 +
108741 + if (is_gimple_constant(rhs))
108742 + return false;
108743 +
108744 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108745 + return false;
108746 +
108747 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108748 + return false;
108749 +
108750 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108751 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108752 + return false;
108753 +
108754 + return true;
108755 +}
108756 +
108757 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108758 +{
108759 + gimple assign, def_stmt;
108760 +
108761 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108762 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108763 + gcc_unreachable();
108764 +
108765 + def_stmt = get_def_stmt(rhs);
108766 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108767 + return def_stmt;
108768 +
108769 + if (lhs == CREATE_NEW_VAR)
108770 + lhs = create_new_var(dst_type);
108771 +
108772 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108773 +
108774 + if (!gsi_end_p(*gsi)) {
108775 + location_t loc = gimple_location(gsi_stmt(*gsi));
108776 + gimple_set_location(assign, loc);
108777 + }
108778 +
108779 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108780 +
108781 + if (before)
108782 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108783 + else
108784 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108785 + update_stmt(assign);
108786 + gimple_set_plf(assign, MY_STMT, true);
108787 +
108788 + return assign;
108789 +}
108790 +
108791 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108792 +{
108793 + gimple_stmt_iterator gsi;
108794 + tree lhs;
108795 + const_gimple new_stmt;
108796 +
108797 + if (rhs == NULL_TREE)
108798 + return NULL_TREE;
108799 +
108800 + gsi = gsi_for_stmt(stmt);
108801 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108802 +
108803 + lhs = get_lhs(new_stmt);
108804 + gcc_assert(lhs != NULL_TREE);
108805 + return lhs;
108806 +}
108807 +
108808 +static tree cast_to_TI_type(gimple stmt, tree node)
108809 +{
108810 + gimple_stmt_iterator gsi;
108811 + gimple cast_stmt;
108812 + tree type = TREE_TYPE(node);
108813 +
108814 + if (types_compatible_p(type, intTI_type_node))
108815 + return node;
108816 +
108817 + gsi = gsi_for_stmt(stmt);
108818 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108819 + return gimple_get_lhs(cast_stmt);
108820 +}
108821 +
108822 +static void check_function_hash(const_gimple stmt)
108823 +{
108824 + tree func;
108825 + const struct size_overflow_hash *hash;
108826 +
108827 + if (gimple_code(stmt) != GIMPLE_CALL)
108828 + return;
108829 +
108830 + func = gimple_call_fndecl(stmt);
108831 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108832 + if (func == NULL_TREE)
108833 + return;
108834 +
108835 + hash = get_function_hash(func);
108836 + if (!hash)
108837 + print_missing_msg(func, 0);
108838 +}
108839 +
108840 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108841 +{
108842 + tree lhs, new_lhs;
108843 + gimple_stmt_iterator gsi;
108844 +
108845 + if (rhs1 == NULL_TREE) {
108846 + debug_gimple_stmt(oldstmt);
108847 + error("%s: rhs1 is NULL_TREE", __func__);
108848 + gcc_unreachable();
108849 + }
108850 +
108851 + switch (gimple_code(oldstmt)) {
108852 + case GIMPLE_ASM:
108853 + lhs = rhs1;
108854 + break;
108855 + case GIMPLE_CALL:
108856 + lhs = gimple_call_lhs(oldstmt);
108857 + break;
108858 + case GIMPLE_ASSIGN:
108859 + lhs = gimple_get_lhs(oldstmt);
108860 + break;
108861 + default:
108862 + debug_gimple_stmt(oldstmt);
108863 + gcc_unreachable();
108864 + }
108865 +
108866 + gsi = gsi_for_stmt(oldstmt);
108867 + pointer_set_insert(visited, oldstmt);
108868 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108869 + basic_block next_bb, cur_bb;
108870 + const_edge e;
108871 +
108872 + gcc_assert(before == false);
108873 + gcc_assert(stmt_can_throw_internal(oldstmt));
108874 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108875 + gcc_assert(!gsi_end_p(gsi));
108876 +
108877 + cur_bb = gimple_bb(oldstmt);
108878 + next_bb = cur_bb->next_bb;
108879 + e = find_edge(cur_bb, next_bb);
108880 + gcc_assert(e != NULL);
108881 + gcc_assert(e->flags & EDGE_FALLTHRU);
108882 +
108883 + gsi = gsi_after_labels(next_bb);
108884 + gcc_assert(!gsi_end_p(gsi));
108885 +
108886 + before = true;
108887 + oldstmt = gsi_stmt(gsi);
108888 + }
108889 +
108890 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108891 + return new_lhs;
108892 +}
108893 +
108894 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108895 +{
108896 + gimple stmt;
108897 + gimple_stmt_iterator gsi;
108898 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108899 +
108900 + if (gimple_plf(oldstmt, MY_STMT))
108901 + return lhs;
108902 +
108903 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108904 + rhs1 = gimple_assign_rhs1(oldstmt);
108905 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108906 + }
108907 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108908 + rhs2 = gimple_assign_rhs2(oldstmt);
108909 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108910 + }
108911 +
108912 + stmt = gimple_copy(oldstmt);
108913 + gimple_set_location(stmt, gimple_location(oldstmt));
108914 + gimple_set_plf(stmt, MY_STMT, true);
108915 +
108916 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108917 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108918 +
108919 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108920 +
108921 + new_var = create_new_var(size_overflow_type);
108922 + new_var = make_ssa_name(new_var, stmt);
108923 + gimple_set_lhs(stmt, new_var);
108924 +
108925 + if (rhs1 != NULL_TREE)
108926 + gimple_assign_set_rhs1(stmt, rhs1);
108927 +
108928 + if (rhs2 != NULL_TREE)
108929 + gimple_assign_set_rhs2(stmt, rhs2);
108930 +#if BUILDING_GCC_VERSION >= 4007
108931 + if (rhs3 != NULL_TREE)
108932 + gimple_assign_set_rhs3(stmt, rhs3);
108933 +#endif
108934 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108935 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108936 +
108937 + gsi = gsi_for_stmt(oldstmt);
108938 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108939 + update_stmt(stmt);
108940 + pointer_set_insert(visited, oldstmt);
108941 + return gimple_get_lhs(stmt);
108942 +}
108943 +
108944 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
108945 +{
108946 + basic_block first_bb;
108947 + gimple assign;
108948 + gimple_stmt_iterator gsi;
108949 +
108950 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108951 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108952 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
108953 +
108954 + gsi = gsi_start_bb(first_bb);
108955 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108956 + return gimple_get_lhs(assign);
108957 +}
108958 +
108959 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
108960 +{
108961 + gimple_stmt_iterator gsi;
108962 + const_gimple assign;
108963 + gimple def_stmt = get_def_stmt(new_arg);
108964 +
108965 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
108966 + gsi = gsi_after_labels(gimple_bb(def_stmt));
108967 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
108968 + } else {
108969 + gsi = gsi_for_stmt(def_stmt);
108970 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
108971 + }
108972 +
108973 + return gimple_get_lhs(assign);
108974 +}
108975 +
108976 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
108977 +{
108978 + basic_block bb;
108979 + gimple_stmt_iterator gsi;
108980 + const_gimple assign, def_stmt;
108981 +
108982 + def_stmt = get_def_stmt(arg);
108983 + bb = gimple_bb(def_stmt);
108984 + gcc_assert(bb->index != 0);
108985 + gsi = gsi_after_labels(bb);
108986 +
108987 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108988 + return gimple_get_lhs(assign);
108989 +}
108990 +
108991 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
108992 +{
108993 + tree size_overflow_type;
108994 + const_gimple def_stmt = get_def_stmt(arg);
108995 +
108996 + if (phi_ssa_name != NULL_TREE)
108997 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
108998 +
108999 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
109000 +
109001 + if (new_arg != NULL_TREE) {
109002 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
109003 + return use_phi_ssa_name(phi_ssa_name, new_arg);
109004 + }
109005 +
109006 + switch(gimple_code(def_stmt)) {
109007 + case GIMPLE_PHI:
109008 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
109009 + case GIMPLE_NOP:
109010 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
109011 + default:
109012 + debug_gimple_stmt((gimple)def_stmt);
109013 + gcc_unreachable();
109014 + }
109015 +}
109016 +
109017 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
109018 +{
109019 + basic_block bb;
109020 + gimple phi;
109021 + gimple_seq seq;
109022 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
109023 +
109024 + bb = gsi_bb(gsi);
109025 +
109026 + phi = create_phi_node(result, bb);
109027 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
109028 + seq = phi_nodes(bb);
109029 + gsi = gsi_last(seq);
109030 + gsi_remove(&gsi, false);
109031 +
109032 + gsi = gsi_for_stmt(oldstmt);
109033 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
109034 + gimple_set_bb(phi, bb);
109035 + gimple_set_plf(phi, MY_STMT, true);
109036 + return phi;
109037 +}
109038 +
109039 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
109040 +{
109041 + gimple new_phi = NULL;
109042 + gimple oldstmt = get_def_stmt(orig_result);
109043 + tree phi_ssa_name = NULL_TREE;
109044 + unsigned int i;
109045 +
109046 + pointer_set_insert(visited, oldstmt);
109047 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
109048 + tree arg, new_arg;
109049 +
109050 + arg = gimple_phi_arg_def(oldstmt, i);
109051 +
109052 + new_arg = expand(visited, arg);
109053 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
109054 + if (i == 0) {
109055 + phi_ssa_name = new_arg;
109056 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
109057 + }
109058 +
109059 + gcc_assert(new_phi != NULL);
109060 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
109061 + }
109062 +
109063 + gcc_assert(new_phi != NULL);
109064 + update_stmt(new_phi);
109065 + return gimple_phi_result(new_phi);
109066 +}
109067 +
109068 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
109069 +{
109070 + const_gimple assign;
109071 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109072 + tree origtype = TREE_TYPE(orig_rhs);
109073 +
109074 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
109075 +
109076 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109077 + return gimple_get_lhs(assign);
109078 +}
109079 +
109080 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
109081 +{
109082 + const_tree rhs1, lhs, rhs1_type, lhs_type;
109083 + enum machine_mode lhs_mode, rhs_mode;
109084 + gimple def_stmt = get_def_stmt(no_const_rhs);
109085 +
109086 + if (!gimple_assign_cast_p(def_stmt))
109087 + return false;
109088 +
109089 + rhs1 = gimple_assign_rhs1(def_stmt);
109090 + lhs = gimple_get_lhs(def_stmt);
109091 + rhs1_type = TREE_TYPE(rhs1);
109092 + lhs_type = TREE_TYPE(lhs);
109093 + rhs_mode = TYPE_MODE(rhs1_type);
109094 + lhs_mode = TYPE_MODE(lhs_type);
109095 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
109096 + return false;
109097 +
109098 + return true;
109099 +}
109100 +
109101 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
109102 +{
109103 + tree rhs1 = gimple_assign_rhs1(stmt);
109104 + tree lhs = gimple_get_lhs(stmt);
109105 + const_tree rhs1_type = TREE_TYPE(rhs1);
109106 + const_tree lhs_type = TREE_TYPE(lhs);
109107 +
109108 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
109109 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109110 +
109111 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
109112 +}
109113 +
109114 +static bool no_uses(tree node)
109115 +{
109116 + imm_use_iterator imm_iter;
109117 + use_operand_p use_p;
109118 +
109119 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
109120 + const_gimple use_stmt = USE_STMT(use_p);
109121 + if (use_stmt == NULL)
109122 + return true;
109123 + if (is_gimple_debug(use_stmt))
109124 + continue;
109125 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
109126 + continue;
109127 + return false;
109128 + }
109129 + return true;
109130 +}
109131 +
109132 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
109133 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
109134 +{
109135 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
109136 + gimple def_stmt = get_def_stmt(lhs);
109137 +
109138 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109139 + return false;
109140 +
109141 + rhs1 = gimple_assign_rhs1(def_stmt);
109142 + rhs_type = TREE_TYPE(rhs1);
109143 + lhs_type = TREE_TYPE(lhs);
109144 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
109145 + return false;
109146 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
109147 + return false;
109148 +
109149 + def_stmt = get_def_stmt(rhs1);
109150 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
109151 + return false;
109152 +
109153 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
109154 + return false;
109155 +
109156 + rhs1 = gimple_assign_rhs1(def_stmt);
109157 + rhs2 = gimple_assign_rhs2(def_stmt);
109158 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
109159 + return false;
109160 +
109161 + if (is_gimple_constant(rhs2))
109162 + not_const_rhs = rhs1;
109163 + else
109164 + not_const_rhs = rhs2;
109165 +
109166 + return no_uses(not_const_rhs);
109167 +}
109168 +
109169 +static bool skip_lhs_cast_check(const_gimple stmt)
109170 +{
109171 + const_tree rhs = gimple_assign_rhs1(stmt);
109172 + const_gimple def_stmt = get_def_stmt(rhs);
109173 +
109174 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
109175 + if (gimple_code(def_stmt) == GIMPLE_ASM)
109176 + return true;
109177 +
109178 + if (is_const_plus_unsigned_signed_truncation(rhs))
109179 + return true;
109180 +
109181 + return false;
109182 +}
109183 +
109184 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
109185 +{
109186 + bool cast_lhs, cast_rhs;
109187 + tree lhs = gimple_get_lhs(stmt);
109188 + tree rhs = gimple_assign_rhs1(stmt);
109189 + const_tree lhs_type = TREE_TYPE(lhs);
109190 + const_tree rhs_type = TREE_TYPE(rhs);
109191 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
109192 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
109193 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
109194 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
109195 +
109196 + static bool check_lhs[3][4] = {
109197 + // ss su us uu
109198 + { false, true, true, false }, // lhs > rhs
109199 + { false, false, false, false }, // lhs = rhs
109200 + { true, true, true, true }, // lhs < rhs
109201 + };
109202 +
109203 + static bool check_rhs[3][4] = {
109204 + // ss su us uu
109205 + { true, false, true, true }, // lhs > rhs
109206 + { true, false, true, true }, // lhs = rhs
109207 + { true, false, true, true }, // lhs < rhs
109208 + };
109209 +
109210 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
109211 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
109212 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109213 +
109214 + if (lhs_size > rhs_size) {
109215 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109216 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109217 + } else if (lhs_size == rhs_size) {
109218 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109219 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109220 + } else {
109221 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109222 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109223 + }
109224 +
109225 + if (!cast_lhs && !cast_rhs)
109226 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109227 +
109228 + if (cast_lhs && !skip_lhs_cast_check(stmt))
109229 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
109230 +
109231 + if (cast_rhs)
109232 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
109233 +
109234 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109235 +}
109236 +
109237 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
109238 +{
109239 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
109240 +
109241 + if (gimple_plf(stmt, MY_STMT))
109242 + return lhs;
109243 +
109244 + rhs1 = gimple_assign_rhs1(stmt);
109245 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
109246 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109247 +
109248 + new_rhs1 = expand(visited, rhs1);
109249 +
109250 + if (new_rhs1 == NULL_TREE)
109251 + return create_cast_assign(visited, stmt);
109252 +
109253 + if (gimple_plf(stmt, NO_CAST_CHECK))
109254 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109255 +
109256 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
109257 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
109258 +
109259 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
109260 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
109261 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109262 + }
109263 +
109264 + if (!gimple_assign_cast_p(stmt))
109265 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109266 +
109267 + return create_cast_overflow_check(visited, new_rhs1, stmt);
109268 +}
109269 +
109270 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
109271 +{
109272 + tree rhs1, lhs = gimple_get_lhs(stmt);
109273 + gimple def_stmt = get_def_stmt(lhs);
109274 +
109275 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
109276 + rhs1 = gimple_assign_rhs1(def_stmt);
109277 +
109278 + if (is_gimple_constant(rhs1))
109279 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109280 +
109281 + switch (TREE_CODE(rhs1)) {
109282 + case SSA_NAME:
109283 + return handle_unary_rhs(visited, def_stmt);
109284 + case ARRAY_REF:
109285 + case BIT_FIELD_REF:
109286 + case ADDR_EXPR:
109287 + case COMPONENT_REF:
109288 + case INDIRECT_REF:
109289 +#if BUILDING_GCC_VERSION >= 4006
109290 + case MEM_REF:
109291 +#endif
109292 + case TARGET_MEM_REF:
109293 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109294 + case PARM_DECL:
109295 + case VAR_DECL:
109296 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109297 +
109298 + default:
109299 + debug_gimple_stmt(def_stmt);
109300 + debug_tree(rhs1);
109301 + gcc_unreachable();
109302 + }
109303 +}
109304 +
109305 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
109306 +{
109307 + gimple cond_stmt;
109308 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
109309 +
109310 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
109311 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
109312 + update_stmt(cond_stmt);
109313 +}
109314 +
109315 +static tree create_string_param(tree string)
109316 +{
109317 + tree i_type, a_type;
109318 + const int length = TREE_STRING_LENGTH(string);
109319 +
109320 + gcc_assert(length > 0);
109321 +
109322 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
109323 + a_type = build_array_type(char_type_node, i_type);
109324 +
109325 + TREE_TYPE(string) = a_type;
109326 + TREE_CONSTANT(string) = 1;
109327 + TREE_READONLY(string) = 1;
109328 +
109329 + return build1(ADDR_EXPR, ptr_type_node, string);
109330 +}
109331 +
109332 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
109333 +{
109334 + gimple func_stmt;
109335 + const_gimple def_stmt;
109336 + const_tree loc_line;
109337 + tree loc_file, ssa_name, current_func;
109338 + expanded_location xloc;
109339 + char *ssa_name_buf;
109340 + int len;
109341 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
109342 +
109343 + def_stmt = get_def_stmt(arg);
109344 + xloc = expand_location(gimple_location(def_stmt));
109345 +
109346 + if (!gimple_has_location(def_stmt)) {
109347 + xloc = expand_location(gimple_location(stmt));
109348 + if (!gimple_has_location(stmt))
109349 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
109350 + }
109351 +
109352 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
109353 +
109354 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
109355 + loc_file = create_string_param(loc_file);
109356 +
109357 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
109358 + current_func = create_string_param(current_func);
109359 +
109360 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
109361 + call_count++;
109362 + 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);
109363 + gcc_assert(len > 0);
109364 + ssa_name = build_string(len + 1, ssa_name_buf);
109365 + free(ssa_name_buf);
109366 + ssa_name = create_string_param(ssa_name);
109367 +
109368 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
109369 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
109370 +
109371 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
109372 +}
109373 +
109374 +static void __unused print_the_code_insertions(const_gimple stmt)
109375 +{
109376 + location_t loc = gimple_location(stmt);
109377 +
109378 + inform(loc, "Integer size_overflow check applied here.");
109379 +}
109380 +
109381 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
109382 +{
109383 + basic_block cond_bb, join_bb, bb_true;
109384 + edge e;
109385 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109386 +
109387 + cond_bb = gimple_bb(stmt);
109388 + if (before)
109389 + gsi_prev(&gsi);
109390 + if (gsi_end_p(gsi))
109391 + e = split_block_after_labels(cond_bb);
109392 + else
109393 + e = split_block(cond_bb, gsi_stmt(gsi));
109394 + cond_bb = e->src;
109395 + join_bb = e->dest;
109396 + e->flags = EDGE_FALSE_VALUE;
109397 + e->probability = REG_BR_PROB_BASE;
109398 +
109399 + bb_true = create_empty_bb(cond_bb);
109400 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109401 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109402 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109403 +
109404 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109405 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109406 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109407 +
109408 + if (current_loops != NULL) {
109409 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109410 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109411 + }
109412 +
109413 + insert_cond(cond_bb, arg, cond_code, type_value);
109414 + insert_cond_result(bb_true, stmt, arg, min);
109415 +
109416 +// print_the_code_insertions(stmt);
109417 +}
109418 +
109419 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109420 +{
109421 + const_tree rhs_type = TREE_TYPE(rhs);
109422 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109423 +
109424 + gcc_assert(rhs_type != NULL_TREE);
109425 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109426 + return;
109427 +
109428 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109429 +
109430 + if (is_const_plus_unsigned_signed_truncation(rhs))
109431 + return;
109432 +
109433 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109434 + // typemax (-1) < typemin (0)
109435 + if (TREE_OVERFLOW(type_max))
109436 + return;
109437 +
109438 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109439 +
109440 + cast_rhs_type = TREE_TYPE(cast_rhs);
109441 + type_max_type = TREE_TYPE(type_max);
109442 + type_min_type = TREE_TYPE(type_min);
109443 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109444 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109445 +
109446 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109447 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109448 +}
109449 +
109450 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109451 +{
109452 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109453 + return false;
109454 + if (!is_gimple_constant(rhs))
109455 + return false;
109456 + return true;
109457 +}
109458 +
109459 +static tree get_def_stmt_rhs(const_tree var)
109460 +{
109461 + tree rhs1, def_stmt_rhs1;
109462 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109463 +
109464 + def_stmt = get_def_stmt(var);
109465 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109466 +
109467 + rhs1 = gimple_assign_rhs1(def_stmt);
109468 + rhs1_def_stmt = get_def_stmt(rhs1);
109469 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109470 + return rhs1;
109471 +
109472 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109473 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109474 +
109475 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109476 + case GIMPLE_CALL:
109477 + case GIMPLE_NOP:
109478 + case GIMPLE_ASM:
109479 + case GIMPLE_PHI:
109480 + return def_stmt_rhs1;
109481 + case GIMPLE_ASSIGN:
109482 + return rhs1;
109483 + default:
109484 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109485 + gcc_unreachable();
109486 + }
109487 +}
109488 +
109489 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109490 +{
109491 + tree new_rhs, orig_rhs;
109492 + void (*gimple_assign_set_rhs)(gimple, tree);
109493 + tree rhs1 = gimple_assign_rhs1(stmt);
109494 + tree rhs2 = gimple_assign_rhs2(stmt);
109495 + tree lhs = gimple_get_lhs(stmt);
109496 +
109497 + if (!check_overflow)
109498 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109499 +
109500 + if (change_rhs == NULL_TREE)
109501 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109502 +
109503 + if (new_rhs2 == NULL_TREE) {
109504 + orig_rhs = rhs1;
109505 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109506 + } else {
109507 + orig_rhs = rhs2;
109508 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109509 + }
109510 +
109511 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109512 +
109513 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109514 + gimple_assign_set_rhs(stmt, new_rhs);
109515 + update_stmt(stmt);
109516 +
109517 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109518 +}
109519 +
109520 +static bool is_subtraction_special(const_gimple stmt)
109521 +{
109522 + gimple rhs1_def_stmt, rhs2_def_stmt;
109523 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109524 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109525 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109526 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109527 +
109528 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109529 + return false;
109530 +
109531 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109532 +
109533 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109534 + return false;
109535 +
109536 + rhs1_def_stmt = get_def_stmt(rhs1);
109537 + rhs2_def_stmt = get_def_stmt(rhs2);
109538 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109539 + return false;
109540 +
109541 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109542 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109543 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109544 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109545 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109546 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109547 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109548 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109549 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109550 + return false;
109551 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109552 + return false;
109553 +
109554 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109555 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109556 + return true;
109557 +}
109558 +
109559 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109560 +{
109561 + tree new_rhs1, new_rhs2;
109562 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109563 + gimple assign, stmt = get_def_stmt(lhs);
109564 + tree rhs1 = gimple_assign_rhs1(stmt);
109565 + tree rhs2 = gimple_assign_rhs2(stmt);
109566 +
109567 + if (!is_subtraction_special(stmt))
109568 + return NULL_TREE;
109569 +
109570 + new_rhs1 = expand(visited, rhs1);
109571 + new_rhs2 = expand(visited, rhs2);
109572 +
109573 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109574 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109575 +
109576 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109577 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109578 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109579 + }
109580 +
109581 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109582 + new_lhs = gimple_get_lhs(assign);
109583 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109584 +
109585 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109586 +}
109587 +
109588 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109589 +{
109590 + const_gimple def_stmt;
109591 +
109592 + if (TREE_CODE(rhs) != SSA_NAME)
109593 + return false;
109594 +
109595 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109596 + return false;
109597 +
109598 + def_stmt = get_def_stmt(rhs);
109599 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109600 + return false;
109601 +
109602 + return true;
109603 +}
109604 +
109605 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109606 +{
109607 + tree rhs1, rhs2, new_lhs;
109608 + gimple def_stmt = get_def_stmt(lhs);
109609 + tree new_rhs1 = NULL_TREE;
109610 + tree new_rhs2 = NULL_TREE;
109611 +
109612 + rhs1 = gimple_assign_rhs1(def_stmt);
109613 + rhs2 = gimple_assign_rhs2(def_stmt);
109614 +
109615 + /* no DImode/TImode division in the 32/64 bit kernel */
109616 + switch (gimple_assign_rhs_code(def_stmt)) {
109617 + case RDIV_EXPR:
109618 + case TRUNC_DIV_EXPR:
109619 + case CEIL_DIV_EXPR:
109620 + case FLOOR_DIV_EXPR:
109621 + case ROUND_DIV_EXPR:
109622 + case TRUNC_MOD_EXPR:
109623 + case CEIL_MOD_EXPR:
109624 + case FLOOR_MOD_EXPR:
109625 + case ROUND_MOD_EXPR:
109626 + case EXACT_DIV_EXPR:
109627 + case POINTER_PLUS_EXPR:
109628 + case BIT_AND_EXPR:
109629 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109630 + default:
109631 + break;
109632 + }
109633 +
109634 + new_lhs = handle_integer_truncation(visited, lhs);
109635 + if (new_lhs != NULL_TREE)
109636 + return new_lhs;
109637 +
109638 + if (TREE_CODE(rhs1) == SSA_NAME)
109639 + new_rhs1 = expand(visited, rhs1);
109640 + if (TREE_CODE(rhs2) == SSA_NAME)
109641 + new_rhs2 = expand(visited, rhs2);
109642 +
109643 + if (is_a_neg_overflow(def_stmt, rhs2))
109644 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109645 + if (is_a_neg_overflow(def_stmt, rhs1))
109646 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109647 +
109648 +
109649 + if (is_a_constant_overflow(def_stmt, rhs2))
109650 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109651 + if (is_a_constant_overflow(def_stmt, rhs1))
109652 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109653 +
109654 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109655 +}
109656 +
109657 +#if BUILDING_GCC_VERSION >= 4007
109658 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109659 +{
109660 + if (is_gimple_constant(rhs))
109661 + return cast_a_tree(size_overflow_type, rhs);
109662 + if (TREE_CODE(rhs) != SSA_NAME)
109663 + return NULL_TREE;
109664 + return expand(visited, rhs);
109665 +}
109666 +
109667 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109668 +{
109669 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109670 + gimple def_stmt = get_def_stmt(lhs);
109671 +
109672 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109673 +
109674 + rhs1 = gimple_assign_rhs1(def_stmt);
109675 + rhs2 = gimple_assign_rhs2(def_stmt);
109676 + rhs3 = gimple_assign_rhs3(def_stmt);
109677 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109678 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109679 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109680 +
109681 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109682 +}
109683 +#endif
109684 +
109685 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109686 +{
109687 + const_tree type;
109688 + tree new_type;
109689 +
109690 + gcc_assert(node != NULL_TREE);
109691 +
109692 + type = TREE_TYPE(node);
109693 +
109694 + if (gimple_plf(stmt, MY_STMT))
109695 + return TREE_TYPE(node);
109696 +
109697 + switch (TYPE_MODE(type)) {
109698 + case QImode:
109699 + new_type = intHI_type_node;
109700 + break;
109701 + case HImode:
109702 + new_type = intSI_type_node;
109703 + break;
109704 + case SImode:
109705 + new_type = intDI_type_node;
109706 + break;
109707 + case DImode:
109708 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109709 + new_type = intDI_type_node;
109710 + else
109711 + new_type = intTI_type_node;
109712 + break;
109713 + default:
109714 + debug_tree((tree)node);
109715 + error("%s: unsupported gcc configuration.", __func__);
109716 + gcc_unreachable();
109717 + }
109718 +
109719 + if (TYPE_QUALS(type) != 0)
109720 + return build_qualified_type(new_type, TYPE_QUALS(type));
109721 + return new_type;
109722 +}
109723 +
109724 +static tree expand_visited(gimple def_stmt)
109725 +{
109726 + const_gimple next_stmt;
109727 + gimple_stmt_iterator gsi;
109728 + enum gimple_code code = gimple_code(def_stmt);
109729 +
109730 + if (code == GIMPLE_ASM)
109731 + return NULL_TREE;
109732 +
109733 + gsi = gsi_for_stmt(def_stmt);
109734 + gsi_next(&gsi);
109735 +
109736 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109737 + return NULL_TREE;
109738 + gcc_assert(!gsi_end_p(gsi));
109739 + next_stmt = gsi_stmt(gsi);
109740 +
109741 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109742 + return NULL_TREE;
109743 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109744 +
109745 + return get_lhs(next_stmt);
109746 +}
109747 +
109748 +static tree expand(struct pointer_set_t *visited, tree lhs)
109749 +{
109750 + gimple def_stmt;
109751 +
109752 + if (skip_types(lhs))
109753 + return NULL_TREE;
109754 +
109755 + def_stmt = get_def_stmt(lhs);
109756 +
109757 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109758 + return NULL_TREE;
109759 +
109760 + if (gimple_plf(def_stmt, MY_STMT))
109761 + return lhs;
109762 +
109763 + if (pointer_set_contains(visited, def_stmt))
109764 + return expand_visited(def_stmt);
109765 +
109766 + switch (gimple_code(def_stmt)) {
109767 + case GIMPLE_PHI:
109768 + return handle_phi(visited, lhs);
109769 + case GIMPLE_CALL:
109770 + case GIMPLE_ASM:
109771 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109772 + case GIMPLE_ASSIGN:
109773 + switch (gimple_num_ops(def_stmt)) {
109774 + case 2:
109775 + return handle_unary_ops(visited, def_stmt);
109776 + case 3:
109777 + return handle_binary_ops(visited, lhs);
109778 +#if BUILDING_GCC_VERSION >= 4007
109779 + case 4:
109780 + return handle_ternary_ops(visited, lhs);
109781 +#endif
109782 + }
109783 + default:
109784 + debug_gimple_stmt(def_stmt);
109785 + error("%s: unknown gimple code", __func__);
109786 + gcc_unreachable();
109787 + }
109788 +}
109789 +
109790 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109791 +{
109792 + const_gimple assign;
109793 + tree orig_type = TREE_TYPE(orig_node);
109794 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109795 +
109796 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109797 + return gimple_get_lhs(assign);
109798 +}
109799 +
109800 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109801 +{
109802 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109803 + update_stmt(stmt);
109804 +}
109805 +
109806 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109807 +{
109808 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109809 + update_stmt(stmt);
109810 +}
109811 +
109812 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109813 +{
109814 + tree arg;
109815 + const_tree origarg;
109816 +
109817 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109818 + return true;
109819 +
109820 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109821 + while (origarg && *argnum) {
109822 + (*argnum)--;
109823 + origarg = TREE_CHAIN(origarg);
109824 + }
109825 +
109826 + gcc_assert(*argnum == 0);
109827 +
109828 + gcc_assert(origarg != NULL_TREE);
109829 + *argnum = 0;
109830 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109831 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109832 + return true;
109833 + return false;
109834 +}
109835 +
109836 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109837 +{
109838 + gimple phi = get_def_stmt(result);
109839 + unsigned int i, n = gimple_phi_num_args(phi);
109840 +
109841 + if (!phi)
109842 + return MARK_NO;
109843 +
109844 + pointer_set_insert(visited, phi);
109845 + for (i = 0; i < n; i++) {
109846 + enum mark marked;
109847 + const_tree arg = gimple_phi_arg_def(phi, i);
109848 + marked = pre_expand(visited, search_err_code, arg);
109849 + if (marked != MARK_NO)
109850 + return marked;
109851 + }
109852 + return MARK_NO;
109853 +}
109854 +
109855 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109856 +{
109857 + gimple def_stmt = get_def_stmt(lhs);
109858 + const_tree rhs;
109859 +
109860 + if (!def_stmt)
109861 + return MARK_NO;
109862 +
109863 + rhs = gimple_assign_rhs1(def_stmt);
109864 +
109865 + def_stmt = get_def_stmt(rhs);
109866 + if (is_gimple_constant(rhs))
109867 + search_err_code[FROM_CONST] = true;
109868 +
109869 + return pre_expand(visited, search_err_code, rhs);
109870 +}
109871 +
109872 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109873 +{
109874 + gimple def_stmt = get_def_stmt(lhs);
109875 + const_tree rhs1, rhs2;
109876 + enum mark marked;
109877 +
109878 + if (!def_stmt)
109879 + return MARK_NO;
109880 +
109881 + search_err_code[CAST_ONLY] = false;
109882 +
109883 + rhs1 = gimple_assign_rhs1(def_stmt);
109884 + rhs2 = gimple_assign_rhs2(def_stmt);
109885 + marked = pre_expand(visited, search_err_code, rhs1);
109886 + if (marked != MARK_NO)
109887 + return marked;
109888 + return pre_expand(visited, search_err_code, rhs2);
109889 +}
109890 +
109891 +static const_tree search_field_decl(const_tree comp_ref)
109892 +{
109893 + const_tree field = NULL_TREE;
109894 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109895 +
109896 + for (i = 0; i < len; i++) {
109897 + field = TREE_OPERAND(comp_ref, i);
109898 + if (TREE_CODE(field) == FIELD_DECL)
109899 + break;
109900 + }
109901 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109902 + return field;
109903 +}
109904 +
109905 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109906 +{
109907 + const_tree attr, p;
109908 +
109909 + // mm/filemap.c D.35286_51 = D.35283_46 (file_10(D), mapping_11, pos_1, D.35273_50, D.35285_49, page.14_48, fsdata.15_47);
109910 + if (fndecl == NULL_TREE)
109911 + return MARK_NO;
109912 +
109913 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109914 + if (!attr || !TREE_VALUE(attr))
109915 + return MARK_NO;
109916 +
109917 + p = TREE_VALUE(attr);
109918 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109919 + return MARK_TURN_OFF;
109920 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109921 + return MARK_NOT_INTENTIONAL;
109922 + if (argnum == 0) {
109923 + gcc_assert(current_function_decl == fndecl);
109924 + return MARK_NO;
109925 + }
109926 +
109927 + do {
109928 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109929 + return MARK_YES;
109930 + p = TREE_CHAIN(p);
109931 + } while (p);
109932 +
109933 + return MARK_NO;
109934 +}
109935 +
109936 +static void print_missing_msg(tree func, unsigned int argnum)
109937 +{
109938 + unsigned int new_hash;
109939 + size_t len;
109940 + unsigned char tree_codes[CODES_LIMIT];
109941 + location_t loc;
109942 + const char *curfunc;
109943 +
109944 + func = get_original_function_decl(func);
109945 + loc = DECL_SOURCE_LOCATION(func);
109946 + curfunc = get_asm_name(func);
109947 +
109948 + len = get_function_decl(func, tree_codes);
109949 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
109950 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
109951 +}
109952 +
109953 +static unsigned int search_missing_attribute(const_tree arg)
109954 +{
109955 + unsigned int argnum;
109956 + const struct size_overflow_hash *hash;
109957 + const_tree type = TREE_TYPE(arg);
109958 + tree func = get_original_function_decl(current_function_decl);
109959 +
109960 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
109961 +
109962 + if (TREE_CODE(type) == POINTER_TYPE)
109963 + return 0;
109964 +
109965 + argnum = find_arg_number(arg, func);
109966 + if (argnum == 0)
109967 + return 0;
109968 +
109969 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
109970 + return argnum;
109971 +
109972 + hash = get_function_hash(func);
109973 + if (!hash || !(hash->param & (1U << argnum))) {
109974 + print_missing_msg(func, argnum);
109975 + return 0;
109976 + }
109977 + return argnum;
109978 +}
109979 +
109980 +static enum mark is_already_marked(const_tree lhs)
109981 +{
109982 + unsigned int argnum;
109983 + const_tree fndecl;
109984 +
109985 + argnum = search_missing_attribute(lhs);
109986 + fndecl = get_original_function_decl(current_function_decl);
109987 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
109988 + return MARK_YES;
109989 + return MARK_NO;
109990 +}
109991 +
109992 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109993 +{
109994 + const_gimple def_stmt;
109995 +
109996 + if (skip_types(lhs))
109997 + return MARK_NO;
109998 +
109999 + if (TREE_CODE(lhs) == PARM_DECL)
110000 + return is_already_marked(lhs);
110001 +
110002 + if (TREE_CODE(lhs) == COMPONENT_REF) {
110003 + const_tree field, attr;
110004 +
110005 + field = search_field_decl(lhs);
110006 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
110007 + if (!attr || !TREE_VALUE(attr))
110008 + return MARK_NO;
110009 + return MARK_YES;
110010 + }
110011 +
110012 + def_stmt = get_def_stmt(lhs);
110013 +
110014 + if (!def_stmt)
110015 + return MARK_NO;
110016 +
110017 + if (pointer_set_contains(visited, def_stmt))
110018 + return MARK_NO;
110019 +
110020 + switch (gimple_code(def_stmt)) {
110021 + case GIMPLE_NOP:
110022 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
110023 + return is_already_marked(lhs);
110024 + return MARK_NO;
110025 + case GIMPLE_PHI:
110026 + return walk_phi(visited, search_err_code, lhs);
110027 + case GIMPLE_CALL:
110028 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
110029 + return MARK_TURN_OFF;
110030 + check_function_hash(def_stmt);
110031 + return MARK_NO;
110032 + case GIMPLE_ASM:
110033 + search_err_code[CAST_ONLY] = false;
110034 + return MARK_NO;
110035 + case GIMPLE_ASSIGN:
110036 + switch (gimple_num_ops(def_stmt)) {
110037 + case 2:
110038 + return walk_unary_ops(visited, search_err_code, lhs);
110039 + case 3:
110040 + return walk_binary_ops(visited, search_err_code, lhs);
110041 + }
110042 + default:
110043 + debug_gimple_stmt((gimple)def_stmt);
110044 + error("%s: unknown gimple code", __func__);
110045 + gcc_unreachable();
110046 + }
110047 +}
110048 +
110049 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
110050 +static bool skip_asm(const_tree arg)
110051 +{
110052 + gimple def_stmt = get_def_stmt(arg);
110053 +
110054 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110055 + return false;
110056 +
110057 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
110058 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
110059 +}
110060 +
110061 +/*
110062 +0</MARK_YES: no dup, search attributes (so, int)
110063 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
110064 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
110065 +*/
110066 +
110067 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
110068 +{
110069 + struct pointer_set_t *visited;
110070 + enum mark is_marked, is_found;
110071 + location_t loc;
110072 + bool search_err_code[2] = {true, false};
110073 +
110074 + is_marked = mark_status(current_function_decl, 0);
110075 + if (is_marked == MARK_TURN_OFF)
110076 + return true;
110077 +
110078 + is_marked = mark_status(fndecl, argnum + 1);
110079 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
110080 + return true;
110081 +
110082 + visited = pointer_set_create();
110083 + is_found = pre_expand(visited, search_err_code, arg);
110084 + pointer_set_destroy(visited);
110085 +
110086 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
110087 + return true;
110088 +
110089 + if (where == FROM_ARG && skip_asm(arg))
110090 + return true;
110091 +
110092 + if (is_found == MARK_TURN_OFF)
110093 + return true;
110094 +
110095 + if ((is_found == MARK_YES && is_marked == MARK_YES))
110096 + return true;
110097 +
110098 + if (is_found == MARK_YES) {
110099 + loc = DECL_SOURCE_LOCATION(fndecl);
110100 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
110101 + return true;
110102 + }
110103 + return false;
110104 +}
110105 +
110106 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
110107 +{
110108 + struct pointer_set_t *visited;
110109 + tree arg, new_arg;
110110 + bool match;
110111 +
110112 + if (argnum == 0)
110113 + return;
110114 +
110115 + argnum--;
110116 +
110117 + match = get_function_arg(&argnum, fndecl);
110118 + if (!match)
110119 + return;
110120 + gcc_assert(gimple_call_num_args(stmt) > argnum);
110121 + arg = gimple_call_arg(stmt, argnum);
110122 + if (arg == NULL_TREE)
110123 + return;
110124 +
110125 + if (skip_types(arg))
110126 + return;
110127 +
110128 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
110129 + return;
110130 +
110131 + visited = pointer_set_create();
110132 + new_arg = expand(visited, arg);
110133 + pointer_set_destroy(visited);
110134 +
110135 + if (new_arg == NULL_TREE)
110136 + return;
110137 +
110138 + change_function_arg(stmt, arg, argnum, new_arg);
110139 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
110140 +}
110141 +
110142 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
110143 +{
110144 + tree p = TREE_VALUE(attr);
110145 + do {
110146 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
110147 + p = TREE_CHAIN(p);
110148 + } while (p);
110149 +}
110150 +
110151 +static void handle_function_by_hash(gimple stmt, tree fndecl)
110152 +{
110153 + unsigned int num;
110154 + const struct size_overflow_hash *hash;
110155 +
110156 + hash = get_function_hash(fndecl);
110157 + if (!hash)
110158 + return;
110159 +
110160 + for (num = 0; num <= MAX_PARAM; num++)
110161 + if (hash->param & (1U << num))
110162 + handle_function_arg(stmt, fndecl, num);
110163 +}
110164 +
110165 +static bool check_return_value(void)
110166 +{
110167 + const struct size_overflow_hash *hash;
110168 +
110169 + hash = get_function_hash(current_function_decl);
110170 + if (!hash || !(hash->param & 1U << 0))
110171 + return false;
110172 +
110173 + return true;
110174 +}
110175 +
110176 +static void handle_return_value(gimple ret_stmt)
110177 +{
110178 + struct pointer_set_t *visited;
110179 + tree ret, new_ret;
110180 +
110181 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
110182 + return;
110183 +
110184 + ret = gimple_return_retval(ret_stmt);
110185 +
110186 + if (skip_types(ret))
110187 + return;
110188 +
110189 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
110190 + return;
110191 +
110192 + visited = pointer_set_create();
110193 + new_ret = expand(visited, ret);
110194 + pointer_set_destroy(visited);
110195 +
110196 + change_function_return(ret_stmt, ret, new_ret);
110197 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
110198 +}
110199 +
110200 +static void set_plf_false(void)
110201 +{
110202 + basic_block bb;
110203 +
110204 + FOR_ALL_BB(bb) {
110205 + gimple_stmt_iterator si;
110206 +
110207 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
110208 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110209 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
110210 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110211 + }
110212 +}
110213 +
110214 +static unsigned int handle_function(void)
110215 +{
110216 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
110217 + bool check_ret;
110218 +
110219 + set_plf_false();
110220 +
110221 + check_ret = check_return_value();
110222 +
110223 + do {
110224 + gimple_stmt_iterator gsi;
110225 + next = bb->next_bb;
110226 +
110227 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110228 + tree fndecl, attr;
110229 + gimple stmt = gsi_stmt(gsi);
110230 +
110231 + if (check_ret)
110232 + handle_return_value(stmt);
110233 +
110234 + if (!(is_gimple_call(stmt)))
110235 + continue;
110236 + fndecl = gimple_call_fndecl(stmt);
110237 + if (fndecl == NULL_TREE)
110238 + continue;
110239 + if (gimple_call_num_args(stmt) == 0)
110240 + continue;
110241 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110242 + if (!attr || !TREE_VALUE(attr))
110243 + handle_function_by_hash(stmt, fndecl);
110244 + else
110245 + handle_function_by_attribute(stmt, attr, fndecl);
110246 + gsi = gsi_for_stmt(stmt);
110247 + next = gimple_bb(stmt)->next_bb;
110248 + }
110249 + bb = next;
110250 + } while (bb);
110251 + return 0;
110252 +}
110253 +
110254 +static struct gimple_opt_pass size_overflow_pass = {
110255 + .pass = {
110256 + .type = GIMPLE_PASS,
110257 + .name = "size_overflow",
110258 +#if BUILDING_GCC_VERSION >= 4008
110259 + .optinfo_flags = OPTGROUP_NONE,
110260 +#endif
110261 + .gate = NULL,
110262 + .execute = handle_function,
110263 + .sub = NULL,
110264 + .next = NULL,
110265 + .static_pass_number = 0,
110266 + .tv_id = TV_NONE,
110267 + .properties_required = PROP_cfg,
110268 + .properties_provided = 0,
110269 + .properties_destroyed = 0,
110270 + .todo_flags_start = 0,
110271 + .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
110272 + }
110273 +};
110274 +
110275 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
110276 +{
110277 + tree fntype;
110278 +
110279 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
110280 +
110281 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
110282 + fntype = build_function_type_list(void_type_node,
110283 + const_char_ptr_type_node,
110284 + unsigned_type_node,
110285 + const_char_ptr_type_node,
110286 + const_char_ptr_type_node,
110287 + NULL_TREE);
110288 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
110289 +
110290 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
110291 + TREE_PUBLIC(report_size_overflow_decl) = 1;
110292 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
110293 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
110294 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
110295 +}
110296 +
110297 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110298 +{
110299 + int i;
110300 + const char * const plugin_name = plugin_info->base_name;
110301 + const int argc = plugin_info->argc;
110302 + const struct plugin_argument * const argv = plugin_info->argv;
110303 + bool enable = true;
110304 +
110305 + struct register_pass_info size_overflow_pass_info = {
110306 + .pass = &size_overflow_pass.pass,
110307 + .reference_pass_name = "ssa",
110308 + .ref_pass_instance_number = 1,
110309 + .pos_op = PASS_POS_INSERT_AFTER
110310 + };
110311 +
110312 + if (!plugin_default_version_check(version, &gcc_version)) {
110313 + error(G_("incompatible gcc/plugin versions"));
110314 + return 1;
110315 + }
110316 +
110317 + for (i = 0; i < argc; ++i) {
110318 + if (!strcmp(argv[i].key, "no-size-overflow")) {
110319 + enable = false;
110320 + continue;
110321 + }
110322 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110323 + }
110324 +
110325 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
110326 + if (enable) {
110327 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
110328 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
110329 + }
110330 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110331 +
110332 + return 0;
110333 +}
110334 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
110335 new file mode 100644
110336 index 0000000..ac2901e
110337 --- /dev/null
110338 +++ b/tools/gcc/stackleak_plugin.c
110339 @@ -0,0 +1,327 @@
110340 +/*
110341 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
110342 + * Licensed under the GPL v2
110343 + *
110344 + * Note: the choice of the license means that the compilation process is
110345 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110346 + * but for the kernel it doesn't matter since it doesn't link against
110347 + * any of the gcc libraries
110348 + *
110349 + * gcc plugin to help implement various PaX features
110350 + *
110351 + * - track lowest stack pointer
110352 + *
110353 + * TODO:
110354 + * - initialize all local variables
110355 + *
110356 + * BUGS:
110357 + * - none known
110358 + */
110359 +#include "gcc-plugin.h"
110360 +#include "config.h"
110361 +#include "system.h"
110362 +#include "coretypes.h"
110363 +#include "tree.h"
110364 +#include "tree-pass.h"
110365 +#include "flags.h"
110366 +#include "intl.h"
110367 +#include "toplev.h"
110368 +#include "plugin.h"
110369 +//#include "expr.h" where are you...
110370 +#include "diagnostic.h"
110371 +#include "plugin-version.h"
110372 +#include "tm.h"
110373 +#include "function.h"
110374 +#include "basic-block.h"
110375 +#include "gimple.h"
110376 +#include "rtl.h"
110377 +#include "emit-rtl.h"
110378 +
110379 +#if BUILDING_GCC_VERSION >= 4008
110380 +#define TODO_dump_func 0
110381 +#endif
110382 +
110383 +extern void print_gimple_stmt(FILE *, gimple, int, int);
110384 +
110385 +int plugin_is_GPL_compatible;
110386 +
110387 +static int track_frame_size = -1;
110388 +static const char track_function[] = "pax_track_stack";
110389 +static const char check_function[] = "pax_check_alloca";
110390 +static bool init_locals;
110391 +
110392 +static struct plugin_info stackleak_plugin_info = {
110393 + .version = "201302112000",
110394 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110395 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110396 +};
110397 +
110398 +static bool gate_stackleak_track_stack(void);
110399 +static unsigned int execute_stackleak_tree_instrument(void);
110400 +static unsigned int execute_stackleak_final(void);
110401 +
110402 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110403 + .pass = {
110404 + .type = GIMPLE_PASS,
110405 + .name = "stackleak_tree_instrument",
110406 +#if BUILDING_GCC_VERSION >= 4008
110407 + .optinfo_flags = OPTGROUP_NONE,
110408 +#endif
110409 + .gate = gate_stackleak_track_stack,
110410 + .execute = execute_stackleak_tree_instrument,
110411 + .sub = NULL,
110412 + .next = NULL,
110413 + .static_pass_number = 0,
110414 + .tv_id = TV_NONE,
110415 + .properties_required = PROP_gimple_leh | PROP_cfg,
110416 + .properties_provided = 0,
110417 + .properties_destroyed = 0,
110418 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110419 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110420 + }
110421 +};
110422 +
110423 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110424 + .pass = {
110425 + .type = RTL_PASS,
110426 + .name = "stackleak_final",
110427 +#if BUILDING_GCC_VERSION >= 4008
110428 + .optinfo_flags = OPTGROUP_NONE,
110429 +#endif
110430 + .gate = gate_stackleak_track_stack,
110431 + .execute = execute_stackleak_final,
110432 + .sub = NULL,
110433 + .next = NULL,
110434 + .static_pass_number = 0,
110435 + .tv_id = TV_NONE,
110436 + .properties_required = 0,
110437 + .properties_provided = 0,
110438 + .properties_destroyed = 0,
110439 + .todo_flags_start = 0,
110440 + .todo_flags_finish = TODO_dump_func
110441 + }
110442 +};
110443 +
110444 +static bool gate_stackleak_track_stack(void)
110445 +{
110446 + return track_frame_size >= 0;
110447 +}
110448 +
110449 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110450 +{
110451 + gimple check_alloca;
110452 + tree fntype, fndecl, alloca_size;
110453 +
110454 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110455 + fndecl = build_fn_decl(check_function, fntype);
110456 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110457 +
110458 + // insert call to void pax_check_alloca(unsigned long size)
110459 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110460 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110461 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110462 +}
110463 +
110464 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110465 +{
110466 + gimple track_stack;
110467 + tree fntype, fndecl;
110468 +
110469 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110470 + fndecl = build_fn_decl(track_function, fntype);
110471 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110472 +
110473 + // insert call to void pax_track_stack(void)
110474 + track_stack = gimple_build_call(fndecl, 0);
110475 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110476 +}
110477 +
110478 +#if BUILDING_GCC_VERSION == 4005
110479 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110480 +{
110481 + tree fndecl;
110482 +
110483 + if (!is_gimple_call(stmt))
110484 + return false;
110485 + fndecl = gimple_call_fndecl(stmt);
110486 + if (!fndecl)
110487 + return false;
110488 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110489 + return false;
110490 +// print_node(stderr, "pax", fndecl, 4);
110491 + return DECL_FUNCTION_CODE(fndecl) == code;
110492 +}
110493 +#endif
110494 +
110495 +static bool is_alloca(gimple stmt)
110496 +{
110497 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110498 + return true;
110499 +
110500 +#if BUILDING_GCC_VERSION >= 4007
110501 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110502 + return true;
110503 +#endif
110504 +
110505 + return false;
110506 +}
110507 +
110508 +static unsigned int execute_stackleak_tree_instrument(void)
110509 +{
110510 + basic_block bb, entry_bb;
110511 + bool prologue_instrumented = false, is_leaf = true;
110512 +
110513 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110514 +
110515 + // 1. loop through BBs and GIMPLE statements
110516 + FOR_EACH_BB(bb) {
110517 + gimple_stmt_iterator gsi;
110518 +
110519 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110520 + gimple stmt;
110521 +
110522 + stmt = gsi_stmt(gsi);
110523 +
110524 + if (is_gimple_call(stmt))
110525 + is_leaf = false;
110526 +
110527 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110528 + if (!is_alloca(stmt))
110529 + continue;
110530 +
110531 + // 2. insert stack overflow check before each __builtin_alloca call
110532 + stackleak_check_alloca(&gsi);
110533 +
110534 + // 3. insert track call after each __builtin_alloca call
110535 + stackleak_add_instrumentation(&gsi);
110536 + if (bb == entry_bb)
110537 + prologue_instrumented = true;
110538 + }
110539 + }
110540 +
110541 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110542 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110543 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110544 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110545 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110546 + return 0;
110547 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110548 + return 0;
110549 +
110550 + // 4. insert track call at the beginning
110551 + if (!prologue_instrumented) {
110552 + gimple_stmt_iterator gsi;
110553 +
110554 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110555 + if (dom_info_available_p(CDI_DOMINATORS))
110556 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110557 + gsi = gsi_start_bb(bb);
110558 + stackleak_add_instrumentation(&gsi);
110559 + }
110560 +
110561 + return 0;
110562 +}
110563 +
110564 +static unsigned int execute_stackleak_final(void)
110565 +{
110566 + rtx insn, next;
110567 +
110568 + if (cfun->calls_alloca)
110569 + return 0;
110570 +
110571 + // keep calls only if function frame is big enough
110572 + if (get_frame_size() >= track_frame_size)
110573 + return 0;
110574 +
110575 + // 1. find pax_track_stack calls
110576 + for (insn = get_insns(); insn; insn = next) {
110577 + // 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))
110578 + rtx body;
110579 +
110580 + next = NEXT_INSN(insn);
110581 + if (!CALL_P(insn))
110582 + continue;
110583 + body = PATTERN(insn);
110584 + if (GET_CODE(body) != CALL)
110585 + continue;
110586 + body = XEXP(body, 0);
110587 + if (GET_CODE(body) != MEM)
110588 + continue;
110589 + body = XEXP(body, 0);
110590 + if (GET_CODE(body) != SYMBOL_REF)
110591 + continue;
110592 + if (strcmp(XSTR(body, 0), track_function))
110593 + continue;
110594 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110595 + // 2. delete call
110596 + delete_insn_and_edges(insn);
110597 +#if BUILDING_GCC_VERSION >= 4007
110598 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110599 + insn = next;
110600 + next = NEXT_INSN(insn);
110601 + delete_insn_and_edges(insn);
110602 + }
110603 +#endif
110604 + }
110605 +
110606 +// print_simple_rtl(stderr, get_insns());
110607 +// print_rtl(stderr, get_insns());
110608 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110609 +
110610 + return 0;
110611 +}
110612 +
110613 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110614 +{
110615 + const char * const plugin_name = plugin_info->base_name;
110616 + const int argc = plugin_info->argc;
110617 + const struct plugin_argument * const argv = plugin_info->argv;
110618 + int i;
110619 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110620 + .pass = &stackleak_tree_instrument_pass.pass,
110621 +// .reference_pass_name = "tree_profile",
110622 + .reference_pass_name = "optimized",
110623 + .ref_pass_instance_number = 1,
110624 + .pos_op = PASS_POS_INSERT_BEFORE
110625 + };
110626 + struct register_pass_info stackleak_final_pass_info = {
110627 + .pass = &stackleak_final_rtl_opt_pass.pass,
110628 + .reference_pass_name = "final",
110629 + .ref_pass_instance_number = 1,
110630 + .pos_op = PASS_POS_INSERT_BEFORE
110631 + };
110632 +
110633 + if (!plugin_default_version_check(version, &gcc_version)) {
110634 + error(G_("incompatible gcc/plugin versions"));
110635 + return 1;
110636 + }
110637 +
110638 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110639 +
110640 + for (i = 0; i < argc; ++i) {
110641 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110642 + if (!argv[i].value) {
110643 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110644 + continue;
110645 + }
110646 + track_frame_size = atoi(argv[i].value);
110647 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110648 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110649 + continue;
110650 + }
110651 + if (!strcmp(argv[i].key, "initialize-locals")) {
110652 + if (argv[i].value) {
110653 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110654 + continue;
110655 + }
110656 + init_locals = true;
110657 + continue;
110658 + }
110659 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110660 + }
110661 +
110662 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110663 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110664 +
110665 + return 0;
110666 +}
110667 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110668 new file mode 100644
110669 index 0000000..4fae911
110670 --- /dev/null
110671 +++ b/tools/gcc/structleak_plugin.c
110672 @@ -0,0 +1,277 @@
110673 +/*
110674 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110675 + * Licensed under the GPL v2
110676 + *
110677 + * Note: the choice of the license means that the compilation process is
110678 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110679 + * but for the kernel it doesn't matter since it doesn't link against
110680 + * any of the gcc libraries
110681 + *
110682 + * gcc plugin to forcibly initialize certain local variables that could
110683 + * otherwise leak kernel stack to userland if they aren't properly initialized
110684 + * by later code
110685 + *
110686 + * Homepage: http://pax.grsecurity.net/
110687 + *
110688 + * Usage:
110689 + * $ # for 4.5/4.6/C based 4.7
110690 + * $ 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
110691 + * $ # for C++ based 4.7/4.8+
110692 + * $ 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
110693 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110694 + *
110695 + * TODO: eliminate redundant initializers
110696 + * increase type coverage
110697 + */
110698 +
110699 +#include "gcc-plugin.h"
110700 +#include "config.h"
110701 +#include "system.h"
110702 +#include "coretypes.h"
110703 +#include "tree.h"
110704 +#include "tree-pass.h"
110705 +#include "intl.h"
110706 +#include "plugin-version.h"
110707 +#include "tm.h"
110708 +#include "toplev.h"
110709 +#include "function.h"
110710 +#include "tree-flow.h"
110711 +#include "plugin.h"
110712 +#include "gimple.h"
110713 +#include "diagnostic.h"
110714 +#include "cfgloop.h"
110715 +#include "langhooks.h"
110716 +
110717 +#if BUILDING_GCC_VERSION >= 4008
110718 +#define TODO_dump_func 0
110719 +#endif
110720 +
110721 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110722 +
110723 +// unused type flag in all versions 4.5-4.8
110724 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110725 +
110726 +int plugin_is_GPL_compatible;
110727 +void debug_gimple_stmt(gimple gs);
110728 +
110729 +static struct plugin_info structleak_plugin_info = {
110730 + .version = "201304082245",
110731 + .help = "disable\tdo not activate plugin\n",
110732 +};
110733 +
110734 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110735 +{
110736 + *no_add_attrs = true;
110737 +
110738 + // check for types? for now accept everything linux has to offer
110739 + if (TREE_CODE(*node) != FIELD_DECL)
110740 + return NULL_TREE;
110741 +
110742 + *no_add_attrs = false;
110743 + return NULL_TREE;
110744 +}
110745 +
110746 +static struct attribute_spec user_attr = {
110747 + .name = "user",
110748 + .min_length = 0,
110749 + .max_length = 0,
110750 + .decl_required = false,
110751 + .type_required = false,
110752 + .function_type_required = false,
110753 + .handler = handle_user_attribute,
110754 +#if BUILDING_GCC_VERSION >= 4007
110755 + .affects_type_identity = true
110756 +#endif
110757 +};
110758 +
110759 +static void register_attributes(void *event_data, void *data)
110760 +{
110761 + register_attribute(&user_attr);
110762 +// register_attribute(&force_attr);
110763 +}
110764 +
110765 +static tree get_field_type(tree field)
110766 +{
110767 + return strip_array_types(TREE_TYPE(field));
110768 +}
110769 +
110770 +static bool is_userspace_type(tree type)
110771 +{
110772 + tree field;
110773 +
110774 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110775 + tree fieldtype = get_field_type(field);
110776 + enum tree_code code = TREE_CODE(fieldtype);
110777 +
110778 + if (code == RECORD_TYPE || code == UNION_TYPE)
110779 + if (is_userspace_type(fieldtype))
110780 + return true;
110781 +
110782 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110783 + return true;
110784 + }
110785 + return false;
110786 +}
110787 +
110788 +static void finish_type(void *event_data, void *data)
110789 +{
110790 + tree type = (tree)event_data;
110791 +
110792 + if (TYPE_USERSPACE(type))
110793 + return;
110794 +
110795 + if (is_userspace_type(type))
110796 + TYPE_USERSPACE(type) = 1;
110797 +}
110798 +
110799 +static void initialize(tree var)
110800 +{
110801 + basic_block bb;
110802 + gimple_stmt_iterator gsi;
110803 + tree initializer;
110804 + gimple init_stmt;
110805 +
110806 + // this is the original entry bb before the forced split
110807 + // TODO: check further BBs in case more splits occured before us
110808 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110809 +
110810 + // first check if the variable is already initialized, warn otherwise
110811 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110812 + gimple stmt = gsi_stmt(gsi);
110813 + tree rhs1;
110814 +
110815 + // we're looking for an assignment of a single rhs...
110816 + if (!gimple_assign_single_p(stmt))
110817 + continue;
110818 + rhs1 = gimple_assign_rhs1(stmt);
110819 +#if BUILDING_GCC_VERSION >= 4007
110820 + // ... of a non-clobbering expression...
110821 + if (TREE_CLOBBER_P(rhs1))
110822 + continue;
110823 +#endif
110824 + // ... to our variable...
110825 + if (gimple_get_lhs(stmt) != var)
110826 + continue;
110827 + // if it's an initializer then we're good
110828 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110829 + return;
110830 + }
110831 +
110832 + // these aren't the 0days you're looking for
110833 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110834 +
110835 + // build the initializer expression
110836 + initializer = build_constructor(TREE_TYPE(var), NULL);
110837 +
110838 + // build the initializer stmt
110839 + init_stmt = gimple_build_assign(var, initializer);
110840 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110841 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110842 + update_stmt(init_stmt);
110843 +}
110844 +
110845 +static unsigned int handle_function(void)
110846 +{
110847 + basic_block bb;
110848 + unsigned int ret = 0;
110849 + tree var;
110850 +
110851 +#if BUILDING_GCC_VERSION == 4005
110852 + tree vars;
110853 +#else
110854 + unsigned int i;
110855 +#endif
110856 +
110857 + // split the first bb where we can put the forced initializers
110858 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110859 + if (dom_info_available_p(CDI_DOMINATORS))
110860 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110861 +
110862 + // enumarate all local variables and forcibly initialize our targets
110863 +#if BUILDING_GCC_VERSION == 4005
110864 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110865 + var = TREE_VALUE(vars);
110866 +#else
110867 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110868 +#endif
110869 + tree type = TREE_TYPE(var);
110870 +
110871 + gcc_assert(DECL_P(var));
110872 + if (!auto_var_in_fn_p(var, current_function_decl))
110873 + continue;
110874 +
110875 + // only care about structure types
110876 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110877 + continue;
110878 +
110879 + // if the type is of interest, examine the variable
110880 + if (TYPE_USERSPACE(type))
110881 + initialize(var);
110882 + }
110883 +
110884 + return ret;
110885 +}
110886 +
110887 +static struct gimple_opt_pass structleak_pass = {
110888 + .pass = {
110889 + .type = GIMPLE_PASS,
110890 + .name = "structleak",
110891 +#if BUILDING_GCC_VERSION >= 4008
110892 + .optinfo_flags = OPTGROUP_NONE,
110893 +#endif
110894 + .gate = NULL,
110895 + .execute = handle_function,
110896 + .sub = NULL,
110897 + .next = NULL,
110898 + .static_pass_number = 0,
110899 + .tv_id = TV_NONE,
110900 + .properties_required = PROP_cfg,
110901 + .properties_provided = 0,
110902 + .properties_destroyed = 0,
110903 + .todo_flags_start = 0,
110904 + .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
110905 + }
110906 +};
110907 +
110908 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110909 +{
110910 + int i;
110911 + const char * const plugin_name = plugin_info->base_name;
110912 + const int argc = plugin_info->argc;
110913 + const struct plugin_argument * const argv = plugin_info->argv;
110914 + bool enable = true;
110915 +
110916 + struct register_pass_info structleak_pass_info = {
110917 + .pass = &structleak_pass.pass,
110918 + .reference_pass_name = "ssa",
110919 + .ref_pass_instance_number = 1,
110920 + .pos_op = PASS_POS_INSERT_AFTER
110921 + };
110922 +
110923 + if (!plugin_default_version_check(version, &gcc_version)) {
110924 + error(G_("incompatible gcc/plugin versions"));
110925 + return 1;
110926 + }
110927 +
110928 + if (strcmp(lang_hooks.name, "GNU C")) {
110929 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110930 + enable = false;
110931 + }
110932 +
110933 + for (i = 0; i < argc; ++i) {
110934 + if (!strcmp(argv[i].key, "disable")) {
110935 + enable = false;
110936 + continue;
110937 + }
110938 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110939 + }
110940 +
110941 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
110942 + if (enable) {
110943 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
110944 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
110945 + }
110946 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110947 +
110948 + return 0;
110949 +}
110950 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
110951 index 280dd82..077b427 100644
110952 --- a/tools/lib/lk/Makefile
110953 +++ b/tools/lib/lk/Makefile
110954 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
110955
110956 LIBFILE = liblk.a
110957
110958 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110959 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110960 EXTLIBS = -lelf -lpthread -lrt -lm
110961 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
110962 ALL_LDFLAGS = $(LDFLAGS)
110963 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
110964 index 6789d78..4afd019e 100644
110965 --- a/tools/perf/util/include/asm/alternative-asm.h
110966 +++ b/tools/perf/util/include/asm/alternative-asm.h
110967 @@ -5,4 +5,7 @@
110968
110969 #define altinstruction_entry #
110970
110971 + .macro pax_force_retaddr rip=0, reload=0
110972 + .endm
110973 +
110974 #endif
110975 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
110976 index 96b919d..c49bb74 100644
110977 --- a/tools/perf/util/include/linux/compiler.h
110978 +++ b/tools/perf/util/include/linux/compiler.h
110979 @@ -18,4 +18,12 @@
110980 #define __force
110981 #endif
110982
110983 +#ifndef __size_overflow
110984 +# define __size_overflow(...)
110985 +#endif
110986 +
110987 +#ifndef __intentional_overflow
110988 +# define __intentional_overflow(...)
110989 +#endif
110990 +
110991 #endif
110992 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
110993 index 1580dd4..5627b5b 100644
110994 --- a/virt/kvm/kvm_main.c
110995 +++ b/virt/kvm/kvm_main.c
110996 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
110997
110998 static cpumask_var_t cpus_hardware_enabled;
110999 static int kvm_usage_count = 0;
111000 -static atomic_t hardware_enable_failed;
111001 +static atomic_unchecked_t hardware_enable_failed;
111002
111003 struct kmem_cache *kvm_vcpu_cache;
111004 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
111005
111006 -static __read_mostly struct preempt_ops kvm_preempt_ops;
111007 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
111008 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
111009 +static struct preempt_ops kvm_preempt_ops = {
111010 + .sched_in = kvm_sched_in,
111011 + .sched_out = kvm_sched_out,
111012 +};
111013
111014 struct dentry *kvm_debugfs_dir;
111015
111016 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
111017 /* We can read the guest memory with __xxx_user() later on. */
111018 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
111019 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
111020 - !access_ok(VERIFY_WRITE,
111021 + !__access_ok(VERIFY_WRITE,
111022 (void __user *)(unsigned long)mem->userspace_addr,
111023 mem->memory_size)))
111024 goto out;
111025 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
111026 return 0;
111027 }
111028
111029 -static struct file_operations kvm_vcpu_fops = {
111030 +static file_operations_no_const kvm_vcpu_fops __read_only = {
111031 .release = kvm_vcpu_release,
111032 .unlocked_ioctl = kvm_vcpu_ioctl,
111033 #ifdef CONFIG_COMPAT
111034 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
111035 return 0;
111036 }
111037
111038 -static struct file_operations kvm_vm_fops = {
111039 +static file_operations_no_const kvm_vm_fops __read_only = {
111040 .release = kvm_vm_release,
111041 .unlocked_ioctl = kvm_vm_ioctl,
111042 #ifdef CONFIG_COMPAT
111043 @@ -2662,7 +2667,7 @@ out:
111044 return r;
111045 }
111046
111047 -static struct file_operations kvm_chardev_ops = {
111048 +static file_operations_no_const kvm_chardev_ops __read_only = {
111049 .unlocked_ioctl = kvm_dev_ioctl,
111050 .compat_ioctl = kvm_dev_ioctl,
111051 .llseek = noop_llseek,
111052 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
111053
111054 if (r) {
111055 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
111056 - atomic_inc(&hardware_enable_failed);
111057 + atomic_inc_unchecked(&hardware_enable_failed);
111058 printk(KERN_INFO "kvm: enabling virtualization on "
111059 "CPU%d failed\n", cpu);
111060 }
111061 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
111062
111063 kvm_usage_count++;
111064 if (kvm_usage_count == 1) {
111065 - atomic_set(&hardware_enable_failed, 0);
111066 + atomic_set_unchecked(&hardware_enable_failed, 0);
111067 on_each_cpu(hardware_enable_nolock, NULL, 1);
111068
111069 - if (atomic_read(&hardware_enable_failed)) {
111070 + if (atomic_read_unchecked(&hardware_enable_failed)) {
111071 hardware_disable_all_nolock();
111072 r = -EBUSY;
111073 }
111074 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
111075 kvm_arch_vcpu_put(vcpu);
111076 }
111077
111078 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111079 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111080 struct module *module)
111081 {
111082 int r;
111083 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111084 if (!vcpu_align)
111085 vcpu_align = __alignof__(struct kvm_vcpu);
111086 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
111087 - 0, NULL);
111088 + SLAB_USERCOPY, NULL);
111089 if (!kvm_vcpu_cache) {
111090 r = -ENOMEM;
111091 goto out_free_3;
111092 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111093 if (r)
111094 goto out_free;
111095
111096 + pax_open_kernel();
111097 kvm_chardev_ops.owner = module;
111098 kvm_vm_fops.owner = module;
111099 kvm_vcpu_fops.owner = module;
111100 + pax_close_kernel();
111101
111102 r = misc_register(&kvm_dev);
111103 if (r) {
111104 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111105
111106 register_syscore_ops(&kvm_syscore_ops);
111107
111108 - kvm_preempt_ops.sched_in = kvm_sched_in;
111109 - kvm_preempt_ops.sched_out = kvm_sched_out;
111110 -
111111 r = kvm_init_debug();
111112 if (r) {
111113 printk(KERN_ERR "kvm: create debugfs files failed\n");